From e42e078dcccd343e644a4bda89eda4c20d6d7154 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 10 Jun 2018 13:44:16 +0000 Subject: [PATCH] use markdown for schedule too --- content/models.py | 6 +++++- content/templates/opt.html | 2 +- content/views.py | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/content/models.py b/content/models.py index 88428a5..7f7b89f 100644 --- a/content/models.py +++ b/content/models.py @@ -69,7 +69,7 @@ class Content(models.Model): header = MarkdownxField(blank=True, null=True, default='') body = MarkdownxField(blank=True, null=True, default='') teaser = models.TextField(blank=True, null=True, validators=[MaxLengthValidator(200)]) - schedule = models.TextField(blank=True, null=True) + schedule = MarkdownxField(blank=True, null=True, default='') schedulebutton = models.CharField(db_column='scheduleButton', max_length=255, blank=True, null=True) # Field name made lowercase. optbtn2 = models.CharField(db_column='optBtn2', max_length=127, blank=True, null=True) # Field name made lowercase. opttext2 = models.TextField(db_column='optText2', blank=True, null=True) # Field name made lowercase. @@ -119,6 +119,10 @@ class Content(models.Model): value = '' return mark_safe(value) + @property + def formatted_schedule(self): + return mark_safe(markdownify(self.schedule)) + @property def typefilter(self): return self.type diff --git a/content/templates/opt.html b/content/templates/opt.html index a5f545c..a0a4e8d 100644 --- a/content/templates/opt.html +++ b/content/templates/opt.html @@ -17,6 +17,6 @@ {% if content.schedule %}

{{content.schedulebutton|default:"Schedule"}}

-

{{ content.schedule|safe|linebreaks }}

+

{{ content.formatted_schedule }}

{% endif %} diff --git a/content/views.py b/content/views.py index f8a114d..c1498fb 100644 --- a/content/views.py +++ b/content/views.py @@ -247,7 +247,8 @@ def redirect_event(request): content = get_object_or_404(Content, shortname=shortname) return redirect(content.get_absolute_url()) id = request.GET.get('id') - id = re.compile('\d+').findall(id) + if id: + id = re.compile('\d+').findall(id) if id: id = id[0] content = get_object_or_404(Content, id=id)