diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index 393bbbb5..6a40a352 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -233,3 +233,5 @@ USE_GRAVATAR = True TERMS_OF_HIRE_URL = "http://www.nottinghamtec.co.uk/terms.pdf" AUTHORISATION_NOTIFICATION_ADDRESS = 'productions@nottinghamtec.co.uk' +RISK_ASSESSMENT_URL = os.environ.get('RISK_ASSESSMENT_URL') if os.environ.get( + 'RISK_ASSESSMENT_URL') else "http://example.com" diff --git a/RIGS/rigboard.py b/RIGS/rigboard.py index 82bb29dc..a6b3ef80 100644 --- a/RIGS/rigboard.py +++ b/RIGS/rigboard.py @@ -80,6 +80,20 @@ class EventEmbed(EventDetail): template_name = 'RIGS/event_embed.html' +class EventRA(generic.base.RedirectView): + permanent = False + def get_redirect_url(self, *args, **kwargs): + event = get_object_or_404(models.Event, pk=kwargs['pk']) + params = { + 'entry.708610078': f'N{event.pk:05}', + 'entry.905899507': event.name, + 'entry.139491562': event.venue.name if event.venue else '', + 'entry.1689826056': event.start_date.strftime('%Y-%m-%d') + ((' ' + event.end_date.strftime('%Y-%m-%d')) if event.end_date else ''), + 'entry.902421165': event.mic.name if event.mic else '' + } + return settings.RISK_ASSESSMENT_URL + "?" + urllib.parse.urlencode(params) + + class EventCreate(generic.CreateView): model = models.Event form_class = forms.EventForm diff --git a/RIGS/templates/RIGS/event_detail_buttons.html b/RIGS/templates/RIGS/event_detail_buttons.html index 878684cc..3d2f06af 100644 --- a/RIGS/templates/RIGS/event_detail_buttons.html +++ b/RIGS/templates/RIGS/event_detail_buttons.html @@ -2,6 +2,9 @@ + {% if event.is_rig %} \d+)/print/$', permission_required_with_403('RIGS.view_event')(rigboard.EventPrint.as_view()), name='event_print'), + url(r'^event/(?P\d+)/ra/$', + permission_required_with_403('RIGS.change_event')(rigboard.EventRA.as_view()), + name='event_ra'), url(r'^event/create/$', permission_required_with_403('RIGS.add_event')(rigboard.EventCreate.as_view()), name='event_create'),