Add button for creating forum thread draft from event detail

TODO: Allow RIGS to ingest POST requests sent from the forum on new posts in RIG info to link up the forum thread

RE https://forum.nottinghamtec.co.uk/t/rigs-discourse-integration/15592/21
This commit is contained in:
2023-06-26 18:48:26 +01:00
parent d03a4e115f
commit 76cd5459fc
5 changed files with 49 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ import datetime
import re
import premailer
import simplejson
import urllib
from django.conf import settings
from django.contrib import messages
@@ -377,3 +378,20 @@ class EventAuthoriseRequestEmailPreview(generic.DetailView):
context['to_name'] = self.request.GET.get('to_name', None)
context['target'] = 'event_authorise_form_preview'
return context
class CreateForumThread(generic.base.RedirectView):
permanent = False
def get_redirect_url(self, *args, **kwargs):
event = get_object_or_404(models.Event, pk=kwargs['pk'])
if event.forum_url:
return event.forum_url
params = {
'title': str(event),
'body': 'https://rigs.nottinghamtec.co.uk/event/{}'.format(event.pk),
'category': 'rig-info'
}
return 'https://forum.nottinghamtec.co.uk/new-topic' + "?" + urllib.parse.urlencode(params)