diff --git a/chrono/agendas/migrations/0036_auto_20191223_1758.py b/chrono/agendas/migrations/0036_auto_20191223_1758.py new file mode 100644 index 00000000..00a67177 --- /dev/null +++ b/chrono/agendas/migrations/0036_auto_20191223_1758.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.17 on 2019-12-23 17:58 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('agendas', '0035_remove_desk_timeperiod_exceptions_remote_url'), + ] + + operations = [ + migrations.AddField( + model_name='event', + name='pricing', + field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Pricing'), + ), + migrations.AddField( + model_name='event', + name='url', + field=models.CharField(blank=True, max_length=200, null=True, verbose_name='URL'), + ), + ] diff --git a/chrono/agendas/models.py b/chrono/agendas/models.py index 2b745556..e4e85007 100644 --- a/chrono/agendas/models.py +++ b/chrono/agendas/models.py @@ -312,6 +312,8 @@ class Event(models.Model): description = models.TextField( _('Description'), null=True, blank=True, help_text=_('Optional event description.') ) + pricing = models.CharField(_('Pricing'), max_length=150, null=True, blank=True) + url = models.CharField(_('URL'), max_length=200, null=True, blank=True) full = models.BooleanField(default=False) meeting_type = models.ForeignKey(MeetingType, null=True, on_delete=models.CASCADE) desk = models.ForeignKey('Desk', null=True, on_delete=models.CASCADE) @@ -392,6 +394,8 @@ class Event(models.Model): 'label': self.label, 'slug': self.slug, 'description': self.description, + 'url': self.url, + 'pricing': self.pricing, } diff --git a/chrono/api/views.py b/chrono/api/views.py index c05bb710..2eaec494 100644 --- a/chrono/api/views.py +++ b/chrono/api/views.py @@ -229,6 +229,8 @@ class Datetimes(APIView): 'text': force_text(x), 'datetime': format_response_datetime(x.start_datetime), 'description': x.description, + 'pricing': x.pricing, + 'url': x.url, 'disabled': bool(x.full), 'api': { 'fillslot_url': request.build_absolute_uri( diff --git a/chrono/manager/templates/chrono/manager_event_detail.html b/chrono/manager/templates/chrono/manager_event_detail.html index f533e8a3..b45a0fb9 100644 --- a/chrono/manager/templates/chrono/manager_event_detail.html +++ b/chrono/manager/templates/chrono/manager_event_detail.html @@ -24,9 +24,13 @@ {% block content %} -{% if object.description %} +{% if object.description or object.pricing or object.url %}
-

{{ object.description }}

+
+ {% if object.description %}

{{ object.description }}

{% endif %} + {% if object.pricing %}

{% trans "Pricing:" %} {{ object.pricing }}

{% endif %} + {% if object.url %}

{{ object.url|truncatechars:100 }}{% endif %} +

{% endif %} diff --git a/tests/test_api.py b/tests/test_api.py index 4c2540e9..05389356 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- + import datetime import urllib.parse as urlparse import pytest @@ -227,9 +229,11 @@ def test_datetimes_api(app, some_data): check_bookability(resp.json['data']) assert resp.json['data'][0]['description'] is None - # add description to events + # add description, URL and pricing to events for i, event in enumerate(agenda.event_set.all()): event.description = 'Description %s' % i + event.url = 'https://www.example.net/%s' % i + event.pricing = '%s €' % i event.save() resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug) assert resp.json['data'][0]['description'] diff --git a/tests/test_import_export.py b/tests/test_import_export.py index f49c6720..f2c95c70 100644 --- a/tests/test_import_export.py +++ b/tests/test_import_export.py @@ -116,9 +116,11 @@ def test_import_export(app, some_data, meetings_agenda): shutil.rmtree(tempdir) -def test_import_export_event_description(app, some_data, meetings_agenda): +def test_import_export_event_details(app, some_data, meetings_agenda): first_event = Agenda.objects.get(label='Foo bar').event_set.first() first_event.description = 'description' + first_event.pricing = '100' + first_event.url = 'https://example.net/' first_event.save() output = get_output_of_command('export_site') @@ -133,6 +135,8 @@ def test_import_export_event_description(app, some_data, meetings_agenda): assert Agenda.objects.count() == 3 first_imported_event = Agenda.objects.get(label='Foo bar').event_set.first() assert first_imported_event.description == 'description' + assert first_imported_event.pricing == '100' + assert first_imported_event.url == 'https://example.net/' def test_import_export_permissions(app, some_data, meetings_agenda):