liquid_feedback_frontend

diff app/main/admin/_action/area_update.lua @ 126:36aedac3e4bf

Add default policy selector in area admin
author Daniel Poelzleithner <poelzi@poelzi.org>
date Mon Oct 04 15:52:22 2010 +0200 (2010-10-04)
parents 915cc0341538
children 46351752814f
line diff
     1.1 --- a/app/main/admin/_action/area_update.lua	Mon Oct 04 14:37:13 2010 +0200
     1.2 +++ b/app/main/admin/_action/area_update.lua	Mon Oct 04 15:52:22 2010 +0200
     1.3 @@ -24,4 +24,28 @@
     1.4    foreign_reference = "policy_id"
     1.5  }
     1.6  
     1.7 +-- we have to update the default flag because update_relationship can't handle it
     1.8 +old_default = AllowedPolicy:new_selector()
     1.9 +:add_where{ "allowed_policy.area_id = ? AND allowed_policy.default_policy = 't'", area.id }
    1.10 +:optional_object_mode()
    1.11 +:exec()
    1.12 +
    1.13 +if old_default then
    1.14 +  old_default.default_policy = false;
    1.15 +  old_default:save()
    1.16 +end
    1.17 +
    1.18 +default_policy_id = param.get("default_policy", atom.integer)
    1.19 +
    1.20 +if default_policy_id and default_policy_id ~= -1 then
    1.21 +  pol = AllowedPolicy:new_selector()
    1.22 +  :add_where{ "allowed_policy.area_id = ? AND allowed_policy.policy_id = ?", area.id, default_policy_id }
    1.23 +  :optional_object_mode()
    1.24 +  :exec()
    1.25 +  if pol then
    1.26 +    pol.default_policy = true;
    1.27 +    pol:save()
    1.28 +  end
    1.29 +end
    1.30 +
    1.31  slot.put_into("notice", _"Area successfully updated")

Impressum / About Us