Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit fe4ad23

Browse files
committed
Merge pull request #403 from gandalfar/patch-sentry-645
Fixes crash when deleting one of the dates when editing event
2 parents 652ea4f + 4b99424 commit fe4ad23

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

web/forms/event_form.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def clean(self):
144144
start_date = cleaned_data.get('start_date')
145145
end_date = cleaned_data.get('end_date')
146146

147-
if end_date < start_date:
147+
if start_date and end_date and end_date < start_date:
148148
msg = u'End date should be greater than start date.'
149149
self._errors['end_date'] = self.error_class([msg])
150150

@@ -153,7 +153,6 @@ def clean(self):
153153
def __init__(self, *args, **kwargs):
154154
super(AddEventForm, self).__init__(*args, **kwargs)
155155

156-
157156
class SearchEventForm(forms.Form):
158157

159158
countries._countries.append(Event.CUSTOM_COUNTRY_ENTRIES[0])

web/tests/test_event_views.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,34 @@ def test_edit_event_with_image(admin_user, admin_client, db):
228228
assert 'event_picture/ercchy' not in response.content
229229

230230

231+
@pytest.mark.django_db
232+
def test_edit_event_without_end_date(db, admin_user, admin_client):
233+
event = EventFactory.create(creator=admin_user)
234+
235+
event_data = {
236+
'audience': [6, 7],
237+
'theme': [3,4],
238+
'contact_person': u'[email protected]',
239+
'country': u'SI',
240+
'description': u'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\r\ntempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,\r\nquis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo\r\nconsequat. Duis aute irure dolor in reprehenderit in voluptate velit esse\r\ncillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non\r\nproident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
241+
'event_url': u'',
242+
'location': u'Ljubljana, Slovenia',
243+
'organizer': u'Mozilla Slovenija',
244+
'picture': '',
245+
'start_date': datetime.datetime.now(),
246+
'end_date': '',
247+
'tags': [u'css', u'html', u'web'],
248+
'title': u'Webmaker Ljubljana',
249+
'user_email': u'[email protected]'
250+
}
251+
252+
response_edited = admin_client.post(reverse('web.edit_event', args=[event.id]), event_data)
253+
254+
assert response_edited.status_code == 200
255+
assert 'end_date' in response_edited.context['form'].errors
256+
257+
event.delete()
258+
231259
@pytest.mark.django_db
232260
def test_scoreboard_links_and_results(admin_user, db, client):
233261

0 commit comments

Comments
 (0)