def ticket_create(): # defalut category based on last submit (get from session) # using session, as information about last created ticket can be sensitive # in future it can be stored in extened user model instead last_category = session.get('ticket_create_last_category') form = CreateTicketForm(category=last_category) if form.validate_on_submit(): new_ticket = FlicketTicketExt.create_ticket( title=form.title.data, user=g.user, content=form.content.data, category=form.category.data, priority=form.priority.data, files=request.files.getlist("file")) flash(gettext('New Ticket created.'), category='success') session['ticket_create_last_category'] = form.category.data return redirect( url_for('flicket_bp.ticket_view', ticket_id=new_ticket.id)) title = gettext('Create Ticket') return render_template('flicket_create.html', title=title, form=form)
def ticket_create(): # default domain based on last submit (get from session) # using session, as information about last created ticket can be sensitive # in future it can be stored in extended user model instead last_domain = session.get("ticket_create_last_domain") form = CreateTicketForm(domain=last_domain) if form.validate_on_submit(): new_ticket = FlicketTicketExt.create_ticket( title=form.title.data, user=g.user, content=form.content.data, requester=form.requester.data, referee=form.referee.data, requester_role=form.requester_role.data, request_stage=1, procedure_stage=form.procedure_stage.data, domain=form.domain.data, institute=form.institute.data, days=form.days.data, files=request.files.getlist("file"), ) flash(gettext("New Ticket created."), category="success") session["ticket_create_last_domain"] = form.domain.data return redirect(url_for("flicket_bp.ticket_view", ticket_id=new_ticket.id)) title = gettext("Create Ticket") return render_template("flicket_create.html", title=title, form=form)
def ticket_create(): form = CreateTicketForm() if form.validate_on_submit(): # this is a new post so ticket status is 'open' ticket_status = FlicketStatus.query.filter_by(status='open').first() ticket_priority = FlicketPriority.query.filter_by( id=int(form.priority.data)).first() ticket_category = FlicketCategory.query.filter_by( id=int(form.category.data)).first() files = request.files.getlist("file") upload_attachments = UploadAttachment(files) if upload_attachments.are_attachements(): upload_attachments.upload_files() # submit ticket data to database new_ticket = FlicketTicket(title=form.title.data, date_added=datetime.datetime.now(), user=g.user, current_status=ticket_status, content=form.content.data, ticket_priority=ticket_priority, category=ticket_category) db.session.add(new_ticket) # add attachments to the dataabase. upload_attachments.populate_db(new_ticket) # subscribe user to ticket subscribe = FlicketSubscription(user=g.user, ticket=new_ticket) db.session.add(subscribe) # commit changes to the database db.session.commit() # send email # TEST SEND EMAIL HERE f_mail = FlicketMail() f_mail.create_ticket(ticket=new_ticket) flash('New Ticket created.', category='success') return redirect( url_for('flicket_bp.ticket_view', ticket_id=new_ticket.id)) return render_template('flicket_create.html', title='Flicket - Create Ticket', form=form)
def ticket_create(): form = CreateTicketForm() if form.validate_on_submit(): new_ticket = FlicketTicketExt.create_ticket(title=form.title.data, user=g.user, content=form.content.data, category=form.category.data, priority=form.priority.data, files=request.files.getlist("file")) flash(gettext('New Ticket created.'), category='success') return redirect(url_for('flicket_bp.ticket_view', ticket_id=new_ticket.id)) title = gettext('Flicket - Create Ticket') return render_template('flicket_create.html', title=title, form=form)