0001-misc-add-a-description-field-to-events-36169.patch
chrono/agendas/migrations/0027_event_description.py | ||
---|---|---|
1 |
# -*- coding: utf-8 -*- |
|
2 |
# Generated by Django 1.11.12 on 2019-09-17 06:36 |
|
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', '0026_booking_user_display_label'), |
|
12 |
] |
|
13 | ||
14 |
operations = [ |
|
15 |
migrations.AddField( |
|
16 |
model_name='event', |
|
17 |
name='description', |
|
18 |
field=models.TextField(blank=True, help_text='Optional event description.', null=True, verbose_name='Description'), |
|
19 |
), |
|
20 |
] |
chrono/agendas/models.py | ||
---|---|---|
289 | 289 |
_('Places in waiting list'), default=0) |
290 | 290 |
label = models.CharField(_('Label'), max_length=150, null=True, blank=True, |
291 | 291 |
help_text=_('Optional label to identify this date.')) |
292 |
description = models.TextField(_('Description'), null=True, blank=True, |
|
293 |
help_text=_('Optional event description.')) |
|
292 | 294 |
full = models.BooleanField(default=False) |
293 | 295 |
meeting_type = models.ForeignKey(MeetingType, null=True) |
294 | 296 |
desk = models.ForeignKey('Desk', null=True) |
chrono/api/views.py | ||
---|---|---|
187 | 187 |
response = {'data': [{'id': x.id, |
188 | 188 |
'text': force_text(x), |
189 | 189 |
'datetime': format_response_datetime(x.start_datetime), |
190 |
'description': x.description, |
|
190 | 191 |
'disabled': bool(x.full), |
191 | 192 |
'api': { |
192 | 193 |
'fillslot_url': request.build_absolute_uri( |
tests/test_api.py | ||
---|---|---|
189 | 189 |
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug) |
190 | 190 |
assert len(resp.json['data']) == 2 |
191 | 191 |
check_bookability(resp.json['data']) |
192 |
assert resp.json['data'][0]['description'] is None |
|
193 | ||
194 |
# add description to events |
|
195 |
for i, event in enumerate(agenda.event_set.all()): |
|
196 |
event.description = 'Description %s' % i |
|
197 |
event.save() |
|
198 |
resp = app.get('/api/agenda/%s/datetimes/' % agenda.slug) |
|
199 |
assert resp.json['data'][0]['description'] |
|
192 | 200 | |
193 | 201 |
def test_datetimes_api_wrong_kind(app, some_data): |
194 | 202 |
agenda = Agenda.objects.filter(label=u'Foo bar')[0] |
tests/test_manager.py | ||
---|---|---|
336 | 336 |
assert resp_datetimes.json['data'][0]['text'] == 'Feb. 15, %s, 5 p.m.' % year |
337 | 337 |
assert resp_datetimes.json['data'][0]['datetime'] == '%s-02-15 17:00:00' % year |
338 | 338 | |
339 |
# add with a description |
|
340 |
resp = app.get('/manage/agendas/%s/settings' % agenda.id, status=200) |
|
341 |
resp = resp.click('New Event') |
|
342 |
resp.form['start_datetime'] = '%s-02-15 18:00' % year |
|
343 |
resp.form['places'] = 11 |
|
344 |
resp.form['description'] = 'A description' |
|
345 |
resp = resp.form.submit() |
|
346 |
resp = resp.follow() |
|
347 |
event = Event.objects.get(places=11) |
|
348 |
assert event.description == 'A description' |
|
349 | ||
350 | ||
339 | 351 |
def test_add_event_on_missing_agenda(app, admin_user): |
340 | 352 |
app = login(app) |
341 | 353 |
app.get('/manage/agendas/%s/add-event' % '999', status=404) |
342 |
- |