Exemplo n.º 1
0
def thanks():
    return render_template(
        'views/support/thanks.html',
        urgent=convert_to_boolean(request.args.get('urgent')),
        anonymous=convert_to_boolean(request.args.get('anonymous')),
        logged_in=current_user.is_authenticated,
    )
Exemplo n.º 2
0
def thanks():
    return render_template(
        'views/support/thanks.html',
        out_of_hours_emergency=convert_to_boolean(
            request.args.get('out_of_hours_emergency')),
        email_address_provided=convert_to_boolean(
            request.args.get('email_address_provided')),
        out_of_hours=not in_business_hours(),
    )
Exemplo n.º 3
0
def email_template():
    return HTMLEmail(
        govuk_banner=convert_to_boolean(request.args.get('govuk_banner', True))
    )(
        'Lorem Ipsum is simply dummy text of the printing and typesetting '
        'industry.\n\nLorem Ipsum has been the industry’s standard dummy '
        'text ever since the 1500s, when an unknown printer took a galley '
        'of type and scrambled it to make a type specimen book. '
        '\n\n'
        '# History'
        '\n\n'
        'It has '
        'survived not only'
        '\n'
        '*five centuries'
        '\n'
        '* but also the leap into electronic typesetting'
        '\n\n'
        'It was '
        'popularised in the 1960s with the release of Letraset sheets '
        'containing Lorem Ipsum passages, and more recently with desktop '
        'publishing software like Aldus PageMaker including versions of '
        'Lorem Ipsum.'
        '\n\n'
        '^ It is a long established fact that a reader will be distracted '
        'by the readable content of a page when looking at its layout.'
        '\n\n'
        'The point of using Lorem Ipsum is that it has a more-or-less '
        'normal distribution of letters, as opposed to using ‘Content '
        'here, content here’, making it look like readable English.'
        '\n\n\n'
        'This is an example of an email sent using GOV.UK Notify.'
    )
Exemplo n.º 4
0
def email_template():
    return str(
        HTMLEmailTemplate(
            {
                'subject':
                'foo',
                'content':
                ('Lorem Ipsum is simply dummy text of the printing and typesetting '
                 'industry.\n\nLorem Ipsum has been the industry’s standard dummy '
                 'text ever since the 1500s, when an unknown printer took a galley '
                 'of type and scrambled it to make a type specimen book. '
                 '\n\n'
                 '# History'
                 '\n\n'
                 'It has '
                 'survived not only'
                 '\n\n'
                 '* five centuries'
                 '\n'
                 '* but also the leap into electronic typesetting'
                 '\n\n'
                 'It was '
                 'popularised in the 1960s with the release of Letraset sheets '
                 'containing Lorem Ipsum passages, and more recently with desktop '
                 'publishing software like Aldus PageMaker including versions of '
                 'Lorem Ipsum.'
                 '\n\n'
                 '^ It is a long established fact that a reader will be distracted '
                 'by the readable content of a page when looking at its layout.'
                 '\n\n'
                 'The point of using Lorem Ipsum is that it has a more-or-less '
                 'normal distribution of letters, as opposed to using ‘Content '
                 'here, content here’, making it look like readable English.'
                 '\n\n\n'
                 '1. One'
                 '\n'
                 '2. Two'
                 '\n'
                 '10. Three'
                 '\n\n'
                 'This is an example of an email sent using GOV.UK Notify.'
                 '\n\n'
                 'https://www.notifications.service.gov.uk')
            },
            govuk_banner=convert_to_boolean(
                request.args.get('govuk_banner', True))))
Exemplo n.º 5
0
def feedback(ticket_type):
    form = FeedbackOrProblem()

    if not form.feedback.data:
        form.feedback.data = session.pop('feedback_message', '')

    if request.args.get('severe') in ['yes', 'no']:
        severe = convert_to_boolean(request.args.get('severe'))
    else:
        severe = None

    out_of_hours_emergency = all((
        ticket_type != QUESTION_TICKET_TYPE,
        not in_business_hours(),
        severe,
    ))

    if needs_triage(ticket_type, severe):
        session['feedback_message'] = form.feedback.data
        return redirect(url_for('.triage', ticket_type=ticket_type))

    if needs_escalation(ticket_type, severe):
        return redirect(url_for('.bat_phone'))

    if current_user.is_authenticated:
        form.email_address.data = current_user.email_address
        form.name.data = current_user.name

    if form.validate_on_submit():
        user_email = form.email_address.data
        user_name = form.name.data or None
        if current_service:
            service_string = 'Service: "{name}"\n{url}\n'.format(
                name=current_service.name,
                url=url_for('main.service_dashboard',
                            service_id=current_service.id,
                            _external=True))
        else:
            service_string = ''

        feedback_msg = '{}\n{}'.format(
            form.feedback.data,
            service_string,
        )

        zendesk_client.create_ticket(subject='Notify feedback',
                                     message=feedback_msg,
                                     ticket_type=ticket_type,
                                     p1=out_of_hours_emergency,
                                     user_email=user_email,
                                     user_name=user_name)
        return redirect(
            url_for(
                '.thanks',
                out_of_hours_emergency=out_of_hours_emergency,
                email_address_provided=(current_user.is_authenticated
                                        or bool(form.email_address.data)),
            ))

    return render_template(
        'views/support/form.html',
        form=form,
        back_link=(url_for('.support') if severe is None else url_for(
            '.triage', ticket_type=ticket_type)),
        show_status_page_banner=(ticket_type == PROBLEM_TICKET_TYPE),
        page_title={
            GENERAL_TICKET_TYPE: 'Contact GOV.UK Notify support',
            PROBLEM_TICKET_TYPE: 'Report a problem',
            QUESTION_TICKET_TYPE: 'Ask a question or give feedback',
        }.get(ticket_type),
    )
