liquid_feedback_frontend

diff app/main/initiative/_action/create.lua @ 0:3bfb2fcf7ab9

Version alpha1
author bsw/jbe
date Wed Nov 18 12:00:00 2009 +0100 (2009-11-18)
parents
children 768faea1096d
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/initiative/_action/create.lua	Wed Nov 18 12:00:00 2009 +0100
     1.3 @@ -0,0 +1,54 @@
     1.4 +local issue
     1.5 +local area
     1.6 +
     1.7 +db:query("BEGIN")
     1.8 +
     1.9 +local issue_id = param.get("issue_id", atom.integer)
    1.10 +if issue_id then
    1.11 +  issue = Issue:new_selector():add_where{"id=?",issue_id}:single_object_mode():exec()
    1.12 +  area = issue.area
    1.13 +
    1.14 +else
    1.15 +  local area_id = param.get("area_id", atom.integer)
    1.16 +  area = Area:new_selector():add_where{"id=?",area_id}:single_object_mode():exec()
    1.17 +end
    1.18 +
    1.19 +local initiative = Initiative:new()
    1.20 +
    1.21 +if not issue then
    1.22 +  issue = Issue:new()
    1.23 +  issue.area_id = area.id
    1.24 +  issue.policy_id = param.get("policy_id", atom.integer)
    1.25 +  issue:save()
    1.26 +end
    1.27 +
    1.28 +initiative.issue_id = issue.id
    1.29 +param.update(initiative, "name")
    1.30 +initiative:save()
    1.31 +
    1.32 +local draft = Draft:new()
    1.33 +draft.initiative_id = initiative.id
    1.34 +draft.content = param.get("draft")
    1.35 +draft.author_id = app.session.member.id
    1.36 +draft:save()
    1.37 +
    1.38 +local initiator = Initiator:new()
    1.39 +initiator.initiative_id = initiative.id
    1.40 +initiator.member_id = app.session.member.id
    1.41 +initiator:save()
    1.42 +
    1.43 +local supporter = Supporter:new()
    1.44 +supporter.initiative_id = initiative.id
    1.45 +supporter.member_id = app.session.member.id
    1.46 +supporter.draft_id = draft.id
    1.47 +supporter:save()
    1.48 +
    1.49 +db:query("COMMIT")
    1.50 +
    1.51 +slot.put_into("notice", _"Initiative successfully created")
    1.52 +
    1.53 +request.redirect{
    1.54 +  module = "initiative",
    1.55 +  view = "show",
    1.56 +  id = initiative.id
    1.57 +}
    1.58 \ No newline at end of file

Impressum / About Us