liquid_feedback_frontend
annotate app/main/initiative/_action/create.lua @ 5:afd9f769c7ae
Version beta1
Final voting with Schulze-Method is now possible
Many bug fixes and code cleanup
Registration with invite codes
More sort and filter options
Seperated display of "supporters" and "potential supporters"
Optical changes
Flood limit / initiative contigent is now checked by frontend
Neccessary changes to access core beta11
Final voting with Schulze-Method is now possible
Many bug fixes and code cleanup
Registration with invite codes
More sort and filter options
Seperated display of "supporters" and "potential supporters"
Optical changes
Flood limit / initiative contigent is now checked by frontend
Neccessary changes to access core beta11
author | bsw/jbe |
---|---|
date | Fri Dec 25 12:00:00 2009 +0100 (2009-12-25) |
parents | 80c215dbf076 |
children | 8d91bccab0bf |
rev | line source |
---|---|
bsw/jbe@5 | 1 local tmp = db:query({ "SELECT text_entries_left, initiatives_left FROM member_contingent_left WHERE member_id = ?", app.session.member.id }, "opt_object") |
bsw/jbe@5 | 2 if tmp then |
bsw/jbe@5 | 3 if tmp.initiatives_left and tmp.initiatives_left < 1 then |
bsw/jbe@5 | 4 slot.put_into("error", _"Sorry, your contingent for creating initiatives has been used up. Please try again later.") |
bsw/jbe@5 | 5 return false |
bsw/jbe@5 | 6 end |
bsw/jbe@5 | 7 if tmp.text_entries_left and tmp.text_entries_left < 1 then |
bsw/jbe@5 | 8 slot.put_into("error", _"Sorry, you have reached your personal flood limit. Please be slower...") |
bsw/jbe@5 | 9 return false |
bsw/jbe@5 | 10 end |
bsw/jbe@5 | 11 end |
bsw/jbe@5 | 12 |
bsw/jbe@0 | 13 local issue |
bsw/jbe@0 | 14 local area |
bsw/jbe@0 | 15 |
bsw/jbe@0 | 16 local issue_id = param.get("issue_id", atom.integer) |
bsw/jbe@0 | 17 if issue_id then |
bsw/jbe@0 | 18 issue = Issue:new_selector():add_where{"id=?",issue_id}:single_object_mode():exec() |
bsw/jbe@5 | 19 if issue.closed then |
bsw/jbe@5 | 20 slot.put_into("error", _"This issue is already closed.") |
bsw/jbe@5 | 21 return false |
bsw/jbe@5 | 22 elseif issue.fully_frozen then |
bsw/jbe@5 | 23 slot.put_into("error", _"Voting for this issue has already begun.") |
bsw/jbe@5 | 24 return false |
bsw/jbe@5 | 25 end |
bsw/jbe@0 | 26 area = issue.area |
bsw/jbe@0 | 27 else |
bsw/jbe@0 | 28 local area_id = param.get("area_id", atom.integer) |
bsw/jbe@0 | 29 area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec() |
bsw/jbe@0 | 30 end |
bsw/jbe@0 | 31 |
bsw/jbe@0 | 32 local initiative = Initiative:new() |
bsw/jbe@0 | 33 |
bsw/jbe@0 | 34 if not issue then |
bsw/jbe@0 | 35 issue = Issue:new() |
bsw/jbe@0 | 36 issue.area_id = area.id |
bsw/jbe@0 | 37 issue.policy_id = param.get("policy_id", atom.integer) |
bsw/jbe@0 | 38 issue:save() |
bsw/jbe@0 | 39 end |
bsw/jbe@0 | 40 |
bsw/jbe@5 | 41 |
bsw/jbe@5 | 42 |
bsw/jbe@0 | 43 initiative.issue_id = issue.id |
bsw@3 | 44 |
bsw@3 | 45 param.update(initiative, "name", "discussion_url") |
bsw/jbe@0 | 46 initiative:save() |
bsw/jbe@0 | 47 |
bsw/jbe@0 | 48 local draft = Draft:new() |
bsw/jbe@0 | 49 draft.initiative_id = initiative.id |
bsw/jbe@4 | 50 local formatting_engine = param.get("formatting_engine") |
bsw/jbe@4 | 51 local formatting_engine_valid = false |
bsw/jbe@4 | 52 for fe, dummy in pairs(config.formatting_engine_executeables) do |
bsw/jbe@4 | 53 if formatting_engine == fe then |
bsw/jbe@4 | 54 formatting_engine_valid = true |
bsw/jbe@4 | 55 end |
bsw/jbe@4 | 56 end |
bsw/jbe@4 | 57 if not formatting_engine_valid then |
bsw/jbe@4 | 58 error("invalid formatting engine!") |
bsw/jbe@4 | 59 end |
bsw/jbe@4 | 60 draft.formatting_engine = formatting_engine |
bsw/jbe@0 | 61 draft.content = param.get("draft") |
bsw/jbe@0 | 62 draft.author_id = app.session.member.id |
bsw/jbe@0 | 63 draft:save() |
bsw/jbe@0 | 64 |
bsw/jbe@0 | 65 local initiator = Initiator:new() |
bsw/jbe@0 | 66 initiator.initiative_id = initiative.id |
bsw/jbe@0 | 67 initiator.member_id = app.session.member.id |
bsw/jbe@0 | 68 initiator:save() |
bsw/jbe@0 | 69 |
bsw/jbe@0 | 70 local supporter = Supporter:new() |
bsw/jbe@0 | 71 supporter.initiative_id = initiative.id |
bsw/jbe@0 | 72 supporter.member_id = app.session.member.id |
bsw/jbe@0 | 73 supporter.draft_id = draft.id |
bsw/jbe@0 | 74 supporter:save() |
bsw/jbe@0 | 75 |
bsw/jbe@0 | 76 slot.put_into("notice", _"Initiative successfully created") |
bsw/jbe@0 | 77 |
bsw/jbe@0 | 78 request.redirect{ |
bsw/jbe@0 | 79 module = "initiative", |
bsw/jbe@0 | 80 view = "show", |
bsw/jbe@0 | 81 id = initiative.id |
bsw/jbe@0 | 82 } |