def accept(id): if not mproposal.Proposal.exists(id): abort(404) proposal = mproposal.Proposal(id) cuser = muser.getCurrentUser() if not cuser.isMod(): abort(403) if proposal.getDetail("courseid") == 0: proposal.createCourse() proposal = mproposal.Proposal(id) owner = proposal.getProposer() cmail.send_textbased_email( owner.getDetail("email"), "Dein Kursvorschlag für '" + proposal.getTitle() + "' war erfolgreich!", """Hallo %s, dein Kursvorschlag für einen Kurs ## %s war erfolgreich. Du kannst jetzt den Kurs erstellen. {# Zum Kurs -> %s #}""" % (owner.getDetail("realname"), proposal.getTitle(), request.url_root + "c/" + str(proposal.getDetail("courseid")))) return "{ok}"
def commit(id): if not mproposal.Proposal.exists(id): abort(404) proposal = mproposal.Proposal(id) cuser = muser.getCurrentUser() if cuser.isDisabled() or not cuser.isLoggedIn(): return "[no.permission]" if not proposal.hasUserCommitment(cuser): proposal.addUserCommitment(cuser) return "{ok}"
def unclose(id): if not mproposal.Proposal.exists(id): abort(404) proposal = mproposal.Proposal(id) cuser = muser.getCurrentUser() if not cuser.isMod(): abort(404) proposal.setDetail("declined", 0) proposal.setDetail("decline_reason", "") return "{ok}"
def close(id): if not mproposal.Proposal.exists(id): abort(404) proposal = mproposal.Proposal(id) cuser = muser.getCurrentUser() if not cuser.isMod(): abort(404) data = request.json proposal.setDetail("declined", 1) proposal.setDetail("decline_reason", data["reason"]) return "{ok}"
def single(id): if not mproposal.Proposal.exists(id): abort(404) data = mproposal.Proposal(id) cuser = muser.getCurrentUser() if data.isDeleted() and not cuser.isMod(): abort(404) return render_template('proposal/show.html', title="Kursvorschlag: " + data.getTitle(), thispage="course", data=data)
def courses_propose(): cuser = muser.getCurrentUser() if not cuser.isLoggedIn() or cuser.isDisabled(): abort(403) if S.get("limit-course-creation") == "yes" and not cuser.isTeam(): abort(403) if request.method == "GET": if S.get("limit-course-creation") == "yes": return render_template('courses/propose.html', title="Kurs erstellen", thispage="courses", topic=mcourses.Topic) return render_template('courses/propose.html', title="Kurs vorschlagen", thispage="courses", topic=mcourses.Topic) elif request.method == "POST": if cuser.may("course_propose"): data = request.json topic = data["topic"] title = data["title"].strip() shortdesc = data["shortdesc"].strip() longdesc = data["longdesc"].strip() requirements = data["requirements"].strip() topic = mcourses.Topic(topic) if not topic.isGiveable(): return jsonify({ "result": "error", "error": "Das Thema " + topic.getTitle() + " kann nicht vergeben werden." }) errors = _validateCourse(title, shortdesc, longdesc, requirements) if len(errors) != 0: return jsonify({"result": "errors", "errors": errors}) p = mproposal.Proposal.createNew(topic.id, title, shortdesc, longdesc, requirements, cuser) if S.get("limit-course-creation") == "yes": p.createCourse() p = mproposal.Proposal(p.id) p.setDetail("deleted", 1) return jsonify({ "result": "success", "url": url_for("course_info", id=p.getDetail("courseid")) }) if p: return jsonify({ "result": "success", "url": url_for("proposal.single", id=p.id) }) return jsonify({ "result": "error", "error": "Ein Fehler ist aufgetreten." }) else: abort(405)