liquid_feedback_frontend

annotate app/main/suggestion/_action/add.lua @ 1859:02c34183b6df

Fixed wrong filename in INSTALL file
author bsw
date Tue Nov 28 18:54:51 2023 +0100 (6 months ago)
parents 32cc544d5a5b
children
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/jbe@1309 9 return execute.view { module = "index", view = "403" }
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/jbe@1309 30 slot.put_into("error", "invalid formatting engine!")
bsw/jbe@1309 31 return false
bsw@279 32 end
bsw@279 33
bsw@279 34 if param.get("preview") then
bsw@279 35 return
bsw@279 36 end
bsw@279 37
bsw/jbe@0 38 local suggestion = Suggestion:new()
bsw/jbe@0 39
bsw/jbe@0 40 suggestion.author_id = app.session.member.id
bsw/jbe@6 41 suggestion.name = name
bsw@279 42 suggestion.formatting_engine = formatting_engine
bsw@279 43 param.update(suggestion, "content", "initiative_id")
bsw/jbe@0 44 suggestion:save()
bsw/jbe@0 45
bsw/jbe@5 46 -- TODO important m1 selectors returning result _SET_!
bsw/jbe@5 47 local issue = suggestion.initiative:get_reference_selector("issue"):for_share():single_object_mode():exec()
bsw/jbe@5 48
bsw/jbe@5 49 if issue.closed then
bsw/jbe@5 50 slot.put_into("error", _"This issue is already closed.")
bsw/jbe@5 51 return false
bsw@41 52 elseif issue.half_frozen then
bsw@41 53 slot.put_into("error", _"This issue is already frozen.")
bsw/jbe@5 54 return false
bsw@964 55 elseif
bsw@964 56 (issue.half_frozen and issue.phase_finished) or
bsw@964 57 (not issue.accepted and issue.phase_finished)
bsw@964 58 then
bsw@964 59 slot.put_into("error", _"Current phase is already closed.")
bsw@964 60 return false
bsw/jbe@5 61 end
bsw/jbe@5 62
bsw/jbe@0 63 local opinion = Opinion:new()
bsw/jbe@0 64
bsw/jbe@0 65 opinion.suggestion_id = suggestion.id
bsw/jbe@0 66 opinion.member_id = app.session.member.id
bsw/jbe@0 67 opinion.degree = param.get("degree", atom.integer)
bsw/jbe@0 68 opinion.fulfilled = false
bsw/jbe@0 69
bsw/jbe@0 70 opinion:save()
bsw/jbe@0 71
bsw/jbe@1309 72 slot.put_into("notice", _"Your suggestion has been added")

Impressum / About Us