예제 #1
0
def ticket_detail(project_id, ticket_id):
    project = Project.query.filter_by(id=project_id).first()
    ticket = Ticket.query.filter_by(id=ticket_id).filter_by(current_status='open').first()
    error = None

    if project is None:
        abort(404)

    if ticket is None:
        archive = Ticket.query.filter_by(id=ticket_id).filter_by(current_status='closed').first()
        if archive is None:
            abort(404)
        else:
            return redirect(url_for('archive_detail', project_id=project_id, ticket_id=ticket_id))

    if request.method == 'POST':
        try:
            c = Comment(request.form['name'],
                    request.form['email'],
                    request.form['content'],
                    )
            c.ticket = ticket
            db_session.add(c)
            db_session.commit()

            flash("New comment was successfully submitted.")
            return redirect(url_for('ticket_detail', project_id=project_id, ticket_id=ticket_id))

        except Exception as e:
            error = "There was an issue creating ticket."

    return render_template('ticket_detail.html', project=project, ticket=ticket, error=error)
예제 #2
0
def submit_ticket(project_id):
    project = Project.query.filter_by(id=project_id).first()
    error = None

    if project is None:
        abort(404)

    if request.method == 'POST':
        print(request.form)
        try:
            t = Ticket(request.form['name'], request.form['email'],
                       request.form['title'], request.form['content'],
                       request.form['priority'])
            t.project = project
            db_session.add(t)
            db_session.commit()

            print("post method form submission")
            flash("New ticket was successfully submitted.")
            return redirect(url_for('project_detail', project_id=project_id))

        except Exception as e:
            print(e)
            error = "There was an issue creating ticket."

    return render_template('submit_ticket.html', project=project, error=error)
예제 #3
0
def submit_ticket(project_id):
    project = Project.query.filter_by(id=project_id).first()
    error = None

    if project is None:
        abort(404)

    if request.method == 'POST':
        print(request.form)
        try:
            t = Ticket(request.form['name'],
                    request.form['email'],
                    request.form['title'],
                    request.form['content'],
                    request.form['priority']
                    )
            t.project = project
            db_session.add(t)
            db_session.commit()

            print("post method form submission")
            flash("New ticket was successfully submitted.")
            return redirect(url_for('project_detail', project_id=project_id))

        except Exception as e:
            print(e)
            error = "There was an issue creating ticket."

    return render_template('submit_ticket.html', project=project, error=error)
예제 #4
0
def create_project():
    j = request.get_json()
    try:
        m = Maintainer.query.filter_by(id=j['maintainerId']).one()
        p = Project(j['title'], j['description'], m)
        db_session.add(p)
        db_session.commit()
        print(p)
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue creating project resource.")

    return jsonify(success=j), 201
예제 #5
0
def create_project():
    j = request.get_json()
    try:
        m = Maintainer.query.filter_by(id=j['maintainerId']).one()
        p = Project(j['title'], j['description'], m)
        db_session.add(p)
        db_session.commit()
        print(p)
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue creating project resource.")

    return jsonify(success=j), 201
예제 #6
0
def create_ticket():
    j = request.get_json()
    try:
        p = Project.query.filter_by(id=j['projectId']).one()
        t = Ticket(j['name'], j['email'], j['title'], j['content'],
                   j['priority'], p)
        db_session.add(t)
        db_session.commit()
        print(t)
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue creating ticket resource.")

    return jsonify(success=j), 201
예제 #7
0
def create_comment():
    j = request.get_json()
    try:
        t = Ticket.query.filter_by(id=j['ticketId']).one()
        c = Comment(j['name'], j['email'], j['content'], t)
        c.is_maintainer = True
        db_session.add(c)
        db_session.commit()
        print(c)
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue creating comment resource.")

    return jsonify(success=j), 201
예제 #8
0
def update_project(project_id):
    j = request.get_json()
    try:
        p = Project.query.filter_by(id=project_id).one()
        p.title = j['title']
        p.description = j['description']
        p.date_modified = datetime.now()

        db_session.add(p)
        db_session.commit()
        print(p)
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue updating project resource.")

    return jsonify(project=p.serialize)
