general: add pricing & url attributes to events (#37979)
This commit is contained in:
parent
23f940e2ab
commit
61496b5cdf
|
@ -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'),
|
||||
),
|
||||
]
|
|
@ -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,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -24,9 +24,13 @@
|
|||
|
||||
{% block content %}
|
||||
|
||||
{% if object.description %}
|
||||
{% if object.description or object.pricing or object.url %}
|
||||
<div class="section">
|
||||
<div><p>{{ object.description }}</p></div>
|
||||
<div>
|
||||
{% if object.description %}<p>{{ object.description }}</p>{% endif %}
|
||||
{% if object.pricing %}<p>{% trans "Pricing:" %} {{ object.pricing }}</p>{% endif %}
|
||||
{% if object.url %}<p><a href="{{ object.url }}">{{ object.url|truncatechars:100 }}</a>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
|
|
@ -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']
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue