コード例 #1
0
def release(ticket_id=False):
    if ticket_id:

        ticket = FlicketTicket.query.filter_by(id=ticket_id).first()

        # is ticket assigned.
        if not ticket.assigned:
            flash('Ticket has not been assigned')
            return redirect(
                url_for('flicket_bp.ticket_view', ticket_id=ticket_id))

        # check ticket is owned by user or user is admin
        if (ticket.assigned.id != g.user.id) and (not g.user.is_admin):
            flash('You can not release a ticket you are not working on.')
            return redirect(
                url_for('flicket_bp.ticket_view', ticket_id=ticket_id))

        # set status to open
        status = FlicketStatus.query.filter_by(status='Open').first()
        ticket.current_status = status
        ticket.assigned = None
        db.session.commit()

        # add action record
        add_action(action='release', ticket=ticket)

        # send email to state ticket has been released.
        f_mail = FlicketMail()
        f_mail.release_ticket(ticket)

        flash('You released ticket: {}'.format(ticket.id))
        return redirect(url_for('flicket_bp.ticket_view', ticket_id=ticket.id))

    return redirect(url_for('flicket_bp.tickets'))
コード例 #2
0
def release(ticket_id=False):

    if ticket_id:

        ticket = FlicketTicket.query.filter_by(id=ticket_id).first()

        # is ticket assigned.
        if not ticket.assigned:
            flash(gettext("Ticket has not been assigned"))
            return redirect(
                url_for("flicket_bp.ticket_view", ticket_id=ticket_id))

        # check ticket is owned by user or user is admin
        if (ticket.assigned.id != g.user.id) and (not g.user.is_admin):
            flash(
                gettext(
                    "You can not release a ticket you are not working on."))
            return redirect(
                url_for("flicket_bp.ticket_view", ticket_id=ticket_id))

        # set status to open
        status = FlicketStatus.query.filter_by(status="New").first()
        ticket.current_status = status
        user = ticket.assigned
        ticket.assigned = None
        user.total_assigned -= 1

        db.session.commit()

        # add action record
        add_action(ticket, "release")

        # send email to state ticket has been released.
        f_mail = FlicketMail()
        f_mail.release_ticket(ticket)

        flash(gettext("You released ticket: %(value)s", value=ticket.id))
        return redirect(url_for("flicket_bp.ticket_view", ticket_id=ticket.id))

    return redirect(url_for("flicket_bp.tickets"))
コード例 #3
0
ファイル: release.py プロジェクト: teemal/flicket
def release(ticket_id=False):

    if ticket_id:

        ticket = FlicketTicket.query.filter_by(id=ticket_id).first()

        # is ticket assigned.
        if not ticket.assigned:
            flash(gettext('Ticket has not been assigned'), category='warning')
            return redirect(url_for('flicket_bp.ticket_view', ticket_id=ticket_id))

        # check ticket is owned by user or user is admin
        if (ticket.assigned.id != g.user.id) and (not g.user.is_admin):
            flash(gettext('You can not release a ticket you are not working on.'), category='warning')
            return redirect(url_for('flicket_bp.ticket_view', ticket_id=ticket_id))

        # set status to open
        status = FlicketStatus.query.filter_by(status='Open').first()
        ticket.current_status = status
        ticket.last_updated = datetime.datetime.now()
        user = ticket.assigned
        ticket.assigned = None
        user.total_assigned -= 1

        db.session.commit()

        # add action record
        add_action(ticket, 'release')

        # send email to state ticket has been released.
        f_mail = FlicketMail()
        f_mail.release_ticket(ticket)

        flash(gettext('You released ticket: %(value)s', value=ticket.id), category='success')
        return redirect(url_for('flicket_bp.ticket_view', ticket_id=ticket.id))

    return redirect(url_for('flicket_bp.tickets'))