예제 #9
0
def update_comment(comment_id):
    j = request.get_json()
    print(j)
    try:
        c = Comment.query.filter_by(id=comment_id).one()
        c.name = j['name']
        c.email = j['email']
        c.content = j['content']

        db_session.add(c)
        db_session.commit()
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue updating comment resource.")

    return jsonify(comment=c.serialize)
예제 #10
0
def update_project(project_id):
    j = request.get_json()
    try:
        p = Project.query.filter_by(id=project_id).one()
        p.title = j['title']
        p.description = j['description']
        p.date_modified = datetime.now()

        db_session.add(p)
        db_session.commit()
        print(p)
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue updating project resource.")

    return jsonify(project=p.serialize)
예제 #11
0
def update_comment(comment_id):
    j = request.get_json()
    print(j)
    try:
        c = Comment.query.filter_by(id=comment_id).one()
        c.name = j['name']
        c.email = j['email']
        c.content = j['content']

        db_session.add(c)
        db_session.commit()
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue updating comment resource.")

    return jsonify(comment=c.serialize)
예제 #12
0
def create_comment():
    j = request.get_json()
    try:
        t = Ticket.query.filter_by(id=j['ticketId']).one()
        c = Comment(j['name'],
                    j['email'],
                    j['content'],
                    t)
        c.is_maintainer = True
        db_session.add(c)
        db_session.commit()
        print(c)
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue creating comment resource.")

    return jsonify(success=j), 201
예제 #13
0
def create_ticket():
    j = request.get_json()
    try:
        p = Project.query.filter_by(id=j['projectId']).one()
        t = Ticket(j['name'],
                   j['email'],
                   j['title'],
                   j['content'],
                   j['priority'],
                   p)
        db_session.add(t)
        db_session.commit()
        print(t)
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue creating ticket resource.")

    return jsonify(success=j), 201
예제 #14
0
def ticket_detail(project_id, ticket_id):
    project = Project.query.filter_by(id=project_id).first()
    ticket = Ticket.query.filter_by(id=ticket_id).filter_by(
        current_status='open').first()
    error = None

    if project is None:
        abort(404)

    if ticket is None:
        archive = Ticket.query.filter_by(id=ticket_id).filter_by(
            current_status='closed').first()
        if archive is None:
            abort(404)
        else:
            return redirect(
                url_for('archive_detail',
                        project_id=project_id,
                        ticket_id=ticket_id))

    if request.method == 'POST':
        try:
            c = Comment(
                request.form['name'],
                request.form['email'],
                request.form['content'],
            )
            c.ticket = ticket
            db_session.add(c)
            db_session.commit()

            flash("New comment was successfully submitted.")
            return redirect(
                url_for('ticket_detail',
                        project_id=project_id,
                        ticket_id=ticket_id))

        except Exception as e:
            error = "There was an issue creating ticket."

    return render_template('ticket_detail.html',
                           project=project,
                           ticket=ticket,
                           error=error)
예제 #15
0
def update_ticket(ticket_id):
    j = request.get_json()
    print(j)
    try:
        t = Ticket.query.filter_by(id=ticket_id).one()
        t.date_modified = datetime.now()
        t.name = j['name']
        t.email = j['email']
        t.title = j['title']
        t.content = j['content']
        t.current_priority = j['priority']
        t.current_status = j['status']

        db_session.add(t)
        db_session.commit()
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue updating ticket resource.")

    return jsonify(ticket=t.serialize)
예제 #16
0
def update_ticket(ticket_id):
    j = request.get_json()
    print(j)
    try:
        t = Ticket.query.filter_by(id=ticket_id).one()
        t.date_modified = datetime.now()
        t.name = j['name']
        t.email = j['email']
        t.title = j['title']
        t.content = j['content']
        t.current_priority = j['priority']
        t.current_status = j['status']

        db_session.add(t)
        db_session.commit()
    except Exception as e:
        print("Exception occurred: {}".format(e))
        return jsonify(error="There was an issue updating ticket resource.")

    return jsonify(ticket=t.serialize)