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

@@ -0,0 +1,18 @@
# Generated by Django 3.2.18 on 2023-06-26 17:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('RIGS', '0049_auto_20230529_1123'),
]
operations = [
migrations.AddField(
model_name='event',
name='forum_url',
field=models.URLField(blank=True, null=True),
),
]

View File

@@ -357,6 +357,8 @@ class Event(models.Model, RevisionMixin):
auth_request_at = models.DateTimeField(null=True, blank=True)
auth_request_to = models.EmailField(blank=True, default='')
forum_url = models.URLField(null=True, blank=True)
@property
def display_id(self):
if self.pk:

View File

@@ -77,6 +77,15 @@
<dt class="col-sm-6">PO</dt>
<dd class="col-sm-6">{{ object.purchase_order }}</dd>
{% endif %}
<dt class="col-6">Forum Thread</dt>
{% if event.forum_thread %}
<dd class="col-6"><a href="{{event.forum_thread}}">{{event.forum_thread}}</a></dd>
{% else %}
<a href="{% url 'event_thread' event.pk %}" class="btn btn-primary" title="Create Forum Thread"><span
class="fas fa-plus"></span> <span
class="hidden-xs">Create Forum Thread</span></a>
{% endif %}
</dl>
</div>
</div>

View File

@@ -110,6 +110,8 @@ urlpatterns = [
path('event/<int:pk>/checkin/add/', login_required(views.EventCheckInOverride.as_view()),
name='event_checkin_override'),
path('event/<int:pk>/thread/', permission_required_with_403('RIGS.change_event')(views.CreateForumThread.as_view()), name='event_thread'),
# Finance
path('invoice/', permission_required_with_403('RIGS.view_invoice')(views.InvoiceIndex.as_view()),
name='invoice_list'),

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)