Projet

Général

Profil

0001-general-add-pricing-url-attributes-to-events-37979.patch

Frédéric Péters, 23 décembre 2019 19:58

Télécharger (5,91 ko)

Voir les différences:

Subject: [PATCH] general: add pricing & url attributes to events (#37979)

 .../migrations/0036_auto_20191223_1758.py     | 25 +++++++++++++++++++
 chrono/agendas/models.py                      |  4 +++
 chrono/api/views.py                           |  2 ++
 .../chrono/manager_event_detail.html          |  8 ++++--
 tests/test_api.py                             |  6 ++++-
 tests/test_import_export.py                   |  6 ++++-
 6 files changed, 47 insertions(+), 4 deletions(-)
 create mode 100644 chrono/agendas/migrations/0036_auto_20191223_1758.py
chrono/agendas/migrations/0036_auto_20191223_1758.py
1
# -*- coding: utf-8 -*-
2
# Generated by Django 1.11.17 on 2019-12-23 17:58
3
from __future__ import unicode_literals
4

  
5
from django.db import migrations, models
6

  
7

  
8
class Migration(migrations.Migration):
9

  
10
    dependencies = [
11
        ('agendas', '0035_remove_desk_timeperiod_exceptions_remote_url'),
12
    ]
13

  
14
    operations = [
15
        migrations.AddField(
16
            model_name='event',
17
            name='pricing',
18
            field=models.CharField(blank=True, max_length=150, null=True, verbose_name='Pricing'),
19
        ),
20
        migrations.AddField(
21
            model_name='event',
22
            name='url',
23
            field=models.CharField(blank=True, max_length=200, null=True, verbose_name='URL'),
24
        ),
25
    ]
chrono/agendas/models.py
312 312
    description = models.TextField(
313 313
        _('Description'), null=True, blank=True, help_text=_('Optional event description.')
314 314
    )
315
    pricing = models.CharField(_('Pricing'), max_length=150, null=True, blank=True)
316
    url = models.CharField(_('URL'), max_length=200, null=True, blank=True)
315 317
    full = models.BooleanField(default=False)
316 318
    meeting_type = models.ForeignKey(MeetingType, null=True, on_delete=models.CASCADE)
317 319
    desk = models.ForeignKey('Desk', null=True, on_delete=models.CASCADE)
......
392 394
            'label': self.label,
393 395
            'slug': self.slug,
394 396
            'description': self.description,
397
            'url': self.url,
398
            'pricing': self.pricing,
395 399
        }
396 400

  
397 401

  
chrono/api/views.py
229 229
                    'text': force_text(x),
230 230
                    'datetime': format_response_datetime(x.start_datetime),
231 231
                    'description': x.description,
232
                    'pricing': x.pricing,
233
                    'url': x.url,
232 234
                    'disabled': bool(x.full),
233 235
                    'api': {
234 236
                        'fillslot_url': request.build_absolute_uri(
chrono/manager/templates/chrono/manager_event_detail.html
24 24

  
25 25
{% block content %}
26 26

  
27
{% if object.description %}
27
{% if object.description or object.pricing or object.url %}
28 28
<div class="section">
29
<div><p>{{ object.description }}</p></div>
29
<div>
30
 {% if object.description %}<p>{{ object.description }}</p>{% endif %}
31
 {% if object.pricing %}<p>{% trans "Pricing:" %} {{ object.pricing }}</p>{% endif %}
32
 {% if object.url %}<p><a href="{{ object.url }}">{{ object.url|truncatechars:100 }}</a>{% endif %}
33
</div>
30 34
</div>
31 35
{% endif %}
32 36

  
tests/test_api.py
1
# -*- coding: utf-8 -*-
2

  
1 3
import datetime
2 4
import urllib.parse as urlparse
3 5
import pytest
......
227 229
    check_bookability(resp.json['data'])
228 230
    assert resp.json['data'][0]['description'] is None
229 231

  
230
    # add description to events
232
    # add description, URL and pricing to events
231 233
    for i, event in enumerate(agenda.event_set.all()):
232 234
        event.description = 'Description %s' % i
235
        event.url = 'https://www.example.net/%s' % i
236
        event.pricing = '%s €' % i
233 237
        event.save()
234 238
    resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug)
235 239
    assert resp.json['data'][0]['description']
tests/test_import_export.py
116 116
    shutil.rmtree(tempdir)
117 117

  
118 118

  
119
def test_import_export_event_description(app, some_data, meetings_agenda):
119
def test_import_export_event_details(app, some_data, meetings_agenda):
120 120
    first_event = Agenda.objects.get(label='Foo bar').event_set.first()
121 121
    first_event.description = 'description'
122
    first_event.pricing = '100'
123
    first_event.url = 'https://example.net/'
122 124
    first_event.save()
123 125

  
124 126
    output = get_output_of_command('export_site')
......
133 135
    assert Agenda.objects.count() == 3
134 136
    first_imported_event = Agenda.objects.get(label='Foo bar').event_set.first()
135 137
    assert first_imported_event.description == 'description'
138
    assert first_imported_event.pricing == '100'
139
    assert first_imported_event.url == 'https://example.net/'
136 140

  
137 141

  
138 142
def test_import_export_permissions(app, some_data, meetings_agenda):
139
-