From fd1ca9f5ecc9e8b5ccbc17a9a15747ed264cef71 Mon Sep 17 00:00:00 2001 From: Dan Clark Date: Fri, 9 Feb 2024 09:53:16 +0000 Subject: [PATCH] Add the location of each talk/task to various pages --- volunteers/admin.py | 6 +-- volunteers/forms.py | 1 + .../migrations/0009_auto_20240209_1048.py | 44 +++++++++++++++++++ volunteers/models.py | 5 +++ .../templates/volunteers/talk_detailed.html | 7 +++ .../templates/volunteers/task_detailed.html | 6 +++ .../templates/volunteers/task_schedule.html | 3 +- volunteers/templates/volunteers/tasks.html | 9 ++++ .../templates/volunteers/tasks_detailed.html | 4 +- 9 files changed, 80 insertions(+), 5 deletions(-) create mode 100644 volunteers/migrations/0009_auto_20240209_1048.py diff --git a/volunteers/admin.py b/volunteers/admin.py index 3d60f30..0ce3409 100644 --- a/volunteers/admin.py +++ b/volunteers/admin.py @@ -311,15 +311,15 @@ class VolunteerTaskAdmin(admin.ModelAdmin): class TaskAdmin(admin.ModelAdmin): fieldsets = [ (None, {'fields': ['edition', 'name', 'nbr_volunteers', 'nbr_volunteers_min', 'nbr_volunteers_max', 'date', - 'start_time', 'end_time']}), + 'start_time', 'end_time', 'location']}), (None, {'fields': ['talk', 'template']}), (None, {'fields': ['description', 'fosdem_url']}), ] # inlines = (VolunteerTaskInline,) list_display = ['link', 'edition', 'name', 'date', 'start_time', 'end_time', 'assigned_volunteers', - 'nbr_volunteers', 'nbr_volunteers_min', 'nbr_volunteers_max'] + 'nbr_volunteers', 'nbr_volunteers_min', 'nbr_volunteers_max', 'location'] list_editable = ['name', 'date', 'start_time', 'end_time', 'nbr_volunteers', 'nbr_volunteers_min', - 'nbr_volunteers_max'] + 'nbr_volunteers_max', 'location'] list_filter = [EditionFilter, DayListFilter, 'template', 'talk__track'] actions = ['mass_mail_volunteer'] diff --git a/volunteers/forms.py b/volunteers/forms.py index 743d9b4..e9a3259 100644 --- a/volunteers/forms.py +++ b/volunteers/forms.py @@ -23,6 +23,7 @@ class EditTasksForm(forms.Form): start_time = forms.TimeField(label=_('Start time'), required=True) end_time = forms.TimeField(label=_('End time'), required=True) name = forms.CharField(label=_('Name'), max_length=30, required=True) + location = forms.CharField(label=_('Location'), max_length=30, required=True) description = forms.CharField(label=_('Description'), max_length=30, required=False, widget=forms.Textarea) fosdem_url = forms.CharField(label=_('Fosdem URL'), max_length=100, required=False, widget=forms.Textarea) diff --git a/volunteers/migrations/0009_auto_20240209_1048.py b/volunteers/migrations/0009_auto_20240209_1048.py new file mode 100644 index 0000000..0cd640c --- /dev/null +++ b/volunteers/migrations/0009_auto_20240209_1048.py @@ -0,0 +1,44 @@ +# Generated by Django 3.2 on 2024-02-09 09:48 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('volunteers', '0008_auto_20240207_1717'), + ] + + operations = [ + migrations.AddField( + model_name='talk', + name='location', + field=models.CharField(max_length=128, null=True), + ), + migrations.AddField( + model_name='task', + name='location', + field=models.CharField(max_length=30, null=True), + ), + migrations.AlterField( + model_name='task', + name='edition', + field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.PROTECT, to='volunteers.edition'), + ), + migrations.AlterField( + model_name='task', + name='fosdem_url', + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name='track', + name='edition', + field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.PROTECT, to='volunteers.edition'), + ), + migrations.AlterField( + model_name='volunteerstatus', + name='edition', + field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.PROTECT, to='volunteers.edition'), + ), + ] diff --git a/volunteers/models.py b/volunteers/models.py index 371a798..3e8eaa1 100644 --- a/volunteers/models.py +++ b/volunteers/models.py @@ -203,6 +203,7 @@ def __str__(self): speaker = models.CharField(max_length=128) description = models.TextField() fosdem_url = models.TextField(null=True) + location = models.CharField(max_length=128, null=True) date = models.DateField() start_time = models.TimeField() end_time = models.TimeField() @@ -240,6 +241,7 @@ def penta_create_or_update(cls, xml, edition, day_date): talk.title = xml.find('title').text talk.description = xml.find('description').text or '' talk.fosdem_url = xml.find('url').text + talk.location = xml.find('room').text talk.date = day_date (talk.start_time, talk.end_time) = (talk_start, talk_end) persons = xml.find('persons') @@ -348,6 +350,7 @@ def __str__(self): counter = models.CharField(max_length=2) description = models.TextField() fosdem_url = models.TextField(null=True, blank=True) + location = models.CharField(null=True, max_length=30) date = models.DateField() start_time = models.TimeField() end_time = models.TimeField() @@ -401,6 +404,7 @@ def create_or_update_from_talk(cls, edition, talk, task_type, volunteers): task.template = template task.name = '%s: %s' % (task_type, talk.title) task.fosdem_url = talk.fosdem_url + task.location = talk.location task.date = talk.date task.start_time = talk.start_time task.end_time = talk.end_time @@ -426,6 +430,7 @@ def create_from_xml(cls, xml, edition): task = cls(name=name, counter=counter, template=template, edition=edition) task.description = xml.find('description').text task.fosdem_url = xml.find('url').text + task.location = xml.find('location').text day_offset = int(xml.find('day').text) task.date = edition.start_date + datetime.timedelta(days=day_offset) task.start_time = parse_time(xml.find('start_time').text) diff --git a/volunteers/templates/volunteers/talk_detailed.html b/volunteers/templates/volunteers/talk_detailed.html index f5c1ab9..01c4990 100644 --- a/volunteers/templates/volunteers/talk_detailed.html +++ b/volunteers/templates/volunteers/talk_detailed.html @@ -13,6 +13,9 @@ {% trans 'When' %} {% trans 'Title' %} {% trans 'Attending' %} + {% if talk.location %} + {% trans 'Location' %} + {% endif %} {{ talk.date|date:"D" }}, {{ talk.start_time|time:"H:i" }} - {{ talk.end_time|time:"H:i" }} @@ -23,6 +26,10 @@ {{talk.title}} {% endif %} + {% if talk.location %} + {{talk.location}} + {% endif %} + {% for volunteer in talk.volunteers.all %} {{ volunteer.user.first_name }} {{ volunteer.user.last_name }}, {% endfor %} diff --git a/volunteers/templates/volunteers/task_detailed.html b/volunteers/templates/volunteers/task_detailed.html index fdec722..ef5f5ef 100644 --- a/volunteers/templates/volunteers/task_detailed.html +++ b/volunteers/templates/volunteers/task_detailed.html @@ -14,6 +14,9 @@ {% trans 'Title' %} {% trans 'Attending' %} {% trans 'Talk' %} + {% if task.location %} + {% trans 'Location' %} + {% endif %} {{ task.date|date:"D" }}, {{ task.start_time|time:"H:i" }} - {{ task.end_time|time:"H:i" }} @@ -32,6 +35,9 @@ {% else %} {{task.talk}} {% endif %} + {% if task.location %} + {{task.location}} + {% endif %}   diff --git a/volunteers/templates/volunteers/task_schedule.html b/volunteers/templates/volunteers/task_schedule.html index 4b61bc8..1aebccf 100644 --- a/volunteers/templates/volunteers/task_schedule.html +++ b/volunteers/templates/volunteers/task_schedule.html @@ -11,7 +11,8 @@ {% for task, volunteers in tasks.items %}

