liquid_feedback_frontend
view app/main/initiative/_action/create.lua @ 52:88ac7798b562
Several bugfixes (getpic.c, accepted but canceled issues, ...); Listing of available policies
- Bugfixes in fastpath/getpic.c (related to crashes since alpha5)
- Respect Content-Types of images in database
(needs database update, as Content-Type was incorrectly stored by previous versions)
- Typo fixed in help messages
- RSS-Feed (currently only after manual authentication while session is valid)
- Listing of available policies
- German translation fixed: "gebe" -> "gib" (Imperativ)
- Bugfixes related to issues which had been accepted but canceled afterwards
- Prohibit creation of initiatives in disabled areas or with disabled policies
- Bugfixes in fastpath/getpic.c (related to crashes since alpha5)
- Respect Content-Types of images in database
(needs database update, as Content-Type was incorrectly stored by previous versions)
- Typo fixed in help messages
- RSS-Feed (currently only after manual authentication while session is valid)
- Listing of available policies
- German translation fixed: "gebe" -> "gib" (Imperativ)
- Bugfixes related to issues which had been accepted but canceled afterwards
- Prohibit creation of initiatives in disabled areas or with disabled policies
author | bsw/jbe |
---|---|
date | Thu Apr 15 19:58:25 2010 +0200 (2010-04-15) |
parents | 72c5e0ee7c98 |
children | 3ec1dea6eefb |
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 if not area.active then
31 slot.put_into("error", "Invalid area.")
32 return false
33 end
34 end
36 local policy_id = param.get("policy_id", atom.integer)
38 if policy_id == -1 then
39 slot.put_into("error", _"Please choose a policy")
40 return false
41 end
43 local policy = Policy:by_id(policy_id)
45 if not policy.active then
46 slot.put_into("error", "Invalid policy.")
47 return false
48 end
50 local name = param.get("name")
52 local name = util.trim(name)
54 if #name < 3 then
55 slot.put_into("error", _"This name is really too short!")
56 return false
57 end
59 local initiative = Initiative:new()
61 if not issue then
62 if not area:get_reference_selector("allowed_policies")
63 :add_where{ "policy.id = ?", policy_id }
64 :optional_object_mode()
65 :exec()
66 then
67 error("policy not allowed")
68 end
69 issue = Issue:new()
70 issue.area_id = area.id
71 issue.policy_id = policy_id
72 issue:save()
73 end
75 initiative.issue_id = issue.id
76 initiative.name = name
77 param.update(initiative, "discussion_url")
78 initiative:save()
80 local draft = Draft:new()
81 draft.initiative_id = initiative.id
82 local formatting_engine = param.get("formatting_engine")
83 local formatting_engine_valid = false
84 for fe, dummy in pairs(config.formatting_engine_executeables) do
85 if formatting_engine == fe then
86 formatting_engine_valid = true
87 end
88 end
89 if not formatting_engine_valid then
90 error("invalid formatting engine!")
91 end
92 draft.formatting_engine = formatting_engine
93 draft.content = param.get("draft")
94 draft.author_id = app.session.member.id
95 draft:save()
97 local initiator = Initiator:new()
98 initiator.initiative_id = initiative.id
99 initiator.member_id = app.session.member.id
100 initiator.accepted = true
101 initiator:save()
103 local supporter = Supporter:new()
104 supporter.initiative_id = initiative.id
105 supporter.member_id = app.session.member.id
106 supporter.draft_id = draft.id
107 supporter:save()
109 slot.put_into("notice", _"Initiative successfully created")
111 request.redirect{
112 module = "initiative",
113 view = "show",
114 id = initiative.id
115 }