Exemplo n.º 6
0
def feedback(ticket_type):
    try:
        form = {
            QUESTION_TICKET_TYPE: Feedback,
            PROBLEM_TICKET_TYPE: Problem,
        }[ticket_type]()
    except KeyError:
        abort(404)

    if not form.feedback.data:
        form.feedback.data = session.pop('feedback_message', '')

    if request.args.get('severe') in ['yes', 'no']:
        severe = convert_to_boolean(request.args.get('severe'))
    else:
        severe = None

    urgent = (in_business_hours()
              or (ticket_type == PROBLEM_TICKET_TYPE and severe))

    anonymous = ((not form.email_address.data)
                 and (not current_user.is_authenticated))

    if needs_triage(ticket_type, severe):
        session['feedback_message'] = form.feedback.data
        return redirect(url_for('.triage'))

    if needs_escalation(ticket_type, severe):
        return redirect(url_for('.bat_phone'))

    if current_user.is_authenticated:
        form.email_address.data = current_user.email_address
        form.name.data = current_user.name

    if form.validate_on_submit():
        user_email = form.email_address.data
        user_name = form.name.data or None
        if current_service:
            service_string = 'Service "{name}": {url}\n'.format(
                name=current_service['name'],
                url=url_for('main.service_dashboard',
                            service_id=current_service['id'],
                            _external=True))
        else:
            service_string = ''

        feedback_msg = 'Environment: {}\n{}{}\n{}'.format(
            url_for('main.index', _external=True), service_string,
            '' if user_email else '{} (no email address supplied)'.format(
                form.name.data), form.feedback.data)
        data = {
            'person_email':
            user_email or current_app.config.get('DESKPRO_PERSON_EMAIL'),
            'person_name':
            user_name,
            'department_id':
            current_app.config.get('DESKPRO_DEPT_ID'),
            'agent_team_id':
            current_app.config.get('DESKPRO_ASSIGNED_AGENT_TEAM_ID'),
            'subject':
            'Notify feedback {}'.format(user_name),
            'message':
            feedback_msg,
            'label':
            ticket_type,
            'urgency':
            10 if urgent else 1,
        }
        headers = {
            "X-DeskPRO-API-Key": current_app.config.get('DESKPRO_API_KEY'),
            'Content-Type': "application/x-www-form-urlencoded"
        }
        resp = requests.post(current_app.config.get('DESKPRO_API_HOST') +
                             '/api/tickets',
                             data=data,
                             headers=headers)
        if resp.status_code != 201:
            current_app.logger.error(
                "Deskpro create ticket request failed with {} '{}'".format(
                    resp.status_code, resp.json()))
            abort(500, "Feedback submission failed")
        return redirect(url_for('.thanks', urgent=urgent, anonymous=anonymous))

    return render_template(
        'views/support/{}.html'.format(ticket_type),
        form=form,
        ticket_type=ticket_type,
    )
Exemplo n.º 7
0
def feedback(ticket_type):
    try:
        form = {
            QUESTION_TICKET_TYPE: Feedback,
            PROBLEM_TICKET_TYPE: Problem,
        }[ticket_type]()
    except KeyError:
        abort(404)

    if not form.feedback.data:
        form.feedback.data = session.pop('feedback_message', '')

    if request.args.get('severe') in ['yes', 'no']:
        severe = convert_to_boolean(request.args.get('severe'))
    else:
        severe = None

    urgent = (in_business_hours()
              or (ticket_type == PROBLEM_TICKET_TYPE and severe))

    anonymous = ((not form.email_address.data)
                 and (not current_user.is_authenticated))

    if needs_triage(ticket_type, severe):
        session['feedback_message'] = form.feedback.data
        return redirect(url_for('.triage'))

    if needs_escalation(ticket_type, severe):
        return redirect(url_for('.bat_phone'))

    if current_user.is_authenticated:
        form.email_address.data = current_user.email_address
        form.name.data = current_user.name

    if form.validate_on_submit():
        user_email = form.email_address.data
        user_name = form.name.data or None
        if current_service:
            service_string = 'Service "{name}": {url}\n'.format(
                name=current_service['name'],
                url=url_for('main.service_dashboard',
                            service_id=current_service['id'],
                            _external=True))
        else:
            service_string = ''

        feedback_msg = 'Environment: {}\n{}{}\n{}'.format(
            url_for('main.index', _external=True), service_string,
            '' if user_email else '{} (no email address supplied)'.format(
                form.name.data), form.feedback.data)

        try:
            support_api_client.post_support_ticket(
                dict(subject='Notify feedback {}'.format(user_name),
                     message=feedback_msg,
                     ticket_type=ticket_type,
                     urgency=10 if urgent else 1,
                     user_email=user_email,
                     user_name=user_name))
        except HTTPError:
            abort(500, "Support submission failed")
        return redirect(url_for('.thanks', urgent=urgent, anonymous=anonymous))

    if not form.feedback.data:
        form.feedback.data = get_prefilled_message()

    return render_template(
        'views/support/{}.html'.format(ticket_type),
        form=form,
        ticket_type=ticket_type,
    )
