agendas: use URLField for event url (#89447)
gitea/chrono/pipeline/head This commit looks good Details

This commit is contained in:
Thomas NOËL 2024-04-12 00:30:51 +02:00 committed by Thomas NOËL
parent 3403295d3d
commit 6ee8fbf78d
3 changed files with 20 additions and 12 deletions

View File

@ -17,6 +17,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='event',
name='url',
field=models.CharField(blank=True, max_length=200, null=True, verbose_name='URL'),
field=models.URLField(blank=True, null=True, verbose_name='URL'),
),
]

View File

@ -2234,7 +2234,7 @@ class Event(WithInspectMixin, models.Model):
_('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)
url = models.URLField(_('URL'), max_length=200, null=True, blank=True)
booked_places = models.PositiveSmallIntegerField(default=0)
booked_waiting_list_places = models.PositiveSmallIntegerField(default=0)
almost_full = models.BooleanField(default=False)

View File

@ -764,7 +764,7 @@ def test_export_events(app, admin_user):
resp = app.get('/manage/agendas/%s/import-events' % agenda.id)
resp.form['events_csv_file'] = Upload(
't.csv',
b'2016-09-16,23:30,10,5,label,slug,"description\nfoobar",pricing,url,2016-10-16 00:00,90',
b'2016-09-16,23:30,10,5,label,slug,"description\nfoobar",pricing,https://example.net/event,2016-10-16 00:00,90',
'text/csv',
)
resp.form.submit(status=302)
@ -774,7 +774,7 @@ def test_export_events(app, admin_user):
csv_export
== 'date,time,number of places,number of places in waiting list,label,identifier,description,pricing,URL,publication date/time,duration\r\n'
'2016-09-16,00:30,10,0,,foo-bar-event,,,,,\r\n'
'2016-09-16,23:30,10,5,label,slug,"description\nfoobar",pricing,url,2016-10-16 00:00,90\r\n'
'2016-09-16,23:30,10,5,label,slug,"description\nfoobar",pricing,https://example.net/event,2016-10-16 00:00,90\r\n'
)
@ -967,7 +967,7 @@ def test_import_events(app, admin_user):
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
resp.form['events_csv_file'] = Upload(
't.csv',
b'2016-09-16,18:00,10,5,label,slug,"description\nfoobar",pricing,url,2016-10-16,90',
b'2016-09-16,18:00,10,5,label,slug,"description\nfoobar",pricing,https://example.net/event,2016-10-16,90',
'text/csv',
)
resp = resp.form.submit(status=302)
@ -975,7 +975,7 @@ def test_import_events(app, admin_user):
event = Event.objects.get()
assert event.description == 'description\nfoobar'
assert event.pricing == 'pricing'
assert event.url == 'url'
assert event.url == 'https://example.net/event'
assert str(event.publication_datetime) == '2016-10-15 22:00:00+00:00'
assert str(event.publication_datetime.tzinfo) == 'UTC'
assert event.duration == 90
@ -983,7 +983,7 @@ def test_import_events(app, admin_user):
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
resp.form['events_csv_file'] = Upload(
't.csv',
b'2016-09-16,18:00,10,5,label,slug,"description\nfoobar",pricing,url,2016-10-16 10:00,90',
b'2016-09-16,18:00,10,5,label,slug,"description\nfoobar",pricing,https://example.net/event,2016-10-16 10:00,90',
'text/csv',
)
resp = resp.form.submit(status=302)
@ -991,7 +991,7 @@ def test_import_events(app, admin_user):
event = Event.objects.get()
assert event.description == 'description\nfoobar'
assert event.pricing == 'pricing'
assert event.url == 'url'
assert event.url == 'https://example.net/event'
assert str(event.publication_datetime) == '2016-10-16 08:00:00+00:00'
assert str(event.publication_datetime.tzinfo) == 'UTC'
assert event.duration == 90
@ -999,7 +999,9 @@ def test_import_events(app, admin_user):
# publication date/time bad format
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
resp.form['events_csv_file'] = Upload(
't.csv', b'2016-09-16,18:00,10,5,label,slug,description,pricing,url,foobar', 'text/csv'
't.csv',
b'2016-09-16,18:00,10,5,label,slug,description,pricing,https://example.net/event,foobar',
'text/csv',
)
resp = resp.form.submit(status=200)
assert 'Wrong publication date/time format. (1st event)' in resp.text
@ -1007,7 +1009,9 @@ def test_import_events(app, admin_user):
# duration bad format
resp = app.get('/manage/agendas/%s/import-events' % agenda.id, status=200)
resp.form['events_csv_file'] = Upload(
't.csv', b'2016-09-16,18:00,10,5,label,slug,description,pricing,url,2016-09-16,foobar', 'text/csv'
't.csv',
b'2016-09-16,18:00,10,5,label,slug,description,pricing,https://example.net/event,2016-09-16,foobar',
'text/csv',
)
resp = resp.form.submit(status=200)
assert 'Duration must be an integer. (1st event)' in resp.text
@ -1202,7 +1206,9 @@ def test_import_events_partial_bookings(app, admin_user):
# no end time
resp = app.get('/manage/agendas/%s/import-events' % agenda.pk)
resp.form['events_csv_file'] = Upload(
't.csv', b'2016-09-16,18:00,10,5,label,slug,description,pricing,url,2016-09-16', 'text/csv'
't.csv',
b'2016-09-16,18:00,10,5,label,slug,description,pricing,https://example.net/event,2016-09-16',
'text/csv',
)
resp = resp.form.submit(status=200)
assert 'Missing end_time.' in resp.text
@ -1210,7 +1216,9 @@ def test_import_events_partial_bookings(app, admin_user):
# invalid end time
resp = app.get('/manage/agendas/%s/import-events' % agenda.pk)
resp.form['events_csv_file'] = Upload(
't.csv', b'2016-09-16,18:00,10,5,label,slug,description,pricing,url,2016-09-16,xxx', 'text/csv'
't.csv',
b'2016-09-16,18:00,10,5,label,slug,description,pricing,https://example.net/event,2016-09-16,xxx',
'text/csv',
)
resp = resp.form.submit(status=200)
assert '“xxx” value has an invalid format' in resp.text