From 2a3a3af675e5f6d13b5d53b7b5fd80b6de3baf64 Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Sun, 18 Nov 2018 19:01:53 +0100 Subject: [PATCH] Add htmlicon field to all sessions This makes it possible to store a HTML icon for the session, such as a coffee mug or similar, in the record instead of having ugly if-this-then-that chains in the template comparing the name of the session. --- docs/confreg/schedule.md | 5 +++++ postgresqleu/confreg/backendforms.py | 2 +- .../confreg/migrations/0036_htmlicon.py | 20 +++++++++++++++++++ postgresqleu/confreg/models.py | 1 + postgresqleu/confreg/views.py | 2 +- 5 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 postgresqleu/confreg/migrations/0036_htmlicon.py diff --git a/docs/confreg/schedule.md b/docs/confreg/schedule.md index f923158..0ce7ba1 100644 --- a/docs/confreg/schedule.md +++ b/docs/confreg/schedule.md @@ -122,6 +122,11 @@ Speakers profile before it can be used here, but it the same speaker profile can be used across multiple conferences. +HTML Icon +: HTML code to be inserted into schedule (and possibly other places) +representing this session. Can be used to include icons like coffee +mugs for coffee breaks etc. Should be pure HTML. + Status : The [state](callforpapers#states) state of this session. diff --git a/postgresqleu/confreg/backendforms.py b/postgresqleu/confreg/backendforms.py index ce78369..19f14e9 100644 --- a/postgresqleu/confreg/backendforms.py +++ b/postgresqleu/confreg/backendforms.py @@ -455,7 +455,7 @@ class BackendConferenceSessionForm(BackendForm): class Meta: model = ConferenceSession - fields = ['title', 'speaker', 'status', 'starttime', 'endtime', 'cross_schedule', + fields = ['title', 'htmlicon', 'speaker', 'status', 'starttime', 'endtime', 'cross_schedule', 'track', 'room', 'can_feedback', 'skill_level', 'abstract', 'submissionnote'] def fix_fields(self): diff --git a/postgresqleu/confreg/migrations/0036_htmlicon.py b/postgresqleu/confreg/migrations/0036_htmlicon.py new file mode 100644 index 0000000..21d8908 --- /dev/null +++ b/postgresqleu/confreg/migrations/0036_htmlicon.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.10 on 2018-11-18 18:48 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('confreg', '0035_confseries_administrators'), + ] + + operations = [ + migrations.AddField( + model_name='conferencesession', + name='htmlicon', + field=models.CharField(blank=True, help_text=b'HTML representing an icon used for this session on the schedule (and optionally elsewhere)', max_length=100, verbose_name=b'HTML Icon'), + ), + ] diff --git a/postgresqleu/confreg/models.py b/postgresqleu/confreg/models.py index a86bb3e..8bbc59f 100644 --- a/postgresqleu/confreg/models.py +++ b/postgresqleu/confreg/models.py @@ -671,6 +671,7 @@ class ConferenceSession(models.Model): can_feedback = models.BooleanField(null=False, default=True) abstract = models.TextField(null=False, blank=True) skill_level = models.IntegerField(null=False, default=1, choices=SKILL_CHOICES) + htmlicon = models.CharField(max_length=100, null=False, blank=True, verbose_name="HTML Icon", help_text="HTML representing an icon used for this session on the schedule (and optionally elsewhere)") status = models.IntegerField(null=False, default=0, choices=STATUS_CHOICES) lastnotifiedstatus = models.IntegerField(null=False, default=0, choices=STATUS_CHOICES) lastnotifiedtime = models.DateTimeField(null=True, blank=True, verbose_name="Notification last sent") diff --git a/postgresqleu/confreg/views.py b/postgresqleu/confreg/views.py index 4f88b85..d4678f2 100644 --- a/postgresqleu/confreg/views.py +++ b/postgresqleu/confreg/views.py @@ -1011,7 +1011,7 @@ def _scheduledata(request, conference): 'confid': conference.id, }) - raw = exec_to_grouped_dict("SELECT s.starttime::date AS day, s.id, s.starttime, s.endtime, to_json(t.*) AS track, s.track_id, to_json(r.*) AS room, s.room_id, s.title, to_char(starttime, 'HH24:MI') || ' - ' || to_char(endtime, 'HH24:MI') AS timeslot, extract(epoch FROM endtime-starttime)/60 AS length, min(starttime) OVER days AS firsttime, max(endtime) OVER days AS lasttime, cross_schedule, EXISTS (SELECT 1 FROM confreg_conferencesessionslides sl WHERE sl.session_id=s.id) AS has_slides, COALESCE(json_agg(json_build_object('id', spk.id, 'name', spk.fullname, 'company', spk.company, 'twittername', spk.twittername)) FILTER (WHERE spk.id IS NOT NULL), '[]') AS speakers FROM confreg_conferencesession s LEFT JOIN confreg_track t ON t.id=s.track_id LEFT JOIN confreg_room r ON r.id=s.room_id LEFT JOIN confreg_conferencesession_speaker css ON css.conferencesession_id=s.id LEFT JOIN confreg_speaker spk ON spk.id=css.speaker_id WHERE s.conference_id=%(confid)s AND s.status=1 AND (cross_schedule OR room_id IS NOT NULL) GROUP BY s.id, t.id, r.id WINDOW days AS (PARTITION BY s.starttime::date) ORDER BY day, s.starttime, r.sortkey", { + raw = exec_to_grouped_dict("SELECT s.starttime::date AS day, s.id, s.starttime, s.endtime, to_json(t.*) AS track, s.track_id, to_json(r.*) AS room, s.room_id, s.title, s.htmlicon, to_char(starttime, 'HH24:MI') || ' - ' || to_char(endtime, 'HH24:MI') AS timeslot, extract(epoch FROM endtime-starttime)/60 AS length, min(starttime) OVER days AS firsttime, max(endtime) OVER days AS lasttime, cross_schedule, EXISTS (SELECT 1 FROM confreg_conferencesessionslides sl WHERE sl.session_id=s.id) AS has_slides, COALESCE(json_agg(json_build_object('id', spk.id, 'name', spk.fullname, 'company', spk.company, 'twittername', spk.twittername)) FILTER (WHERE spk.id IS NOT NULL), '[]') AS speakers FROM confreg_conferencesession s LEFT JOIN confreg_track t ON t.id=s.track_id LEFT JOIN confreg_room r ON r.id=s.room_id LEFT JOIN confreg_conferencesession_speaker css ON css.conferencesession_id=s.id LEFT JOIN confreg_speaker spk ON spk.id=css.speaker_id WHERE s.conference_id=%(confid)s AND s.status=1 AND (cross_schedule OR room_id IS NOT NULL) GROUP BY s.id, t.id, r.id WINDOW days AS (PARTITION BY s.starttime::date) ORDER BY day, s.starttime, r.sortkey", { 'confid': conference.id, }) -- 2.39.5