Exemplo n.º 8
0
def feedback(ticket_type):
    try:
        form = {
            QUESTION_TICKET_TYPE: Feedback,
            PROBLEM_TICKET_TYPE: Problem,
        }[ticket_type]()
    except KeyError:
        abort(404)

    if not form.feedback.data:
        form.feedback.data = session.pop('feedback_message', '')

    if request.args.get('severe') in ['yes', 'no']:
        severe = convert_to_boolean(request.args.get('severe'))
    else:
        severe = None

    p1 = False
    urgent = False

    if in_business_hours():
        # if we're in the office, it's urgent (aka we'll get back in 30 mins)
        urgent = True
    elif ticket_type == PROBLEM_TICKET_TYPE and severe:
        # out of hours, it's only a p1 and it's only urgent if it's a p1
        urgent = True
        p1 = True

    anonymous = (
        (not form.email_address.data) and
        (not current_user.is_authenticated)
    )

    if needs_triage(ticket_type, severe):
        session['feedback_message'] = form.feedback.data
        return redirect(url_for('.triage'))

    if needs_escalation(ticket_type, severe):
        return redirect(url_for('.bat_phone'))

    if current_user.is_authenticated:
        form.email_address.data = current_user.email_address
        form.name.data = current_user.name

    if form.validate_on_submit():
        user_email = form.email_address.data
        user_name = form.name.data or None
        if current_service:
            service_string = 'Service: "{name}"\n{url}\n'.format(
                name=current_service['name'],
                url=url_for('main.service_dashboard', service_id=current_service['id'], _external=True)
            )
        else:
            service_string = ''

        feedback_msg = '{}\n{}{}'.format(
            form.feedback.data,
            service_string,
            '' if user_email else '{} (no email address supplied)'.format(form.name.data)
        )

        zendesk_client.create_ticket(
            subject='Notify feedback',
            message=feedback_msg,
            ticket_type=ticket_type,
            p1=p1,
            user_email=user_email,
            user_name=user_name
        )
        return redirect(url_for('.thanks', urgent=urgent, anonymous=anonymous))

    if not form.feedback.data:
        form.feedback.data = get_prefilled_message()

    return render_template(
        'views/support/{}.html'.format(ticket_type),
        form=form,
        ticket_type=ticket_type,
    )
Exemplo n.º 9
0
def feedback(ticket_type):
    try:
        form = {
            QUESTION_TICKET_TYPE: Feedback,
            PROBLEM_TICKET_TYPE: Problem,
        }[ticket_type]()
    except KeyError:
        abort(404)

    if not form.feedback.data:
        form.feedback.data = session.pop('feedback_message', '')

    if request.args.get('severe') in ['yes', 'no']:
        severe = convert_to_boolean(request.args.get('severe'))
    else:
        severe = None

    out_of_hours_emergency = all((
        ticket_type == PROBLEM_TICKET_TYPE,
        not in_business_hours(),
        severe,
    ))

    if needs_triage(ticket_type, severe):
        session['feedback_message'] = form.feedback.data
        return redirect(url_for('.triage'))

    if needs_escalation(ticket_type, severe):
        return redirect(url_for('.bat_phone'))

    if current_user.is_authenticated:
        form.email_address.data = current_user.email_address
        form.name.data = current_user.name

    if form.validate_on_submit():
        user_email = form.email_address.data
        user_name = form.name.data or None
        if current_service:
            service_string = 'Service: "{name}"\n{url}\n'.format(
                name=current_service.name,
                url=url_for('main.service_dashboard',
                            service_id=current_service.id,
                            _external=True))
        else:
            service_string = ''

        feedback_msg = '{}\n{}{}'.format(
            form.feedback.data, service_string, '' if user_email else
            '{} (no email address supplied)'.format(form.name.data))

        zendesk_client.create_ticket(subject='Notify feedback',
                                     message=feedback_msg,
                                     ticket_type=ticket_type,
                                     p1=out_of_hours_emergency,
                                     user_email=user_email,
                                     user_name=user_name)
        return redirect(
            url_for(
                '.thanks',
                out_of_hours_emergency=out_of_hours_emergency,
                email_address_provided=(current_user.is_authenticated
                                        or bool(form.email_address.data)),
            ))

    if not form.feedback.data:
        form.feedback.data = get_prefilled_message()

    return render_template(
        'views/support/{}.html'.format(ticket_type),
        form=form,
        ticket_type=ticket_type,
    )