Ejemplo n.º 1
0
def issues_edit(id):
    issue = Issue.query.get(id)

    if request.method == 'GET' and issue and issue.status == 'unread':
        issue = Issue.unread_to_open(issue)

    form = IssueForm(obj=issue)

    subject = _('[Catwatch issue] Re: %(issue_type)s',
                issue_type=issue.LABEL[issue.label])

    # Shenanigans to comply with PEP-8's formatting style.
    body_string = '\n\nYou opened an issue regarding:'
    issue_string = '\n\n---\n{0}\n---\n\n'.format(issue.question)
    message = _('Hello,%(body)s:%(issue)s\n\nThanks,\nCatwatch support team',
                body=body_string, issue=issue_string)

    contact_form = IssueContactForm(email=issue.email,
                                    subject=subject, message=message)

    if form.validate_on_submit():
        form.populate_obj(issue)
        issue.save()

        flash(_('Issue has been saved successfully.'), 'success')
        return redirect(url_for('admin.issues'))

    return render_template('admin/issue/edit.jinja2', form=form,
                           contact_form=contact_form, issue=issue)
Ejemplo n.º 2
0
def issues_edit(id):
    issue = Issue.query.get(id)
    form = IssueForm(obj=issue)

    if form.validate_on_submit():
        form.populate_obj(issue)
        issue.save()

        flash(_('Issue has been saved successfully.'), 'success')
        return redirect(url_for('admin.issues'))

    return render_template('admin/issue/edit.jinja2', form=form, issue=issue)