def team_ticket_comment(ticket): try: ticket = TroubleTicket.get(TroubleTicket.id == ticket) except TroubleTicket.DoesNotExist: flash("Couldn't find ticket #{}.".format(ticket)) return redirect(url_for("team_tickets")) if ticket.team != g.team: flash("That's not your ticket.") return redirect(url_for("team_tickets")) if request.form["comment"]: TicketComment.create(ticket=ticket, comment_by=g.team.name, comment=request.form["comment"], time=datetime.now()) flash("Comment added.") if ticket.active and "resolved" in request.form: ticket.active = False ticket.save() flash("Ticket closed.") elif not ticket.active and "resolved" not in request.form: ticket.active = True ticket.save() flash("Ticket re-opened.") return redirect(url_for("team_ticket_detail", ticket=ticket.id))
def admin_ticket_detail(ticket): ticket = TroubleTicket.get(TroubleTicket.id == ticket) comments = list(TicketComment.select().where( TicketComment.ticket == ticket).order_by(TicketComment.time)) return render_template("admin/ticket_detail.html", ticket=ticket, comments=comments)
def admin_dashboard(): teams = Team.select() solves = ChallengeSolve.select(ChallengeSolve, Challenge).join(Challenge) adjustments = ScoreAdjustment.select() scoredata = utils.scoreboard.get_all_scores(teams, solves, adjustments) lastsolvedata = utils.scoreboard.get_last_solves(teams, solves) tickets = list(TroubleTicket.select().where(TroubleTicket.active == True)) return render_template("admin/dashboard.html", teams=teams, scoredata=scoredata, lastsolvedata=lastsolvedata, tickets=tickets)
def open_ticket(): if request.method == "GET": return render_template("open_ticket.html") elif request.method == "POST": summary = request.form["summary"] description = request.form["description"] opened_at = datetime.now() ticket = TroubleTicket.create(team=g.team, summary=summary, description=description, opened_at=opened_at) flash("Ticket #{} opened.".format(ticket.id)) return redirect(url_for("team_ticket_detail", ticket=ticket.id))
def team_ticket_detail(ticket): try: ticket = TroubleTicket.get(TroubleTicket.id == ticket) except TroubleTicket.DoesNotExist: flash("Could not find ticket #{}.".format(ticket)) return redirect(url_for("team_tickets")) if ticket.team != g.team: flash("That is not your ticket.") return redirect(url_for("team_tickets")) comments = TicketComment.select().where(TicketComment.ticket == ticket).order_by(TicketComment.time) return render_template("ticket_detail.html", ticket=ticket, comments=comments)
def team_ticket_detail(ticket): try: ticket = TroubleTicket.get(TroubleTicket.id == ticket) except TroubleTicket.DoesNotExist: flash("Couldn't find ticket #{}.".format(ticket)) return redirect(url_for("team_tickets")) if ticket.team != g.team: flash("That's not your ticket.") return redirect(url_for("team_tickets")) comments = TicketComment.select().where(TicketComment.ticket == ticket).order_by(TicketComment.time.desc()) return render_template("ticket_detail.html", ticket=ticket, comments=comments)
def open_ticket(): if request.method == "GET": return render_template("open_ticket.html") elif request.method == "POST": if g.redis.get("ticketl{}".format(session["team_id"])): return "You're doing that too fast." g.redis.set("ticketl{}".format(g.team.id), "1", 30) summary = request.form["summary"] description = request.form["description"] opened_at = datetime.now() ticket = TroubleTicket.create(team=g.team, summary=summary, description=description, opened_at=opened_at) flash("Ticket #{} opened.".format(ticket.id)) return redirect(url_for("team_ticket_detail", ticket=ticket.id))
def open_ticket(): if request.method == "GET": return render_template("open_ticket.html") else: if g.redis.get("ticketl{}".format(session["team_id"])): return "You're doing that too fast." g.redis.set("ticketl{}".format(g.team.id), "1", 10) summary = request.form["summary"] description = request.form["description"] if not summary: flash("summary can not be null") return redirect(url_for("team_tickets")) if not description: flash("description can not be null") return redirect(url_for("team_tickets")) opened_at = datetime.now() ticket = TroubleTicket.create(team=g.team, summary=summary, description=description, opened_at=opened_at) app.logger.info(g.user.username+" opened a ticket,ticket's id is "+str(ticket.id)) flash("Ticket #{} opened.".format(ticket.id)) return redirect(url_for("team_ticket_detail", ticket=ticket.id))
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("team_ticket_detail", ticket=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("team_ticket_detail", ticket=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("team_ticket_detail", ticket=ticket.id)))) flash("Ticket reopened.") return redirect(url_for(".admin_ticket_detail", ticket=ticket.id))
def team_ticket_comment(ticket): if g.redis.get("ticketl{}".format(session["team_id"])): return "You are doing that too fast." g.redis.set("ticketl{}".format(g.team.id), "1", 10) try: ticket = TroubleTicket.get(TroubleTicket.id == ticket) except TroubleTicket.DoesNotExist: flash("Could not find ticket #{}.".format(ticket)) return redirect(url_for("team_tickets")) if ticket.team != g.team: flash("That is not your ticket.") return redirect(url_for("team_tickets")) if request.form["comment"]: comment = request.form["comment"] if not comment: flash("comment can not be null") return redirect(url_for("team_ticket_detail", ticket=ticket.id)) TicketComment.create(ticket=ticket, comment_by=g.team.name, comment=comment, time=datetime.now()) app.logger.info(g.user.username+" comment a ticket,ticket's id is "+str(ticket.id)) flash("Comment added.") if ticket.active and "resolved" in request.form: ticket.active = False ticket.save() app.logger.info(g.user.username+" closed a ticket,ticket's id is "+str(ticket.id)) flash("Ticket closed.") elif not ticket.active and "resolved" not in request.form: ticket.active = True ticket.save() app.logger.info(g.user.username+" re-opened a ticket,ticket's id is "+str(ticket.id)) flash("Ticket re-opened.") return redirect(url_for("team_ticket_detail", ticket=ticket.id))
def admin_ticket_detail(ticket): ticket = TroubleTicket.get(TroubleTicket.id == ticket) comments = list(TicketComment.select().where(TicketComment.ticket == ticket)) return render_template("admin/ticket_detail.html", ticket=ticket, comments=comments)
def admin_tickets(): tickets = list(TroubleTicket.select(TroubleTicket, Team).join(Team)) return render_template("admin/tickets.html", tickets=tickets)