liquid_feedback_frontend
view app/main/admin/_action/area_update.lua @ 172:165f4bd02cf3
don't show the first draft of a new initiative as a new draft event in the timeline
new draft should only show changes of drafts drafts of new initiatives as they are handled by the new initiative event
new draft should only show changes of drafts drafts of new initiatives as they are handled by the new initiative event
| author | Daniel Poelzleithner <poelzi@poelzi.org> |
|---|---|
| date | Sun Oct 10 19:40:32 2010 +0200 (2010-10-10) |
| parents | 36aedac3e4bf |
| children | 46351752814f |
line source
1 if not app.session.member.admin then
2 error()
3 end
5 local id = param.get_id()
7 local area
8 if id then
9 area = Area:new_selector():add_where{ "id = ?", id }:single_object_mode():exec()
10 else
11 area = Area:new()
12 end
15 param.update(area, "name", "description", "active")
17 area:save()
19 param.update_relationship{
20 param_name = "allowed_policies",
21 id = area.id,
22 connecting_model = AllowedPolicy,
23 own_reference = "area_id",
24 foreign_reference = "policy_id"
25 }
27 -- we have to update the default flag because update_relationship can't handle it
28 old_default = AllowedPolicy:new_selector()
29 :add_where{ "allowed_policy.area_id = ? AND allowed_policy.default_policy = 't'", area.id }
30 :optional_object_mode()
31 :exec()
33 if old_default then
34 old_default.default_policy = false;
35 old_default:save()
36 end
38 default_policy_id = param.get("default_policy", atom.integer)
40 if default_policy_id and default_policy_id ~= -1 then
41 pol = AllowedPolicy:new_selector()
42 :add_where{ "allowed_policy.area_id = ? AND allowed_policy.policy_id = ?", area.id, default_policy_id }
43 :optional_object_mode()
44 :exec()
45 if pol then
46 pol.default_policy = true;
47 pol:save()
48 end
49 end
51 slot.put_into("notice", _"Area successfully updated")
