def create_notification(kind_name, target, metadata={}, lookup_path=None): kind_ref = NotificationKind.get(name=kind_name) notification = Notification.create(kind=kind_ref, target=target, metadata_json=json.dumps(metadata), lookup_path=lookup_path) return notification
def admin_ticket_comment(ticket): ticket = TroubleTicket.get(TroubleTicket.id == ticket) if request.form["comment"]: TicketComment.create(ticket=ticket, comment_by=session["admin"], comment=request.form["comment"], time=datetime.now()) Notification.create( team=ticket.team, notification="A response has been added for {}.".format( make_link("ticket #{}".format(ticket.id), url_for("tickets.detail", ticket_id=ticket.id)))) flash("Comment added.") if ticket.active and "resolved" in request.form: ticket.active = False ticket.save() Notification.create(team=ticket.team, notification="{} has been marked resolved.".format( make_link( "Ticket #{}".format(ticket.id), url_for("tickets.detail", ticket_id=ticket.id)))) flash("Ticket closed.") elif not ticket.active and "resolved" not in request.form: ticket.active = True ticket.save() Notification.create(team=ticket.team, notification="{} has been reopened.".format( make_link( "Ticket #{}".format(ticket.id), url_for("tickets.detail", ticket_id=ticket.id)))) flash("Ticket reopened.") return redirect(url_for(".admin_ticket_detail", ticket=ticket.id))