mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
"Create forum post" button on a rig page (#551)
* 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 * Mockup webhook recieving view * Correct method of CRSF exemption for webhook reciever * Use f-strings correctly, not like a big dumb * That was also dumb, fix that too * Second shot at webhook reciever * Oops * >.< * Third shot * Try again at signing * What if I gave it the right arguments. That might be a good start. * More fiddling with auth * Add debug print * Okay, put that back where it was because I inavertently overloaded my import Flashbacks to my java days... * Different header access method * Fix import, again * Fix ommited json parsing wotsit * Fix url * Fix string index * Correct template logic * Allow manual adding/editing of URLs * Filter by right flavour of event * Amend event str conversion for consistency * Oops * Make migration Will be squashed later * Fix logic when creating events * Squash migration * Implement codedoctor suggestion
This commit is contained in:
@@ -308,6 +308,14 @@ class EventManager(models.Manager):
|
||||
return qs
|
||||
|
||||
|
||||
def validate_forum_url(value):
|
||||
if not value:
|
||||
return # Required error is done the field
|
||||
obj = urlparse(value)
|
||||
if obj.hostname not in ('forum.nottinghamtec.co.uk'):
|
||||
raise ValidationError('URL must point to a location on the TEC Forum')
|
||||
|
||||
|
||||
@reversion.register(follow=['items'])
|
||||
class Event(models.Model, RevisionMixin):
|
||||
# Done to make it much nicer on the database
|
||||
@@ -357,6 +365,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(default='', blank=True, validators=[validate_forum_url])
|
||||
|
||||
@property
|
||||
def display_id(self):
|
||||
if self.pk:
|
||||
@@ -505,7 +515,7 @@ class Event(models.Model, RevisionMixin):
|
||||
return reverse('event_detail', kwargs={'pk': self.pk})
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.display_id}: {self.name}"
|
||||
return f"{self.display_id} | {self.name}"
|
||||
|
||||
def clean(self):
|
||||
errdict = {}
|
||||
|
||||
Reference in New Issue
Block a user