liquid_feedback_frontend

view app/main/admin/_action/area_update.lua @ 1182:9aab637c19ef

Fixed usage of a global variable
author bsw
date Thu Mar 26 20:15:07 2015 +0100 (2015-03-26)
parents 701a5cf6b067
children fede09736f2b
line source
1 local area = Area:by_id(param.get_id()) or Area:new()
3 param.update(area, "unit_id", "name", "description", "active")
5 if #area.name < 1 then
6 slot.select("error", function()
7 ui.tag{ content = _"Please choose an area name" }
8 end)
9 return false
10 end
12 area:save()
14 param.update_relationship{
15 param_name = "allowed_policies",
16 id = area.id,
17 connecting_model = AllowedPolicy,
18 own_reference = "area_id",
19 foreign_reference = "policy_id"
20 }
22 -- we have to update the default flag because update_relationship can't handle it
23 local old_default = AllowedPolicy:new_selector()
24 :add_where{ "allowed_policy.area_id = ? AND allowed_policy.default_policy = 't'", area.id }
25 :optional_object_mode()
26 :exec()
28 if old_default then
29 old_default.default_policy = false;
30 old_default:save()
31 end
33 local default_policy_id = param.get("default_policy", atom.integer)
35 if default_policy_id and default_policy_id ~= -1 then
36 local pol = AllowedPolicy:new_selector()
37 :add_where{ "allowed_policy.area_id = ? AND allowed_policy.policy_id = ?", area.id, default_policy_id }
38 :optional_object_mode()
39 :exec()
40 if pol then
41 pol.default_policy = true;
42 pol:save()
43 end
44 end

Impressum / About Us