liquid_feedback_frontend

annotate app/main/suggestion/_action/add.lua @ 1133:48cc61cd91c3

Fixed two typos in German translation
author bsw
date Thu Jan 08 22:02:50 2015 +0100 (2015-01-08)
parents 701a5cf6b067
children 32cc544d5a5b
rev   line source
bsw@904 1 local tmp = db:query({ "SELECT text_entries_left FROM member_contingent_left WHERE member_id = ? AND NOT polling", app.session.member.id }, "opt_object")
bsw@904 2 if not tmp or tmp.text_entries_left < 1 then
bsw/jbe@5 3 slot.put_into("error", _"Sorry, you have reached your personal flood limit. Please be slower...")
bsw/jbe@5 4 return false
bsw/jbe@5 5 end
bsw/jbe@0 6
bsw@281 7 local initiative = Initiative:by_id(param.get("initiative_id", atom.integer))
bsw@281 8 if not app.session.member:has_voting_right_for_unit_id(initiative.issue.area.unit_id) then
bsw@281 9 error("access denied")
bsw@281 10 end
bsw@281 11
bsw@281 12
bsw/jbe@6 13 local name = param.get("name")
bsw/jbe@6 14 local name = util.trim(name)
bsw/jbe@6 15
bsw/jbe@6 16 if #name < 3 then
bsw/jbe@6 17 slot.put_into("error", _"This title is really too short!")
bsw/jbe@6 18 return false
bsw/jbe@6 19 end
bsw/jbe@6 20
bsw@1045 21 local formatting_engine = param.get("formatting_engine") or config.enforce_formatting_engine
bsw@279 22
bsw@279 23 local formatting_engine_valid = false
bsw@1045 24 for i, fe in ipairs(config.formatting_engines) do
bsw@1045 25 if formatting_engine == fe.id then
bsw@279 26 formatting_engine_valid = true
bsw@279 27 end
bsw@279 28 end
bsw@279 29 if not formatting_engine_valid then
bsw@279 30 error("invalid formatting engine!")
bsw@279 31 end
bsw@279 32
bsw@279 33 if param.get("preview") then
bsw@279 34 return
bsw@279 35 end
bsw@279 36
bsw/jbe@0 37 local suggestion = Suggestion:new()
bsw/jbe@0 38
bsw/jbe@0 39 suggestion.author_id = app.session.member.id
bsw/jbe@6 40 suggestion.name = name
bsw@279 41 suggestion.formatting_engine = formatting_engine
bsw@279 42 param.update(suggestion, "content", "initiative_id")
bsw/jbe@0 43 suggestion:save()
bsw/jbe@0 44
bsw/jbe@5 45 -- TODO important m1 selectors returning result _SET_!
bsw/jbe@5 46 local issue = suggestion.initiative:get_reference_selector("issue"):for_share():single_object_mode():exec()
bsw/jbe@5 47
bsw/jbe@5 48 if issue.closed then
bsw/jbe@5 49 slot.put_into("error", _"This issue is already closed.")
bsw/jbe@5 50 return false
bsw@41 51 elseif issue.half_frozen then
bsw@41 52 slot.put_into("error", _"This issue is already frozen.")
bsw/jbe@5 53 return false
bsw@964 54 elseif
bsw@964 55 (issue.half_frozen and issue.phase_finished) or
bsw@964 56 (not issue.accepted and issue.phase_finished)
bsw@964 57 then
bsw@964 58 slot.put_into("error", _"Current phase is already closed.")
bsw@964 59 return false
bsw/jbe@5 60 end
bsw/jbe@5 61
bsw/jbe@0 62 local opinion = Opinion:new()
bsw/jbe@0 63
bsw/jbe@0 64 opinion.suggestion_id = suggestion.id
bsw/jbe@0 65 opinion.member_id = app.session.member.id
bsw/jbe@0 66 opinion.degree = param.get("degree", atom.integer)
bsw/jbe@0 67 opinion.fulfilled = false
bsw/jbe@0 68
bsw/jbe@0 69 opinion:save()
bsw/jbe@0 70
bsw/jbe@0 71 slot.put_into("notice", _"Your suggestion has been added")

Impressum / About Us