liquid_feedback_frontend
view app/main/initiative/_action/create.lua @ 10:72c5e0ee7c98
Version beta6
Bugfixes:
- Security fix: Every user was able to change the discussion URL of an initiative
- Creation of new issues in areas without default policies is now possible
- Members can now be sorted in different ways
- No error when trying to compare a draft with itself
- Added missing local statement to variable initialization in app/main/delegation/new.lua
- CSS flaw in initiative action bar fixed
New features:
- Possiblity to invite other users to become initiator
- Revokation of initiatives implemented
- Number of suggestions, supporters, etc. is shown on corresponding tabs of initiative view
- Members can now be sorted by account creation (default sorting is "newest first")
- Configuration option to create an automatic discussion link for all issues
- First draft of global timeline feature (not accessible via link yet)
- Custom stylesheet URL for users marked as developers
In area listing the number of closed issues is shown too
Renamed "author" field of initiative to "last author"
Removed wrongly included file app/main/member/_show_thumb.lua.orig in the distribution
Help texts updated
Bugfixes:
- Security fix: Every user was able to change the discussion URL of an initiative
- Creation of new issues in areas without default policies is now possible
- Members can now be sorted in different ways
- No error when trying to compare a draft with itself
- Added missing local statement to variable initialization in app/main/delegation/new.lua
- CSS flaw in initiative action bar fixed
New features:
- Possiblity to invite other users to become initiator
- Revokation of initiatives implemented
- Number of suggestions, supporters, etc. is shown on corresponding tabs of initiative view
- Members can now be sorted by account creation (default sorting is "newest first")
- Configuration option to create an automatic discussion link for all issues
- First draft of global timeline feature (not accessible via link yet)
- Custom stylesheet URL for users marked as developers
In area listing the number of closed issues is shown too
Renamed "author" field of initiative to "last author"
Removed wrongly included file app/main/member/_show_thumb.lua.orig in the distribution
Help texts updated
author | bsw |
---|---|
date | Sun Jan 10 12:00:00 2010 +0100 (2010-01-10) |
parents | 3941792e8be6 |
children | 88ac7798b562 |
line source
1 local tmp = db:query({ "SELECT text_entries_left, initiatives_left FROM member_contingent_left WHERE member_id = ?", app.session.member.id }, "opt_object")
2 if tmp then
3 if tmp.initiatives_left and tmp.initiatives_left < 1 then
4 slot.put_into("error", _"Sorry, your contingent for creating initiatives has been used up. Please try again later.")
5 return false
6 end
7 if tmp.text_entries_left and tmp.text_entries_left < 1 then
8 slot.put_into("error", _"Sorry, you have reached your personal flood limit. Please be slower...")
9 return false
10 end
11 end
13 local issue
14 local area
16 local issue_id = param.get("issue_id", atom.integer)
17 if issue_id then
18 issue = Issue:new_selector():add_where{"id=?",issue_id}:single_object_mode():exec()
19 if issue.closed then
20 slot.put_into("error", _"This issue is already closed.")
21 return false
22 elseif issue.fully_frozen then
23 slot.put_into("error", _"Voting for this issue has already begun.")
24 return false
25 end
26 area = issue.area
27 else
28 local area_id = param.get("area_id", atom.integer)
29 area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec()
30 end
32 local policy_id = param.get("policy_id", atom.integer)
34 if policy_id == -1 then
35 slot.put_into("error", _"Please choose a policy")
36 return false
37 end
39 local name = param.get("name")
41 local name = util.trim(name)
43 if #name < 3 then
44 slot.put_into("error", _"This name is really too short!")
45 return false
46 end
48 local initiative = Initiative:new()
50 if not issue then
51 if not area:get_reference_selector("allowed_policies")
52 :add_where{ "policy.id = ?", policy_id }
53 :optional_object_mode()
54 :exec()
55 then
56 error("policy not allowed")
57 end
58 issue = Issue:new()
59 issue.area_id = area.id
60 issue.policy_id = policy_id
61 issue:save()
62 end
64 initiative.issue_id = issue.id
65 initiative.name = name
66 param.update(initiative, "discussion_url")
67 initiative:save()
69 local draft = Draft:new()
70 draft.initiative_id = initiative.id
71 local formatting_engine = param.get("formatting_engine")
72 local formatting_engine_valid = false
73 for fe, dummy in pairs(config.formatting_engine_executeables) do
74 if formatting_engine == fe then
75 formatting_engine_valid = true
76 end
77 end
78 if not formatting_engine_valid then
79 error("invalid formatting engine!")
80 end
81 draft.formatting_engine = formatting_engine
82 draft.content = param.get("draft")
83 draft.author_id = app.session.member.id
84 draft:save()
86 local initiator = Initiator:new()
87 initiator.initiative_id = initiative.id
88 initiator.member_id = app.session.member.id
89 initiator.accepted = true
90 initiator:save()
92 local supporter = Supporter:new()
93 supporter.initiative_id = initiative.id
94 supporter.member_id = app.session.member.id
95 supporter.draft_id = draft.id
96 supporter:save()
98 slot.put_into("notice", _"Initiative successfully created")
100 request.redirect{
101 module = "initiative",
102 view = "show",
103 id = initiative.id
104 }