liquid_feedback_frontend
view app/main/admin/_action/area_update.lua @ 595:bc6934411019
Added unit editor, small fixes at admin section
author | bsw |
---|---|
date | Sun Jun 24 20:41:50 2012 +0200 (2012-06-24) |
parents | f42d16567c5d |
children | 701a5cf6b067 |
line source
1 local area = Area:by_id(param.get_id()) or Area:new()
3 param.update(area, "unit_id", "name", "description", "active")
5 area:save()
7 param.update_relationship{
8 param_name = "allowed_policies",
9 id = area.id,
10 connecting_model = AllowedPolicy,
11 own_reference = "area_id",
12 foreign_reference = "policy_id"
13 }
15 -- we have to update the default flag because update_relationship can't handle it
16 old_default = AllowedPolicy:new_selector()
17 :add_where{ "allowed_policy.area_id = ? AND allowed_policy.default_policy = 't'", area.id }
18 :optional_object_mode()
19 :exec()
21 if old_default then
22 old_default.default_policy = false;
23 old_default:save()
24 end
26 default_policy_id = param.get("default_policy", atom.integer)
28 if default_policy_id and default_policy_id ~= -1 then
29 pol = AllowedPolicy:new_selector()
30 :add_where{ "allowed_policy.area_id = ? AND allowed_policy.policy_id = ?", area.id, default_policy_id }
31 :optional_object_mode()
32 :exec()
33 if pol then
34 pol.default_policy = true;
35 pol:save()
36 end
37 end