def submit_request_to_go_live(service_id): zendesk_client.create_ticket( subject='Request to go live - {}'.format(current_service.name), message=( 'Service: {service_name}\n' '{service_dashboard}\n' '\n---' '\nOrganisation type: {organisation_type}' '\nAgreement signed: {agreement}' '\n' '\nEmails in next year: {volume_email_formatted}' '\nText messages in next year: {volume_sms_formatted}' '\nLetters in next year: {volume_letter_formatted}' '\n' '\nConsent to research: {research_consent}' '\nOther live services: {existing_live}' '\n' '\nService reply-to address: {email_reply_to}' '\n' '\n---' '\nRequest sent by {email_address}' '\n').format( service_name=current_service.name, service_dashboard=url_for('main.service_dashboard', service_id=current_service.id, _external=True), organisation_type=str( current_service.organisation_type).title(), agreement=current_service.organisation. as_agreement_statement_for_go_live_request( current_user.email_domain), volume_email_formatted=format_thousands( current_service.volume_email), volume_sms_formatted=format_thousands( current_service.volume_sms), volume_letter_formatted=format_thousands( current_service.volume_letter), research_consent='Yes' if current_service.consent_to_research else 'No', existing_live='Yes' if current_user.live_services else 'No', email_address=current_user.email_address, email_reply_to=current_service.default_email_reply_to_address or 'not set', ), ticket_type=zendesk_client.TYPE_QUESTION, user_email=current_user.email_address, user_name=current_user.name, tags=current_service.request_to_go_live_tags, ) current_service.update(go_live_user=current_user.id) flash( 'Thanks for your request to go live. We’ll get back to you within one working day.', 'default') return redirect(url_for('.service_settings', service_id=service_id))
def branding_request(service_id, branding_type): form = BrandingOptions(current_service, branding_type=branding_type) from_template = request.args.get('from_template') if branding_type == "email": branding_name = current_service.email_branding_name elif branding_type == "letter": branding_name = current_service.letter_branding_name if form.validate_on_submit(): zendesk_client.create_ticket( subject='{} branding request - {}'.format( branding_type.capitalize(), current_service.name), message=('Organisation: {organisation}\n' 'Service: {service_name}\n' '{dashboard_url}\n' '\n---' '\nCurrent branding: {current_branding}' '\nBranding requested: {branding_requested}' '{new_paragraph}' '{detail}' '\n').format(organisation=current_service.organisation. as_info_for_branding_request( current_user.email_domain), service_name=current_service.name, dashboard_url=url_for( 'main.service_dashboard', service_id=current_service.id, _external=True), current_branding=branding_name, branding_requested=dict( form.options.choices)[form.options.data], new_paragraph='\n\n' if form.something_else.data else '', detail=form.something_else.data or ''), ticket_type=zendesk_client.TYPE_QUESTION, user_email=current_user.email_address, user_name=current_user.name, tags=['notify_action', 'notify_branding'], ) flash(('Thanks for your branding request. We’ll get back to you ' 'within one working day.'), 'default') return redirect( url_for('.view_template', service_id=current_service.id, template_id=from_template) if from_template else url_for( '.service_settings', service_id=current_service.id)) return render_template( 'views/service-settings/branding/branding-options.html', form=form, branding_type=branding_type, branding_name=branding_name, from_template=from_template)
def branding_request(service_id): branding_type = 'govuk' if current_service.email_branding: branding_type = current_service.email_branding['brand_type'] form = BrandingOptionsEmail(options=branding_type) if form.validate_on_submit(): zendesk_client.create_ticket( subject='Email branding request - {}'.format(current_service.name), message=('Organisation: {organisation}\n' 'Service: {service_name}\n' '{dashboard_url}\n' '\n---' '\nCurrent branding: {current_branding}' '\nBranding requested: {branding_requested}').format( organisation=current_service.organisation. as_info_for_branding_request( current_user.email_domain), service_name=current_service.name, dashboard_url=url_for('main.service_dashboard', service_id=current_service.id, _external=True), current_branding=current_service.email_branding_name, branding_requested=branding_options_dict[ form.options.data], ), ticket_type=zendesk_client.TYPE_QUESTION, user_email=current_user.email_address, user_name=current_user.name, tags=['notify_action_add_branding'], ) flash(('Thanks for your branding request. We’ll get back to you ' 'within one working day.'), 'default') return redirect(url_for('.service_settings', service_id=service_id)) return render_template( 'views/service-settings/branding/email-options.html', form=form, )
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), )
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, )
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, )