Skip to content

Commit

Permalink
Merge pull request #309 from EsupPortail/dev
Browse files Browse the repository at this point in the history
fix bug with additionnal owner
  • Loading branch information
ptitloup authored Jun 29, 2020
2 parents 80a0d07 + 8288e47 commit 63e6a36
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions pod/video/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,18 +387,27 @@ def clean_date_delete(self):
in_dt.years == mddd and in_dt.months > 0) or (
in_dt.years == mddd and in_dt.months == 0 and in_dt.days > 0)):
raise ValidationError(
_('The date must be before or equal to ' + MAX_D.strftime(
'%d-%m-%Y')))
_('The date must be before or equal to ' + MAX_D.strftime(
'%d-%m-%Y')))
return self.cleaned_data['date_delete']

def clean(self):
cleaned_data = super(VideoForm, self).clean()

if isinstance(self.cleaned_data['additional_owners'], QuerySet):
if self.cleaned_data['owner'] in self.cleaned_data[
if ('additional_owners' in cleaned_data.keys()
and isinstance(
self.cleaned_data['additional_owners'],
QuerySet
)):
vidowner = (self.instance.owner if hasattr(self.instance, 'owner')
else cleaned_data['owner']
if 'owner' in cleaned_data.keys()
else self.current_user)
if vidowner and vidowner in self.cleaned_data[
'additional_owners'].all():
raise ValidationError(
_("Owner of the video cannot be an additional owner too"))

self.launch_encode = (
'video' in cleaned_data.keys()
and hasattr(self.instance, 'video')
Expand Down Expand Up @@ -501,8 +510,8 @@ def set_nostaff_config(self):
else:
self.fields[
"date_delete"].widget = forms.DateInput(
format=('%Y-%m-%d'),
attrs={"placeholder": "Select a date"})
format=('%Y-%m-%d'),
attrs={"placeholder": "Select a date"})

def hide_default_language(self):
if self.fields.get('description_%s' % settings.LANGUAGE_CODE):
Expand Down Expand Up @@ -533,13 +542,13 @@ def set_queryset(self):
del self.fields['theme']
del self.fields['channel']
self.fields["type"].queryset = Type.objects.all().filter(
sites=Site.objects.get_current())
sites=Site.objects.get_current())
self.fields["restrict_access_to_groups"].queryset = \
self.fields["restrict_access_to_groups"].queryset.filter(
groupsite__sites=Site.objects.get_current())
self.fields["discipline"].queryset = Discipline.objects.all(
).filter(
sites=Site.objects.get_current())
).filter(
sites=Site.objects.get_current())
if "channel" in self.fields:
self.fields["channel"].queryset = \
self.fields["channel"].queryset.filter(
Expand Down

0 comments on commit 63e6a36

Please sign in to comment.