liquid_feedback_frontend
view app/main/initiative/_action/add_support.lua @ 159:5d797c6706d5
implement quorum display
show the initiative quorum as a small 1px line in bargraph
allow to update your support on the diff page
better linked title in diff page
show absolute quorum numbers in detail pages of issue and initiative
show the initiative quorum as a small 1px line in bargraph
allow to update your support on the diff page
better linked title in diff page
show absolute quorum numbers in detail pages of issue and initiative
author | Daniel Poelzleithner <poelzi@poelzi.org> |
---|---|
date | Sat Oct 09 03:42:48 2010 +0200 (2010-10-09) |
parents | 034f96181e59 |
children | 6d30e49ad609 |
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 supporter.auto_support = auto_support
37 supporter:save()
38 slot.put_into("notice", _"Your support has been added to this initiative")
39 if supporter.auto_active then
40 slot.put_into("notice", _"Auto support is now enabled")
41 end
42 elseif (auto_support ~= nil and supporter.auto_support ~= auto_support) and config.auto_support then
43 supporter.auto_support = auto_support
44 if auto_support then
45 slot.put_into("notice", _"Auto support is now enabled")
46 else
47 slot.put_into("notice", _"Auto support is now disabled")
48 end
49 supporter.draft_id = last_draft.id
50 supporter:save()
51 elseif supporter.draft_id ~= last_draft.id then
52 supporter.draft_id = last_draft.id
53 supporter:save()
54 slot.put_into("notice", _"Your support has been updated to the latest draft")
55 else
56 slot.put_into("notice", _"You are already supporting the latest draft")
57 end