Skip to content

Commit

Permalink
[schedule] Be more tolerant about submitted availabilities
Browse files Browse the repository at this point in the history
The previous version produced issues when organisers changed the event
timeframe and availabilities were re-submitted afterwards. Closes #579
  • Loading branch information
rixx committed Feb 22, 2019
1 parent 1b112d4 commit 01e68d3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
1 change: 1 addition & 0 deletions doc/changelog.rst
Expand Up @@ -3,6 +3,7 @@
Release Notes
=============

- :bug:`579` When organisers changed the event timeframe, already submitted availabilites would have to be changed upon new submission.
- :feature:`577` You can now decide if text lengths should be counted in words or in characters when restricting how long they should be.
- :bug:`587` pretalx did not automtically update a talk's duration when it was changed via the submission type or directly. It was only changed when you moved the talk in the schedule editor.
- :bug:`594` pretalx did not display speaker availabilities during submission, even when they were required, breaking submission workflows.
Expand Down
30 changes: 14 additions & 16 deletions src/pretalx/schedule/forms.py
Expand Up @@ -100,23 +100,21 @@ def _validate_availability(self, rawavail):

tz = pytz.timezone(self.event.timezone)

try:
timeframe_start = tz.localize(
datetime.datetime.combine(self.event.date_from, datetime.time())
)
assert rawavail['start'] >= timeframe_start
timeframe_start = tz.localize(
datetime.datetime.combine(self.event.date_from, datetime.time())
)
if rawavail['start'] < timeframe_start:
rawavail['start'] = timeframe_start

# add 1 day, not 24 hours, https://stackoverflow.com/a/25427822/2486196
timeframe_end = datetime.datetime.combine(
self.event.date_to, datetime.time()
)
timeframe_end = timeframe_end + datetime.timedelta(days=1)
timeframe_end = tz.localize(timeframe_end, is_dst=None)
assert rawavail['end'] <= timeframe_end
except AssertionError:
raise forms.ValidationError(
_("The submitted availability is not within the event timeframe.")
)
# add 1 day, not 24 hours, https://stackoverflow.com/a/25427822/2486196
timeframe_end = datetime.datetime.combine(
self.event.date_to, datetime.time()
)
timeframe_end = timeframe_end + datetime.timedelta(days=1)
timeframe_end = tz.localize(timeframe_end, is_dst=None)
if rawavail['end'] > timeframe_end:
# If the submitted availability ended outside the event timeframe, fix it silently
rawavail['end'] = timeframe_end

def clean_availabilities(self):
data = self.cleaned_data.get('availabilities')
Expand Down

0 comments on commit 01e68d3

Please sign in to comment.