liquid_feedback_frontend
view app/main/initiative/_action/add_support.lua @ 210:2c422bcb79de
Added tag beta31 for changeset bfd8d88f72fc
- Added support to lock inactive member
- Added esperanto translations for new phrases
- Improved and corrected some esperanto phrases
- Display delegation warnings only for open issues
- Refactored code: admin, area, contact and delegation module
- Translated admin menu
- Added policy editor to admin area
- Save and display last login date
- Small fixes
- Added support to lock inactive member
- Added esperanto translations for new phrases
- Improved and corrected some esperanto phrases
- Display delegation warnings only for open issues
- Refactored code: admin, area, contact and delegation module
- Translated admin menu
- Added policy editor to admin area
- Save and display last login date
- Small fixes
| author | bsw | 
|---|---|
| date | Sat Feb 05 20:01:09 2011 +0100 (2011-02-05) | 
| parents | 6d30e49ad609 | 
| children | bde068b37608 | 
 line source
     1 local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec()
     2 local auto_support = param.get("auto_support", atom.boolean)
     4 -- TODO important m1 selectors returning result _SET_!
     5 local issue = initiative:get_reference_selector("issue"):for_share():single_object_mode():exec()
     7 if issue.closed then
     8   slot.put_into("error", _"This issue is already closed.")
     9   return false
    10 elseif issue.fully_frozen then 
    11   slot.put_into("error", _"Voting for this issue has already begun.")
    12   return false
    13 end
    15 if initiative.revoked then
    16   slot.put_into("error", _"This initiative is revoked")
    17   return false
    18 end
    20 local member = app.session.member
    22 local supporter = Supporter:by_pk(initiative.id, member.id)
    24 local last_draft = Draft:new_selector()
    25   :add_where{ "initiative_id = ?", initiative.id }
    26   :add_order_by("id DESC")
    27   :limit(1)
    28   :single_object_mode()
    29   :exec()
    31 if not supporter then
    32   supporter = Supporter:new()
    33   supporter.member_id = member.id
    34   supporter.initiative_id = initiative.id
    35   supporter.draft_id = last_draft.id
    36   if config.auto_support and auto_support ~= nil then
    37     supporter.auto_support = auto_support
    38   end
    39   supporter:save()
    40   slot.put_into("notice", _"Your support has been added to this initiative")
    41   if supporter.auto_active then
    42     slot.put_into("notice", _"Auto support is now enabled")
    43   end
    44 elseif (auto_support ~= nil and supporter.auto_support ~= auto_support) and config.auto_support then
    45   supporter.auto_support = auto_support
    46   if auto_support then
    47     slot.put_into("notice", _"Auto support is now enabled")
    48   else
    49     slot.put_into("notice", _"Auto support is now disabled")
    50   end
    51   supporter.draft_id = last_draft.id
    52   supporter:save()
    53 elseif supporter.draft_id ~= last_draft.id then
    54   supporter.draft_id = last_draft.id
    55   supporter:save()
    56   slot.put_into("notice", _"Your support has been updated to the latest draft")
    57 else
    58   slot.put_into("notice", _"You are already supporting the latest draft")
    59 end
