def request_access_view(request, dataset_uuid): dataset = find_dataset_or_visualisation(dataset_uuid, request.user) if request.method == 'POST': form = RequestAccessForm(request.POST) if form.is_valid(): goal = form.cleaned_data['goal'] contact_email = form.cleaned_data['email'] user_edit_relative = reverse('admin:auth_user_change', args=[request.user.id]) user_url = request.build_absolute_uri(user_edit_relative) dataset_url = request.build_absolute_uri( dataset.get_absolute_url()) if (isinstance(dataset, VisualisationCatalogueItem) and dataset.visualisation_template): ticket_reference = _notify_visualisation_access_request( request, dataset, dataset_url, contact_email, goal) else: ticket_reference = create_zendesk_ticket( contact_email, request.user, goal, user_url, dataset.name, dataset_url, dataset.information_asset_owner, dataset.information_asset_manager, ) log_event( request.user, EventLog.TYPE_DATASET_ACCESS_REQUEST, dataset, extra={ 'contact_email': contact_email, 'goal': goal, 'ticket_reference': ticket_reference, }, ) url = reverse('datasets:request_access_success', args=[dataset_uuid]) return HttpResponseRedirect(f'{url}?ticket={ticket_reference}') return render( request, 'request_access.html', { 'dataset': dataset, 'authenticated_user': request.user, 'is_visualisation': isinstance(dataset, VisualisationCatalogueItem), }, )
def request_access_success_view(request, dataset_uuid): # yes this could cause 400 errors but Todo - replace with session / messages ticket = request.GET['ticket'] dataset = find_dataset_or_visualisation(dataset_uuid, request.user) return render(request, 'request_access_success.html', { 'ticket': ticket, 'dataset': dataset })
def eligibility_criteria_not_met_view(request, dataset_uuid): dataset = find_dataset_or_visualisation(dataset_uuid, request.user) return render( request, 'eligibility_criteria_not_met.html', { 'dataset': dataset, 'is_visualisation': isinstance(dataset, VisualisationCatalogueItem), }, )
def eligibility_criteria_view(request, dataset_uuid): dataset = find_dataset_or_visualisation(dataset_uuid, request.user) if request.method == 'POST': form = EligibilityCriteriaForm(request.POST) if form.is_valid(): if form.cleaned_data['meet_criteria']: return HttpResponseRedirect( reverse('datasets:request_access', args=[dataset_uuid])) else: return HttpResponseRedirect( reverse('datasets:eligibility_criteria_not_met', args=[dataset_uuid])) return render(request, 'eligibility_criteria.html', {'dataset': dataset})