liquid_feedback_frontend

annotate 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
author Daniel Poelzleithner <poelzi@poelzi.org>
date Sat Oct 09 03:42:48 2010 +0200 (2010-10-09)
parents 034f96181e59
children 6d30e49ad609
rev   line source
bsw/jbe@0 1 local initiative = Initiative:new_selector():add_where{ "id = ?", param.get_id()}:single_object_mode():exec()
poelzi@148 2 local auto_support = param.get("auto_support", atom.boolean)
bsw/jbe@0 3
bsw/jbe@5 4 -- TODO important m1 selectors returning result _SET_!
bsw/jbe@5 5 local issue = initiative:get_reference_selector("issue"):for_share():single_object_mode():exec()
bsw/jbe@5 6
bsw/jbe@5 7 if issue.closed then
bsw/jbe@5 8 slot.put_into("error", _"This issue is already closed.")
bsw/jbe@5 9 return false
bsw/jbe@5 10 elseif issue.fully_frozen then
bsw/jbe@5 11 slot.put_into("error", _"Voting for this issue has already begun.")
bsw/jbe@5 12 return false
bsw/jbe@5 13 end
bsw/jbe@5 14
bsw@10 15 if initiative.revoked then
bsw@10 16 slot.put_into("error", _"This initiative is revoked")
bsw@10 17 return false
bsw@10 18 end
bsw@10 19
bsw/jbe@0 20 local member = app.session.member
bsw/jbe@0 21
bsw/jbe@0 22 local supporter = Supporter:by_pk(initiative.id, member.id)
bsw/jbe@0 23
bsw/jbe@0 24 local last_draft = Draft:new_selector()
bsw/jbe@0 25 :add_where{ "initiative_id = ?", initiative.id }
bsw/jbe@0 26 :add_order_by("id DESC")
bsw/jbe@0 27 :limit(1)
bsw/jbe@0 28 :single_object_mode()
bsw/jbe@0 29 :exec()
bsw/jbe@0 30
bsw/jbe@0 31 if not supporter then
bsw/jbe@0 32 supporter = Supporter:new()
bsw/jbe@0 33 supporter.member_id = member.id
bsw/jbe@0 34 supporter.initiative_id = initiative.id
bsw/jbe@0 35 supporter.draft_id = last_draft.id
poelzi@148 36 supporter.auto_support = auto_support
bsw/jbe@0 37 supporter:save()
bsw/jbe@0 38 slot.put_into("notice", _"Your support has been added to this initiative")
poelzi@148 39 if supporter.auto_active then
poelzi@148 40 slot.put_into("notice", _"Auto support is now enabled")
poelzi@148 41 end
poelzi@148 42 elseif (auto_support ~= nil and supporter.auto_support ~= auto_support) and config.auto_support then
poelzi@148 43 supporter.auto_support = auto_support
poelzi@148 44 if auto_support then
poelzi@148 45 slot.put_into("notice", _"Auto support is now enabled")
poelzi@148 46 else
poelzi@148 47 slot.put_into("notice", _"Auto support is now disabled")
poelzi@148 48 end
poelzi@148 49 supporter.draft_id = last_draft.id
poelzi@148 50 supporter:save()
bsw/jbe@0 51 elseif supporter.draft_id ~= last_draft.id then
bsw/jbe@0 52 supporter.draft_id = last_draft.id
bsw/jbe@0 53 supporter:save()
bsw/jbe@0 54 slot.put_into("notice", _"Your support has been updated to the latest draft")
bsw/jbe@0 55 else
bsw/jbe@0 56 slot.put_into("notice", _"You are already supporting the latest draft")
poelzi@148 57 end
poelzi@148 58

Impressum / About Us