{{ task.name }} ({{task.assigned_volunteers}}/{{task.nbr_volunteers}})
- {{ task.date|date:"l" }}, {{ task.start_time|time:"H:i" }} - {{ task.end_time|time:"H:i" }} + {{ task.date|date:"l" }}, {{ task.start_time|time:"H:i" }} - {{ task.end_time|time:"H:i" }}
+ {{ task.location }}


diff --git a/volunteers/templates/volunteers/tasks.html b/volunteers/templates/volunteers/tasks.html index 2c79572..10e5b42 100644 --- a/volunteers/templates/volunteers/tasks.html +++ b/volunteers/templates/volunteers/tasks.html @@ -31,6 +31,7 @@ + @@ -40,6 +41,7 @@ + {% for task in task_set %} @@ -53,6 +55,7 @@ + {% endfor %} {% endfor %} @@ -83,6 +86,7 @@ + @@ -95,6 +99,7 @@ + {% endifchanged %} @@ -102,6 +107,7 @@ + {% for category, category_tasks in categories.items %} {% if category_tasks %} @@ -112,6 +118,7 @@ + {% endifchanged %} @@ -119,6 +126,7 @@ + {% for task in category_tasks %} @@ -136,6 +144,7 @@ + {% endfor %} {% endif %} diff --git a/volunteers/templates/volunteers/tasks_detailed.html b/volunteers/templates/volunteers/tasks_detailed.html index 2fb7367..67adba5 100644 --- a/volunteers/templates/volunteers/tasks_detailed.html +++ b/volunteers/templates/volunteers/tasks_detailed.html @@ -25,10 +25,11 @@
 
{% trans 'Task' %} {% trans 'When' %} {% trans 'Volunteers' %}{% trans 'Location' %}
Problematic tasks #{{ forloop.counter }}:     
{{ task.assigned_volunteers }}/{{ task.nbr_volunteers }}{{task.location}}
{% trans 'Task' %} {% trans 'When' %} {% trans 'Volunteers' %}{% trans 'Location' %}
      
      
      
{{ category.name }}     
{{ task.assigned_volunteers }}/{{ task.nbr_volunteers }}{{task.location}}
- + + @@ -42,6 +43,7 @@ {% if not forloop.last %},{% endif %} {% endfor %} + {% endfor %}
{% trans 'When' %}{% trans 'When' %} {% trans 'Title' %} {% trans 'Attending' %} {% trans 'Talk' %}{% trans 'Location' %}
{{ task.talk }}{{ task.location }}