diff --git a/pod/meeting/forms.py b/pod/meeting/forms.py index 46189c1e38..cda9dd4a47 100644 --- a/pod/meeting/forms.py +++ b/pod/meeting/forms.py @@ -165,7 +165,9 @@ def get_rounded_time(): ( "main_fields", { - "legend": (' %s' % _("Main fields")), + "legend": ( + ' %s' % _("Main fields") + ), "fields": MEETING_MAIN_FIELDS, }, ), @@ -248,26 +250,30 @@ def clean_start_date(self): - the start date is before the recurrence deadline. - in the case of weekly recurrence, the start day must be selected from the list of weekdays. The function raise a validation error if a condition is not met.""" - if ("start" in self.cleaned_data.keys() + if ( + "start" in self.cleaned_data.keys() and "recurring_until" in self.cleaned_data.keys() and self.cleaned_data["recurring_until"] is not None - and ( - self.cleaned_data["start"] > self.cleaned_data["recurring_until"] - )): + and (self.cleaned_data["start"] > self.cleaned_data["recurring_until"]) + ): raise ValidationError(_("Start date must be less than recurring until date")) - if (self.cleaned_data.get("weekdays") + if ( + self.cleaned_data.get("weekdays") and self.cleaned_data.get("start") and self.cleaned_data.get("recurrence") == "weekly" and ( str(self.cleaned_data.get("start").weekday()) not in self.cleaned_data.get("weekdays") - )): + ) + ): raise ValidationError( - _("In case of weekly recurring, the day of the start date must be selected.") + _( + "In case of weekly recurring, the day of the start date must be selected." + ) ) - if not self.cleaned_data.get('recurring_until'): + if not self.cleaned_data.get("recurring_until"): self.instance.recurring_until = None def clean_add_owner(self): @@ -310,7 +316,10 @@ def clean(self): ): self.cleaned_data["is_restricted"] = True - if "start_time" in self.cleaned_data.keys() and "start" in self.cleaned_data.keys(): + if ( + "start_time" in self.cleaned_data.keys() + and "start" in self.cleaned_data.keys() + ): start_time = datetime.datetime.strptime( self.cleaned_data["start_time"], "%H:%M:%S" ).time() diff --git a/pod/meeting/models.py b/pod/meeting/models.py index 11c1b4f823..29c0dd7c34 100644 --- a/pod/meeting/models.py +++ b/pod/meeting/models.py @@ -150,8 +150,8 @@ class Meeting(models.Model): ) INTERVAL_CHOICES = ( - ('', '%s' % _("Choose repeat frequency")), - ('-- %s --' % _("Frequency"), INTERVAL_FREQUENCIES), + ("", "%s" % _("Choose repeat frequency")), + ("-- %s --" % _("Frequency"), INTERVAL_FREQUENCIES), ) DATE_DAY, NTH_DAY = "date_day", "nth_day" diff --git a/pod/meeting/views.py b/pod/meeting/views.py index 964b749263..86a4fac8c0 100644 --- a/pod/meeting/views.py +++ b/pod/meeting/views.py @@ -188,7 +188,11 @@ def add_or_edit(request, meeting_id=None): return render( request, "meeting/add_or_edit.html", - {"form": form, "start_date_formats": start_date_formats, "page_title": mark_safe(page_title)}, + { + "form": form, + "start_date_formats": start_date_formats, + "page_title": mark_safe(page_title), + }, )