Merge pull request #2034 from alphagov/zendesk

send zendesk rather than deskpro tickets
This commit is contained in:
Leo Hemsted
2018-04-27 14:33:31 +01:00
committed by GitHub
42 changed files with 129 additions and 187 deletions

View File

@@ -25,7 +25,7 @@ from functools import partial
from notifications_python_client.errors import HTTPError
from notifications_utils import logging, request_helper, formatters
from notifications_utils.clients import DeskproClient
from notifications_utils.clients.zendesk.zendesk_client import ZendeskClient
from notifications_utils.clients.statsd.statsd_client import StatsdClient
from notifications_utils.recipients import (
validate_phone_number,
@@ -78,7 +78,7 @@ organisations_client = OrganisationsClient()
org_invite_api_client = OrgInviteApiClient()
asset_fingerprinter = AssetFingerprinter()
statsd_client = StatsdClient()
deskpro_client = DeskproClient()
zendesk_client = ZendeskClient()
letter_jobs_client = LetterJobsClient()
inbound_number_client = InboundNumberClient()
billing_api_client = BillingAPIClient()
@@ -99,7 +99,7 @@ def create_app(application):
init_app(application)
statsd_client.init_app(application)
deskpro_client.init_app(application)
zendesk_client.init_app(application)
logging.init_app(application, statsd_client)
csrf.init_app(application)
request_helper.init_app(application)

View File

@@ -12,8 +12,7 @@ class Config(object):
API_HOST_NAME = os.environ.get('API_HOST_NAME')
SECRET_KEY = os.environ.get('SECRET_KEY')
DANGEROUS_SALT = os.environ.get('DANGEROUS_SALT')
DESKPRO_API_HOST = os.environ.get('DESKPRO_API_HOST')
DESKPRO_API_KEY = os.environ.get('DESKPRO_API_KEY')
ZENDESK_API_KEY = os.environ.get('ZENDESK_API_KEY')
# if we're not on cloudfoundry, we can get to this app from localhost. but on cloudfoundry its different
ADMIN_BASE_URL = os.environ.get('ADMIN_BASE_URL', 'http://localhost:6012')
@@ -28,9 +27,6 @@ class Config(object):
DEBUG = False
NOTIFY_LOG_PATH = os.getenv('NOTIFY_LOG_PATH')
DESKPRO_DEPT_ID = 5
DESKPRO_ASSIGNED_AGENT_TEAM_ID = 5
ADMIN_CLIENT_USER_NAME = 'notify-admin'
ASSETS_DEBUG = False
AWS_REGION = 'eu-west-1'
@@ -60,7 +56,6 @@ class Config(object):
WTF_CSRF_ENABLED = True
WTF_CSRF_TIME_LIMIT = None
CSV_UPLOAD_BUCKET_NAME = 'local-notifications-csv-upload'
DESKPRO_PERSON_EMAIL = 'donotreply@notifications.service.gov.uk'
ACTIVITY_STATS_LIMIT_DAYS = 7
TEST_MESSAGE_FILENAME = 'Report'
@@ -92,8 +87,7 @@ class Development(Config):
API_HOST_NAME = 'http://localhost:6011'
DANGEROUS_SALT = 'dev-notify-salt'
SECRET_KEY = 'dev-notify-secret-key'
DESKPRO_API_HOST = "some-host"
DESKPRO_API_KEY = "some-key"
ZENDESK_API_KEY = "some-key"
class Test(Development):

View File

@@ -3,13 +3,12 @@ from datetime import datetime
import pytz
from flask import abort, redirect, render_template, request, session, url_for
from flask_login import current_user
from notifications_utils.clients import DeskproError
from app import (
convert_to_boolean,
current_service,
deskpro_client,
service_api_client,
zendesk_client,
)
from app.main import main
from app.main.forms import Feedback, Problem, SupportType, Triage
@@ -33,11 +32,6 @@ def get_prefilled_message():
)
@main.route('/feedback', methods=['GET'])
def old_feedback():
return redirect(url_for('.support'))
@main.route('/support', methods=['GET', 'POST'])
def support():
form = SupportType()
@@ -64,21 +58,6 @@ def triage():
)
@main.route('/support/submit/<ticket_type>')
def old_submit_feedback(ticket_type):
try:
ticket_type = {
'problem': PROBLEM_TICKET_TYPE,
'question': QUESTION_TICKET_TYPE,
}[ticket_type]
return redirect(url_for(
'.feedback',
ticket_type=ticket_type,
), 301)
except KeyError:
abort(404)
@main.route('/support/<ticket_type>', methods=['GET', 'POST'])
def feedback(ticket_type):
try:
@@ -97,10 +76,16 @@ def feedback(ticket_type):
else:
severe = None
urgent = (
in_business_hours() or
(ticket_type == PROBLEM_TICKET_TYPE and severe)
)
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
@@ -136,17 +121,14 @@ def feedback(ticket_type):
form.feedback.data
)
try:
deskpro_client.create_ticket(
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 DeskproError:
abort(500, "Feedback submission failed")
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:

View File

@@ -10,19 +10,19 @@ from flask import (
)
from flask_login import current_user, login_required
from notifications_python_client.errors import HTTPError
from notifications_utils.clients import DeskproError
from notifications_utils.clients.zendesk.zendesk_client import ZendeskError
from notifications_utils.field import Field
from notifications_utils.formatters import formatted_list
from app import (
billing_api_client,
current_service,
deskpro_client,
email_branding_client,
inbound_number_client,
organisations_client,
service_api_client,
user_api_client,
zendesk_client,
)
from app.main import main
from app.main.forms import (
@@ -191,7 +191,7 @@ def submit_request_to_go_live(service_id):
if form.validate_on_submit():
try:
deskpro_client.create_ticket(
zendesk_client.create_ticket(
subject='Request to go live - {}'.format(current_service['name']),
message=(
'On behalf of {} ({})\n'
@@ -223,7 +223,7 @@ def submit_request_to_go_live(service_id):
user_email=current_user.email_address,
user_name=current_user.name
)
except DeskproError:
except ZendeskError:
abort(500, "Request to go live submission failed")
flash('Thanks for your request to go live. Well get back to you within one working day.', 'default')

View File

@@ -336,7 +336,7 @@
{% endif %}
<li class="bottom-gutter">
<a href="{{ url_for('.service_switch_email_auth', service_id=current_service.id) }}" class="button">
{{ 'Stop editing user auth' if 'email_auth' in current_service.permissions else 'Allow editing user auth' }}
{{ 'Stop user auth type editing' if 'email_auth' in current_service.permissions else 'Allow user auth type editing' }}
</a>
</li>
{% if current_service.active %}