コード例 #1
0
ファイル: views.py プロジェクト: binaryatrocity/packetcrypt
def editticket(tid):
    user = g.user
    t = Ticket.query.get(tid)
    form = TicketForm(subject=t.subject, body=t.body)
    if form.validate_on_submit():
        import datetime
        form.populate_obj(t)
        t.timestamp = datetime.datetime.utcnow()
        flash("Updated ticket: " + t.subject)
        db.session.commit()
        return redirect('/dashboard')
    return render_template('editticket.html', user=user, ticket=t, form=form)
コード例 #2
0
ファイル: views.py プロジェクト: binaryatrocity/packetcrypt
def newticket():
    user = g.user
    form = TicketForm()
    if form.validate_on_submit():
        import datetime
        t = Ticket()
        form.populate_obj(t)
        t.timestamp = datetime.datetime.utcnow()
        t.created = datetime.datetime.utcnow()
        t.user_id = user.id
        db.session.add(t);
        db.session.commit()

        flash('New ticket submitted: ' + form.subject.data)
        return redirect('/dashboard')
    return render_template('newticket.html', form=form, user=user)