def _notify_visualisation_access_request(request, dataset, dataset_url, contact_email, goal): message = f""" An access request has been sent to the data visualisation owner and secondary contact to process. There is no need to action this ticket until a further notification is received. Data visualisation: {dataset.name} ({dataset_url}) Requestor {request.user.email} People finder link: {get_people_url(request.user.get_full_name())} Requestor’s response to why access is needed: {goal} Data visualisation owner: {dataset.enquiries_contact.email} Secondary contact: {dataset.secondary_enquiries_contact.email} If access has not been granted to the requestor within 5 working days, this will trigger an update to this Zendesk ticket to resolve the request. """ ticket_reference = create_support_request( request.user, request.user.email, message, subject=f"Data visualisation access request received - {dataset.name}", tag='visualisation-access-request', ) give_access_url = request.build_absolute_uri( reverse( "visualisations:users-give-access", args=[dataset.visualisation_template.gitlab_project_id], )) give_access_token = generate_token({ 'email': request.user.email, 'ticket': ticket_reference }).decode('utf-8') for contact in set([ dataset.enquiries_contact.email, dataset.secondary_enquiries_contact.email ]): send_email( settings.NOTIFY_VISUALISATION_ACCESS_REQUEST_TEMPLATE_ID, contact, personalisation={ "visualisation_name": dataset.name, "visualisation_url": dataset_url, "user_email": contact_email, "goal": goal, "people_url": get_people_url(request.user.get_full_name()), "give_access_url": f"{give_access_url}?token={give_access_token}", }, ) return ticket_reference
def post(self, request, *args, **kwargs): obj = self.get_object() if obj.status != DataRequestStatus.draft: return HttpResponseRedirect( reverse('request-data:confirmation-page', kwargs={"pk": obj.pk})) # If they've hacked the URL, some required fields might be blank. try: obj.clean_fields(exclude=['zendesk_ticket_id']) except ValidationError: return HttpResponseBadRequest() zendesk_message = f""" A request for a new dataset on Data Workspace has been submitted. Here are the details: # Request details ## Who they are in relation to the request {obj.get_requester_role_display()} ## (Alternative) name of IAO/IAM {obj.name_of_owner_or_manager or '[not provided]'} ## Description of the data {obj.data_description or '[not provided]'} ## Purpose of the data {obj.data_purpose or '[not provided]'} ## Location of the data {obj.data_location or '[not provided]'} ## Security classification {obj.get_security_classification_display() or '[not provided]'} # Personal details ## Full name {obj.requester.get_full_name()} ## Email address {obj.requester.email} """ ticket_id = create_support_request( obj.requester, obj.requester.email, zendesk_message, tag='request-for-data', subject="Request for new dataset on Data Workspace", ) obj.status = DataRequestStatus.submitted obj.zendesk_ticket_id = ticket_id obj.save() return HttpResponseRedirect( reverse('request-data:confirmation-page', kwargs={"pk": obj.pk}))
def form_valid(self, form): cleaned = form.cleaned_data tag = self.ZENDESK_TAGS.get(self.request.GET.get('tag')) ticket_id = create_support_request(self.request.user, cleaned['email'], cleaned['message'], tag=tag) return HttpResponseRedirect( reverse('support-success', kwargs={'ticket_id': ticket_id}))
def form_valid(self, form): cleaned = form.cleaned_data message = ( f'What were you trying to do?\n{cleaned["what_were_you_doing"]}\n\n' f'What happened?\n{cleaned["what_happened"]}\n\n' f'What should have happened?\n{cleaned["what_should_have_happened"]}' ) ticket_id = create_support_request(self.request.user, cleaned["email"], message) return HttpResponseRedirect( reverse("support-success", kwargs={"ticket_id": ticket_id}))
def form_valid(self, form): cleaned = form.cleaned_data ticket_id = create_support_request( self.request.user, cleaned['email'], cleaned['message'], attachments=[ cleaned[x] for x in ['attachment1', 'attachment2', 'attachment3'] if cleaned[x] is not None ], ) return HttpResponseRedirect( reverse('support-success', kwargs={'ticket_id': ticket_id}))
def form_valid(self, form): cleaned = form.cleaned_data if cleaned["support_type"] == form.SupportTypes.NEW_DATASET: return HttpResponseRedirect(reverse("request_data:index")) if cleaned["support_type"] == form.SupportTypes.TECH_SUPPORT: return HttpResponseRedirect( f'{reverse("technical-support")}?email={cleaned["email"]}') tag = self.ZENDESK_TAGS.get(self.request.GET.get("tag")) ticket_id = create_support_request(self.request.user, cleaned["email"], cleaned["message"], tag=tag) return HttpResponseRedirect( reverse("support-success", kwargs={"ticket_id": ticket_id}))
def form_valid(self, form): cleaned = form.cleaned_data ticket_id = create_support_request(self.request.user, cleaned['email'], cleaned['message']) return HttpResponseRedirect( reverse('support-success', kwargs={'ticket_id': ticket_id}))