mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-21 15:32:14 +00:00
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:
18
RIGS/migrations/0050_event_forum_url.py
Normal file
18
RIGS/migrations/0050_event_forum_url.py
Normal 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),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -357,6 +357,8 @@ class Event(models.Model, RevisionMixin):
|
|||||||
auth_request_at = models.DateTimeField(null=True, blank=True)
|
auth_request_at = models.DateTimeField(null=True, blank=True)
|
||||||
auth_request_to = models.EmailField(blank=True, default='')
|
auth_request_to = models.EmailField(blank=True, default='')
|
||||||
|
|
||||||
|
forum_url = models.URLField(null=True, blank=True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def display_id(self):
|
def display_id(self):
|
||||||
if self.pk:
|
if self.pk:
|
||||||
|
|||||||
@@ -77,6 +77,15 @@
|
|||||||
<dt class="col-sm-6">PO</dt>
|
<dt class="col-sm-6">PO</dt>
|
||||||
<dd class="col-sm-6">{{ object.purchase_order }}</dd>
|
<dd class="col-sm-6">{{ object.purchase_order }}</dd>
|
||||||
{% endif %}
|
{% 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>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -110,6 +110,8 @@ urlpatterns = [
|
|||||||
path('event/<int:pk>/checkin/add/', login_required(views.EventCheckInOverride.as_view()),
|
path('event/<int:pk>/checkin/add/', login_required(views.EventCheckInOverride.as_view()),
|
||||||
name='event_checkin_override'),
|
name='event_checkin_override'),
|
||||||
|
|
||||||
|
path('event/<int:pk>/thread/', permission_required_with_403('RIGS.change_event')(views.CreateForumThread.as_view()), name='event_thread'),
|
||||||
|
|
||||||
# Finance
|
# Finance
|
||||||
path('invoice/', permission_required_with_403('RIGS.view_invoice')(views.InvoiceIndex.as_view()),
|
path('invoice/', permission_required_with_403('RIGS.view_invoice')(views.InvoiceIndex.as_view()),
|
||||||
name='invoice_list'),
|
name='invoice_list'),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import datetime
|
|||||||
import re
|
import re
|
||||||
import premailer
|
import premailer
|
||||||
import simplejson
|
import simplejson
|
||||||
|
import urllib
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
@@ -377,3 +378,20 @@ class EventAuthoriseRequestEmailPreview(generic.DetailView):
|
|||||||
context['to_name'] = self.request.GET.get('to_name', None)
|
context['to_name'] = self.request.GET.get('to_name', None)
|
||||||
context['target'] = 'event_authorise_form_preview'
|
context['target'] = 'event_authorise_form_preview'
|
||||||
return context
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user