forked from DGNum/gestioCOF
Py3 allows to shorten super()
This commit is contained in:
parent
5a5b60ec4d
commit
42e762bc4a
11 changed files with 57 additions and 57 deletions
|
@ -181,7 +181,7 @@ class UserProfileAdmin(UserAdmin):
|
|||
def get_fieldsets(self, request, user=None):
|
||||
if not request.user.is_superuser:
|
||||
return self.staff_fieldsets
|
||||
return super(UserProfileAdmin, self).get_fieldsets(request, user)
|
||||
return super().get_fieldsets(request, user)
|
||||
|
||||
def save_model(self, request, user, form, change):
|
||||
cof_group, created = Group.objects.get_or_create(name='COF')
|
||||
|
@ -267,7 +267,7 @@ class PetitCoursDemandeAdmin(admin.ModelAdmin):
|
|||
|
||||
class ClubAdminForm(forms.ModelForm):
|
||||
def clean(self):
|
||||
cleaned_data = super(ClubAdminForm, self).clean()
|
||||
cleaned_data = super().clean()
|
||||
respos = cleaned_data.get('respos')
|
||||
members = cleaned_data.get('membres')
|
||||
for respo in respos.all():
|
||||
|
|
|
@ -18,7 +18,7 @@ class EventForm(forms.Form):
|
|||
event = kwargs.pop("event")
|
||||
self.event = event
|
||||
current_choices = kwargs.pop("current_choices", None)
|
||||
super(EventForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
choices = {}
|
||||
if current_choices:
|
||||
for choice in current_choices.all():
|
||||
|
@ -60,7 +60,7 @@ class SurveyForm(forms.Form):
|
|||
def __init__(self, *args, **kwargs):
|
||||
survey = kwargs.pop("survey")
|
||||
current_answers = kwargs.pop("current_answers", None)
|
||||
super(SurveyForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
answers = {}
|
||||
if current_answers:
|
||||
for answer in current_answers.all():
|
||||
|
@ -100,7 +100,7 @@ class SurveyForm(forms.Form):
|
|||
class SurveyStatusFilterForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
survey = kwargs.pop("survey")
|
||||
super(SurveyStatusFilterForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
for question in survey.questions.all():
|
||||
for answer in question.answers.all():
|
||||
name = "question_%d_answer_%d" % (question.id, answer.id)
|
||||
|
@ -129,7 +129,7 @@ class SurveyStatusFilterForm(forms.Form):
|
|||
class EventStatusFilterForm(forms.Form):
|
||||
def __init__(self, *args, **kwargs):
|
||||
event = kwargs.pop("event")
|
||||
super(EventStatusFilterForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
for option in event.options.all():
|
||||
for choice in option.choices.all():
|
||||
name = "option_%d_choice_%d" % (option.id, choice.id)
|
||||
|
@ -175,12 +175,12 @@ class UserProfileForm(forms.ModelForm):
|
|||
last_name = forms.CharField(label=_('Nom'), max_length=30)
|
||||
|
||||
def __init__(self, *args, **kw):
|
||||
super(UserProfileForm, self).__init__(*args, **kw)
|
||||
super().__init__(*args, **kw)
|
||||
self.fields['first_name'].initial = self.instance.user.first_name
|
||||
self.fields['last_name'].initial = self.instance.user.last_name
|
||||
|
||||
def save(self, *args, **kw):
|
||||
super(UserProfileForm, self).save(*args, **kw)
|
||||
super().save(*args, **kw)
|
||||
self.instance.user.first_name = self.cleaned_data.get('first_name')
|
||||
self.instance.user.last_name = self.cleaned_data.get('last_name')
|
||||
self.instance.user.save()
|
||||
|
@ -193,7 +193,7 @@ class UserProfileForm(forms.ModelForm):
|
|||
|
||||
class RegistrationUserForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kw):
|
||||
super(RegistrationUserForm, self).__init__(*args, **kw)
|
||||
super().__init__(*args, **kw)
|
||||
self.fields['username'].help_text = ""
|
||||
|
||||
class Meta:
|
||||
|
@ -219,8 +219,7 @@ class RegistrationPassUserForm(RegistrationUserForm):
|
|||
return pass2
|
||||
|
||||
def save(self, commit=True, *args, **kwargs):
|
||||
user = super(RegistrationPassUserForm, self).save(commit, *args,
|
||||
**kwargs)
|
||||
user = super().save(commit, *args, **kwargs)
|
||||
user.set_password(self.cleaned_data['password2'])
|
||||
if commit:
|
||||
user.save()
|
||||
|
@ -229,7 +228,7 @@ class RegistrationPassUserForm(RegistrationUserForm):
|
|||
|
||||
class RegistrationProfileForm(forms.ModelForm):
|
||||
def __init__(self, *args, **kw):
|
||||
super(RegistrationProfileForm, self).__init__(*args, **kw)
|
||||
super().__init__(*args, **kw)
|
||||
self.fields['mailing_cof'].initial = True
|
||||
self.fields['mailing_bda'].initial = True
|
||||
self.fields['mailing_bda_revente'].initial = True
|
||||
|
@ -274,7 +273,7 @@ class AdminEventForm(forms.Form):
|
|||
kwargs["initial"] = {"status": "wait"}
|
||||
else:
|
||||
kwargs["initial"] = {"status": "no"}
|
||||
super(AdminEventForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
choices = {}
|
||||
for choice in current_choices:
|
||||
if choice.event_option.id not in choices:
|
||||
|
@ -337,14 +336,15 @@ class BaseEventRegistrationFormset(BaseFormSet):
|
|||
self.events = kwargs.pop('events')
|
||||
self.current_registrations = kwargs.pop('current_registrations', None)
|
||||
self.extra = len(self.events)
|
||||
super(BaseEventRegistrationFormset, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
def _construct_form(self, index, **kwargs):
|
||||
kwargs['event'] = self.events[index]
|
||||
if self.current_registrations is not None:
|
||||
kwargs['current_registration'] = self.current_registrations[index]
|
||||
return super(BaseEventRegistrationFormset, self)._construct_form(
|
||||
index, **kwargs)
|
||||
return super()._construct_form(index, **kwargs)
|
||||
|
||||
|
||||
EventFormset = formset_factory(AdminEventForm, BaseEventRegistrationFormset)
|
||||
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ from gestioncof.petits_cours_models import PetitCoursDemande, PetitCoursAbility
|
|||
|
||||
class BaseMatieresFormSet(BaseInlineFormSet):
|
||||
def clean(self):
|
||||
super(BaseMatieresFormSet, self).clean()
|
||||
super().clean()
|
||||
if any(self.errors):
|
||||
# Don't bother validating the formset unless each form is
|
||||
# valid on its own
|
||||
|
@ -34,7 +34,7 @@ class DemandeForm(ModelForm):
|
|||
captcha = ReCaptchaField(attrs={'theme': 'clean', 'lang': 'fr'})
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(DemandeForm, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['matieres'].help_text = ''
|
||||
|
||||
class Meta:
|
||||
|
|
|
@ -42,7 +42,7 @@ class DemandeDetailView(DetailView):
|
|||
context_object_name = "demande"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(DemandeDetailView, self).get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
obj = self.object
|
||||
context['attributions'] = obj.petitcoursattribution_set.all()
|
||||
return context
|
||||
|
|
|
@ -5,7 +5,7 @@ from django.utils.safestring import mark_safe
|
|||
|
||||
class TriStateCheckbox(Widget):
|
||||
def __init__(self, attrs=None, choices=()):
|
||||
super(TriStateCheckbox, self).__init__(attrs)
|
||||
super().__init__(attrs)
|
||||
# choices can be any iterable, but we may need to render this widget
|
||||
# multiple times. Thus, collapse it into a list so it can be consumed
|
||||
# more than once.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue