Merge branch 'aureplop/Kerl/drop_py2_compat' into 'Kerl/drop_py2_compat'
Py3 allows to shorten super() See merge request cof-geek/gestioCOF!284
This commit is contained in:
commit
8c68270a4d
11 changed files with 57 additions and 57 deletions
|
@ -164,7 +164,7 @@ class AttributionAdminForm(forms.ModelForm):
|
||||||
)
|
)
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(AttributionAdminForm, self).clean()
|
cleaned_data = super().clean()
|
||||||
participant = cleaned_data.get("participant")
|
participant = cleaned_data.get("participant")
|
||||||
spectacle = cleaned_data.get("spectacle")
|
spectacle = cleaned_data.get("spectacle")
|
||||||
if participant and spectacle:
|
if participant and spectacle:
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ResellForm(forms.Form):
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
def __init__(self, participant, *args, **kwargs):
|
def __init__(self, participant, *args, **kwargs):
|
||||||
super(ResellForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['attributions'].queryset = (
|
self.fields['attributions'].queryset = (
|
||||||
participant.attribution_set
|
participant.attribution_set
|
||||||
.filter(spectacle__date__gte=timezone.now())
|
.filter(spectacle__date__gte=timezone.now())
|
||||||
|
@ -70,7 +70,7 @@ class AnnulForm(forms.Form):
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
def __init__(self, participant, *args, **kwargs):
|
def __init__(self, participant, *args, **kwargs):
|
||||||
super(AnnulForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['attributions'].queryset = (
|
self.fields['attributions'].queryset = (
|
||||||
participant.attribution_set
|
participant.attribution_set
|
||||||
.filter(spectacle__date__gte=timezone.now(),
|
.filter(spectacle__date__gte=timezone.now(),
|
||||||
|
@ -89,7 +89,7 @@ class InscriptionReventeForm(forms.Form):
|
||||||
required=False)
|
required=False)
|
||||||
|
|
||||||
def __init__(self, tirage, *args, **kwargs):
|
def __init__(self, tirage, *args, **kwargs):
|
||||||
super(InscriptionReventeForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['spectacles'].queryset = (
|
self.fields['spectacles'].queryset = (
|
||||||
tirage.spectacle_set
|
tirage.spectacle_set
|
||||||
.select_related('location')
|
.select_related('location')
|
||||||
|
@ -104,7 +104,7 @@ class SoldForm(forms.Form):
|
||||||
widget=forms.CheckboxSelectMultiple)
|
widget=forms.CheckboxSelectMultiple)
|
||||||
|
|
||||||
def __init__(self, participant, *args, **kwargs):
|
def __init__(self, participant, *args, **kwargs):
|
||||||
super(SoldForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['attributions'].queryset = (
|
self.fields['attributions'].queryset = (
|
||||||
participant.attribution_set
|
participant.attribution_set
|
||||||
.filter(revente__isnull=False,
|
.filter(revente__isnull=False,
|
||||||
|
|
|
@ -628,7 +628,7 @@ class SpectacleListView(ListView):
|
||||||
return categories
|
return categories
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(SpectacleListView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['tirage_id'] = self.tirage.id
|
context['tirage_id'] = self.tirage.id
|
||||||
context['tirage_name'] = self.tirage.title
|
context['tirage_name'] = self.tirage.title
|
||||||
return context
|
return context
|
||||||
|
|
|
@ -181,7 +181,7 @@ class UserProfileAdmin(UserAdmin):
|
||||||
def get_fieldsets(self, request, user=None):
|
def get_fieldsets(self, request, user=None):
|
||||||
if not request.user.is_superuser:
|
if not request.user.is_superuser:
|
||||||
return self.staff_fieldsets
|
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):
|
def save_model(self, request, user, form, change):
|
||||||
cof_group, created = Group.objects.get_or_create(name='COF')
|
cof_group, created = Group.objects.get_or_create(name='COF')
|
||||||
|
@ -267,7 +267,7 @@ class PetitCoursDemandeAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
class ClubAdminForm(forms.ModelForm):
|
class ClubAdminForm(forms.ModelForm):
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(ClubAdminForm, self).clean()
|
cleaned_data = super().clean()
|
||||||
respos = cleaned_data.get('respos')
|
respos = cleaned_data.get('respos')
|
||||||
members = cleaned_data.get('membres')
|
members = cleaned_data.get('membres')
|
||||||
for respo in respos.all():
|
for respo in respos.all():
|
||||||
|
|
|
@ -18,7 +18,7 @@ class EventForm(forms.Form):
|
||||||
event = kwargs.pop("event")
|
event = kwargs.pop("event")
|
||||||
self.event = event
|
self.event = event
|
||||||
current_choices = kwargs.pop("current_choices", None)
|
current_choices = kwargs.pop("current_choices", None)
|
||||||
super(EventForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
choices = {}
|
choices = {}
|
||||||
if current_choices:
|
if current_choices:
|
||||||
for choice in current_choices.all():
|
for choice in current_choices.all():
|
||||||
|
@ -60,7 +60,7 @@ class SurveyForm(forms.Form):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
survey = kwargs.pop("survey")
|
survey = kwargs.pop("survey")
|
||||||
current_answers = kwargs.pop("current_answers", None)
|
current_answers = kwargs.pop("current_answers", None)
|
||||||
super(SurveyForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
answers = {}
|
answers = {}
|
||||||
if current_answers:
|
if current_answers:
|
||||||
for answer in current_answers.all():
|
for answer in current_answers.all():
|
||||||
|
@ -100,7 +100,7 @@ class SurveyForm(forms.Form):
|
||||||
class SurveyStatusFilterForm(forms.Form):
|
class SurveyStatusFilterForm(forms.Form):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
survey = kwargs.pop("survey")
|
survey = kwargs.pop("survey")
|
||||||
super(SurveyStatusFilterForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
for question in survey.questions.all():
|
for question in survey.questions.all():
|
||||||
for answer in question.answers.all():
|
for answer in question.answers.all():
|
||||||
name = "question_%d_answer_%d" % (question.id, answer.id)
|
name = "question_%d_answer_%d" % (question.id, answer.id)
|
||||||
|
@ -129,7 +129,7 @@ class SurveyStatusFilterForm(forms.Form):
|
||||||
class EventStatusFilterForm(forms.Form):
|
class EventStatusFilterForm(forms.Form):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
event = kwargs.pop("event")
|
event = kwargs.pop("event")
|
||||||
super(EventStatusFilterForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
for option in event.options.all():
|
for option in event.options.all():
|
||||||
for choice in option.choices.all():
|
for choice in option.choices.all():
|
||||||
name = "option_%d_choice_%d" % (option.id, choice.id)
|
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)
|
last_name = forms.CharField(label=_('Nom'), max_length=30)
|
||||||
|
|
||||||
def __init__(self, *args, **kw):
|
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['first_name'].initial = self.instance.user.first_name
|
||||||
self.fields['last_name'].initial = self.instance.user.last_name
|
self.fields['last_name'].initial = self.instance.user.last_name
|
||||||
|
|
||||||
def save(self, *args, **kw):
|
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.first_name = self.cleaned_data.get('first_name')
|
||||||
self.instance.user.last_name = self.cleaned_data.get('last_name')
|
self.instance.user.last_name = self.cleaned_data.get('last_name')
|
||||||
self.instance.user.save()
|
self.instance.user.save()
|
||||||
|
@ -193,7 +193,7 @@ class UserProfileForm(forms.ModelForm):
|
||||||
|
|
||||||
class RegistrationUserForm(forms.ModelForm):
|
class RegistrationUserForm(forms.ModelForm):
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
super(RegistrationUserForm, self).__init__(*args, **kw)
|
super().__init__(*args, **kw)
|
||||||
self.fields['username'].help_text = ""
|
self.fields['username'].help_text = ""
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -219,8 +219,7 @@ class RegistrationPassUserForm(RegistrationUserForm):
|
||||||
return pass2
|
return pass2
|
||||||
|
|
||||||
def save(self, commit=True, *args, **kwargs):
|
def save(self, commit=True, *args, **kwargs):
|
||||||
user = super(RegistrationPassUserForm, self).save(commit, *args,
|
user = super().save(commit, *args, **kwargs)
|
||||||
**kwargs)
|
|
||||||
user.set_password(self.cleaned_data['password2'])
|
user.set_password(self.cleaned_data['password2'])
|
||||||
if commit:
|
if commit:
|
||||||
user.save()
|
user.save()
|
||||||
|
@ -229,7 +228,7 @@ class RegistrationPassUserForm(RegistrationUserForm):
|
||||||
|
|
||||||
class RegistrationProfileForm(forms.ModelForm):
|
class RegistrationProfileForm(forms.ModelForm):
|
||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
super(RegistrationProfileForm, self).__init__(*args, **kw)
|
super().__init__(*args, **kw)
|
||||||
self.fields['mailing_cof'].initial = True
|
self.fields['mailing_cof'].initial = True
|
||||||
self.fields['mailing_bda'].initial = True
|
self.fields['mailing_bda'].initial = True
|
||||||
self.fields['mailing_bda_revente'].initial = True
|
self.fields['mailing_bda_revente'].initial = True
|
||||||
|
@ -274,7 +273,7 @@ class AdminEventForm(forms.Form):
|
||||||
kwargs["initial"] = {"status": "wait"}
|
kwargs["initial"] = {"status": "wait"}
|
||||||
else:
|
else:
|
||||||
kwargs["initial"] = {"status": "no"}
|
kwargs["initial"] = {"status": "no"}
|
||||||
super(AdminEventForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
choices = {}
|
choices = {}
|
||||||
for choice in current_choices:
|
for choice in current_choices:
|
||||||
if choice.event_option.id not in choices:
|
if choice.event_option.id not in choices:
|
||||||
|
@ -337,14 +336,15 @@ class BaseEventRegistrationFormset(BaseFormSet):
|
||||||
self.events = kwargs.pop('events')
|
self.events = kwargs.pop('events')
|
||||||
self.current_registrations = kwargs.pop('current_registrations', None)
|
self.current_registrations = kwargs.pop('current_registrations', None)
|
||||||
self.extra = len(self.events)
|
self.extra = len(self.events)
|
||||||
super(BaseEventRegistrationFormset, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def _construct_form(self, index, **kwargs):
|
def _construct_form(self, index, **kwargs):
|
||||||
kwargs['event'] = self.events[index]
|
kwargs['event'] = self.events[index]
|
||||||
if self.current_registrations is not None:
|
if self.current_registrations is not None:
|
||||||
kwargs['current_registration'] = self.current_registrations[index]
|
kwargs['current_registration'] = self.current_registrations[index]
|
||||||
return super(BaseEventRegistrationFormset, self)._construct_form(
|
return super()._construct_form(index, **kwargs)
|
||||||
index, **kwargs)
|
|
||||||
|
|
||||||
EventFormset = formset_factory(AdminEventForm, BaseEventRegistrationFormset)
|
EventFormset = formset_factory(AdminEventForm, BaseEventRegistrationFormset)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ from gestioncof.petits_cours_models import PetitCoursDemande, PetitCoursAbility
|
||||||
|
|
||||||
class BaseMatieresFormSet(BaseInlineFormSet):
|
class BaseMatieresFormSet(BaseInlineFormSet):
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super(BaseMatieresFormSet, self).clean()
|
super().clean()
|
||||||
if any(self.errors):
|
if any(self.errors):
|
||||||
# Don't bother validating the formset unless each form is
|
# Don't bother validating the formset unless each form is
|
||||||
# valid on its own
|
# valid on its own
|
||||||
|
@ -34,7 +34,7 @@ class DemandeForm(ModelForm):
|
||||||
captcha = ReCaptchaField(attrs={'theme': 'clean', 'lang': 'fr'})
|
captcha = ReCaptchaField(attrs={'theme': 'clean', 'lang': 'fr'})
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(DemandeForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['matieres'].help_text = ''
|
self.fields['matieres'].help_text = ''
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
|
|
@ -42,7 +42,7 @@ class DemandeDetailView(DetailView):
|
||||||
context_object_name = "demande"
|
context_object_name = "demande"
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(DemandeDetailView, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
obj = self.object
|
obj = self.object
|
||||||
context['attributions'] = obj.petitcoursattribution_set.all()
|
context['attributions'] = obj.petitcoursattribution_set.all()
|
||||||
return context
|
return context
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.utils.safestring import mark_safe
|
||||||
|
|
||||||
class TriStateCheckbox(Widget):
|
class TriStateCheckbox(Widget):
|
||||||
def __init__(self, attrs=None, choices=()):
|
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
|
# 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
|
# multiple times. Thus, collapse it into a list so it can be consumed
|
||||||
# more than once.
|
# more than once.
|
||||||
|
|
|
@ -42,7 +42,7 @@ class AccountForm(forms.ModelForm):
|
||||||
|
|
||||||
# Surcharge pour passer data à Account.save()
|
# Surcharge pour passer data à Account.save()
|
||||||
def save(self, data = {}, *args, **kwargs):
|
def save(self, data = {}, *args, **kwargs):
|
||||||
obj = super(AccountForm, self).save(commit = False, *args, **kwargs)
|
obj = super().save(commit = False, *args, **kwargs)
|
||||||
obj.save(data = data)
|
obj.save(data = data)
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ class AccountPwdForm(forms.Form):
|
||||||
raise ValidationError("Mot de passe trop court")
|
raise ValidationError("Mot de passe trop court")
|
||||||
if pwd1 != pwd2:
|
if pwd1 != pwd2:
|
||||||
raise ValidationError("Les mots de passes sont différents")
|
raise ValidationError("Les mots de passes sont différents")
|
||||||
super(AccountPwdForm, self).clean()
|
super().clean()
|
||||||
|
|
||||||
class CofForm(forms.ModelForm):
|
class CofForm(forms.ModelForm):
|
||||||
def clean_is_cof(self):
|
def clean_is_cof(self):
|
||||||
|
@ -195,7 +195,7 @@ class CheckoutStatementCreateForm(forms.ModelForm):
|
||||||
or self.cleaned_data['balance_200'] is None
|
or self.cleaned_data['balance_200'] is None
|
||||||
or self.cleaned_data['balance_500'] is None):
|
or self.cleaned_data['balance_500'] is None):
|
||||||
raise ValidationError("Y'a un problème. Si tu comptes la caisse, mets au moins des 0 stp (et t'as pas idée de comment c'est long de vérifier que t'as mis des valeurs de partout...)")
|
raise ValidationError("Y'a un problème. Si tu comptes la caisse, mets au moins des 0 stp (et t'as pas idée de comment c'est long de vérifier que t'as mis des valeurs de partout...)")
|
||||||
super(CheckoutStatementCreateForm, self).clean()
|
super().clean()
|
||||||
|
|
||||||
class CheckoutStatementUpdateForm(forms.ModelForm):
|
class CheckoutStatementUpdateForm(forms.ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -236,7 +236,7 @@ class ArticleForm(forms.ModelForm):
|
||||||
required = False)
|
required = False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(ArticleForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
if self.instance.pk:
|
if self.instance.pk:
|
||||||
self.initial['suppliers'] = self.instance.suppliers.values_list('pk', flat=True)
|
self.initial['suppliers'] = self.instance.suppliers.values_list('pk', flat=True)
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ class ArticleForm(forms.ModelForm):
|
||||||
category, _ = ArticleCategory.objects.get_or_create(name=category_new)
|
category, _ = ArticleCategory.objects.get_or_create(name=category_new)
|
||||||
self.cleaned_data['category'] = category
|
self.cleaned_data['category'] = category
|
||||||
|
|
||||||
super(ArticleForm, self).clean()
|
super().clean()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Article
|
model = Article
|
||||||
|
@ -321,7 +321,7 @@ class KPsulOperationForm(forms.ModelForm):
|
||||||
}
|
}
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
super(KPsulOperationForm, self).clean()
|
super().clean()
|
||||||
type_ope = self.cleaned_data.get('type')
|
type_ope = self.cleaned_data.get('type')
|
||||||
amount = self.cleaned_data.get('amount')
|
amount = self.cleaned_data.get('amount')
|
||||||
article = self.cleaned_data.get('article')
|
article = self.cleaned_data.get('article')
|
||||||
|
@ -364,7 +364,7 @@ class AddcostForm(forms.Form):
|
||||||
raise ValidationError('Compte invalide')
|
raise ValidationError('Compte invalide')
|
||||||
else:
|
else:
|
||||||
self.cleaned_data['amount'] = 0
|
self.cleaned_data['amount'] = 0
|
||||||
super(AddcostForm, self).clean()
|
super().clean()
|
||||||
|
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
|
@ -462,7 +462,7 @@ class InventoryArticleForm(forms.Form):
|
||||||
stock_new = forms.IntegerField(required=False)
|
stock_new = forms.IntegerField(required=False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(InventoryArticleForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
if 'initial' in kwargs:
|
if 'initial' in kwargs:
|
||||||
self.name = kwargs['initial']['name']
|
self.name = kwargs['initial']['name']
|
||||||
self.stock_old = kwargs['initial']['stock_old']
|
self.stock_old = kwargs['initial']['stock_old']
|
||||||
|
@ -484,7 +484,7 @@ class OrderArticleForm(forms.Form):
|
||||||
quantity_ordered = forms.IntegerField(required=False)
|
quantity_ordered = forms.IntegerField(required=False)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(OrderArticleForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
if 'initial' in kwargs:
|
if 'initial' in kwargs:
|
||||||
self.name = kwargs['initial']['name']
|
self.name = kwargs['initial']['name']
|
||||||
self.stock = kwargs['initial']['stock']
|
self.stock = kwargs['initial']['stock']
|
||||||
|
@ -514,7 +514,7 @@ class OrderArticleToInventoryForm(forms.Form):
|
||||||
quantity_received = forms.IntegerField()
|
quantity_received = forms.IntegerField()
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(OrderArticleToInventoryForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
if 'initial' in kwargs:
|
if 'initial' in kwargs:
|
||||||
self.name = kwargs['initial']['name']
|
self.name = kwargs['initial']['name']
|
||||||
self.category = kwargs['initial']['category']
|
self.category = kwargs['initial']['category']
|
||||||
|
|
|
@ -255,7 +255,7 @@ class Account(models.Model):
|
||||||
cof.save()
|
cof.save()
|
||||||
if data:
|
if data:
|
||||||
self.cofprofile = cof
|
self.cofprofile = cof
|
||||||
super(Account, self).save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
def change_pwd(self, clear_password):
|
def change_pwd(self, clear_password):
|
||||||
from .auth.utils import hash_password
|
from .auth.utils import hash_password
|
||||||
|
@ -423,7 +423,7 @@ class CheckoutStatement(models.Model):
|
||||||
self.balance_new + self.amount_taken - self.balance_old)
|
self.balance_new + self.amount_taken - self.balance_old)
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
Checkout.objects.filter(pk=checkout_id).update(balance=self.balance_new)
|
Checkout.objects.filter(pk=checkout_id).update(balance=self.balance_new)
|
||||||
super(CheckoutStatement, self).save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
self.amount_error = (
|
self.amount_error = (
|
||||||
self.balance_new + self.amount_taken - self.balance_old)
|
self.balance_new + self.amount_taken - self.balance_old)
|
||||||
|
@ -437,7 +437,7 @@ class CheckoutStatement(models.Model):
|
||||||
and last_statement.balance_new != self.balance_new):
|
and last_statement.balance_new != self.balance_new):
|
||||||
Checkout.objects.filter(pk=self.checkout_id).update(
|
Checkout.objects.filter(pk=self.checkout_id).update(
|
||||||
balance=F('balance') - last_statement.balance_new + self.balance_new)
|
balance=F('balance') - last_statement.balance_new + self.balance_new)
|
||||||
super(CheckoutStatement, self).save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class ArticleCategory(models.Model):
|
class ArticleCategory(models.Model):
|
||||||
|
@ -538,7 +538,7 @@ class InventoryArticle(models.Model):
|
||||||
# d'erreur
|
# d'erreur
|
||||||
if not self.inventory.order:
|
if not self.inventory.order:
|
||||||
self.stock_error = self.stock_new - self.stock_old
|
self.stock_error = self.stock_new - self.stock_old
|
||||||
super(InventoryArticle, self).save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class Supplier(models.Model):
|
class Supplier(models.Model):
|
||||||
|
|
|
@ -493,7 +493,7 @@ class AccountNegativeList(ListView):
|
||||||
context_object_name = 'negatives'
|
context_object_name = 'negatives'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(AccountNegativeList, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
real_balances = (neg.account.real_balance for neg in self.object_list)
|
real_balances = (neg.account.real_balance for neg in self.object_list)
|
||||||
context['negatives_sum'] = sum(real_balances)
|
context['negatives_sum'] = sum(real_balances)
|
||||||
return context
|
return context
|
||||||
|
@ -536,7 +536,7 @@ class CheckoutCreate(SuccessMessageMixin, CreateView):
|
||||||
balance_new = checkout.balance,
|
balance_new = checkout.balance,
|
||||||
amount_taken = 0)
|
amount_taken = 0)
|
||||||
|
|
||||||
return super(CheckoutCreate, self).form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
# Checkout - Read
|
# Checkout - Read
|
||||||
|
|
||||||
|
@ -546,7 +546,7 @@ class CheckoutRead(DetailView):
|
||||||
context_object_name = 'checkout'
|
context_object_name = 'checkout'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(CheckoutRead, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['statements'] = context['checkout'].statements.order_by('-at')
|
context['statements'] = context['checkout'].statements.order_by('-at')
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -565,7 +565,7 @@ class CheckoutUpdate(SuccessMessageMixin, UpdateView):
|
||||||
form.add_error(None, 'Permission refusée')
|
form.add_error(None, 'Permission refusée')
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
# Updating
|
# Updating
|
||||||
return super(CheckoutUpdate, self).form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
# Checkout Statement views
|
# Checkout Statement views
|
||||||
|
@ -617,7 +617,7 @@ class CheckoutStatementCreate(SuccessMessageMixin, CreateView):
|
||||||
at = self.object.at)
|
at = self.object.at)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(CheckoutStatementCreate, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
checkout = Checkout.objects.get(pk=self.kwargs['pk_checkout'])
|
checkout = Checkout.objects.get(pk=self.kwargs['pk_checkout'])
|
||||||
context['checkout'] = checkout
|
context['checkout'] = checkout
|
||||||
return context
|
return context
|
||||||
|
@ -633,7 +633,7 @@ class CheckoutStatementCreate(SuccessMessageMixin, CreateView):
|
||||||
form.instance.balance_new = getAmountBalance(form.cleaned_data)
|
form.instance.balance_new = getAmountBalance(form.cleaned_data)
|
||||||
form.instance.checkout_id = self.kwargs['pk_checkout']
|
form.instance.checkout_id = self.kwargs['pk_checkout']
|
||||||
form.instance.by = self.request.user.profile.account_kfet
|
form.instance.by = self.request.user.profile.account_kfet
|
||||||
return super(CheckoutStatementCreate, self).form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
class CheckoutStatementUpdate(SuccessMessageMixin, UpdateView):
|
class CheckoutStatementUpdate(SuccessMessageMixin, UpdateView):
|
||||||
model = CheckoutStatement
|
model = CheckoutStatement
|
||||||
|
@ -645,7 +645,7 @@ class CheckoutStatementUpdate(SuccessMessageMixin, UpdateView):
|
||||||
return reverse_lazy('kfet.checkout.read', kwargs={'pk':self.kwargs['pk_checkout']})
|
return reverse_lazy('kfet.checkout.read', kwargs={'pk':self.kwargs['pk_checkout']})
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(CheckoutStatementUpdate, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
checkout = Checkout.objects.get(pk=self.kwargs['pk_checkout'])
|
checkout = Checkout.objects.get(pk=self.kwargs['pk_checkout'])
|
||||||
context['checkout'] = checkout
|
context['checkout'] = checkout
|
||||||
return context
|
return context
|
||||||
|
@ -657,7 +657,7 @@ class CheckoutStatementUpdate(SuccessMessageMixin, UpdateView):
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
# Updating
|
# Updating
|
||||||
form.instance.amount_taken = getAmountTaken(form.instance)
|
form.instance.amount_taken = getAmountTaken(form.instance)
|
||||||
return super(CheckoutStatementUpdate, self).form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
# Category views
|
# Category views
|
||||||
|
@ -689,7 +689,7 @@ class CategoryUpdate(SuccessMessageMixin, UpdateView):
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
|
|
||||||
# Updating
|
# Updating
|
||||||
return super(CategoryUpdate, self).form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
# Article views
|
# Article views
|
||||||
|
@ -756,7 +756,7 @@ class ArticleCreate(SuccessMessageMixin, CreateView):
|
||||||
)
|
)
|
||||||
|
|
||||||
# Creating
|
# Creating
|
||||||
return super(ArticleCreate, self).form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
# Article - Read
|
# Article - Read
|
||||||
|
@ -766,7 +766,7 @@ class ArticleRead(DetailView):
|
||||||
context_object_name = 'article'
|
context_object_name = 'article'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(ArticleRead, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
inventoryarts = (InventoryArticle.objects
|
inventoryarts = (InventoryArticle.objects
|
||||||
.filter(article=self.object)
|
.filter(article=self.object)
|
||||||
.select_related('inventory')
|
.select_related('inventory')
|
||||||
|
@ -818,7 +818,7 @@ class ArticleUpdate(SuccessMessageMixin, UpdateView):
|
||||||
article=article, supplier=supplier)
|
article=article, supplier=supplier)
|
||||||
|
|
||||||
# Updating
|
# Updating
|
||||||
return super(ArticleUpdate, self).form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
# -----
|
# -----
|
||||||
|
@ -1709,7 +1709,7 @@ class InventoryRead(DetailView):
|
||||||
context_object_name = 'inventory'
|
context_object_name = 'inventory'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(InventoryRead, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
inventoryarticles = (InventoryArticle.objects
|
inventoryarticles = (InventoryArticle.objects
|
||||||
.select_related('article', 'article__category')
|
.select_related('article', 'article__category')
|
||||||
.filter(inventory = self.object)
|
.filter(inventory = self.object)
|
||||||
|
@ -1727,7 +1727,7 @@ class OrderList(ListView):
|
||||||
context_object_name = 'orders'
|
context_object_name = 'orders'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(OrderList, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['suppliers'] = Supplier.objects.order_by('name')
|
context['suppliers'] = Supplier.objects.order_by('name')
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
@ -1856,7 +1856,7 @@ class OrderRead(DetailView):
|
||||||
context_object_name = 'order'
|
context_object_name = 'order'
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super(OrderRead, self).get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
orderarticles = (OrderArticle.objects
|
orderarticles = (OrderArticle.objects
|
||||||
.select_related('article', 'article__category')
|
.select_related('article', 'article__category')
|
||||||
.filter(order=self.object)
|
.filter(order=self.object)
|
||||||
|
@ -2010,7 +2010,7 @@ class SupplierUpdate(SuccessMessageMixin, UpdateView):
|
||||||
form.add_error(None, 'Permission refusée')
|
form.add_error(None, 'Permission refusée')
|
||||||
return self.form_invalid(form)
|
return self.form_invalid(form)
|
||||||
# Updating
|
# Updating
|
||||||
return super(SupplierUpdate, self).form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
# ==========
|
# ==========
|
||||||
|
@ -2274,7 +2274,7 @@ class AccountStatBalance(PkUrlMixin, JSONDetailView):
|
||||||
|
|
||||||
@method_decorator(login_required)
|
@method_decorator(login_required)
|
||||||
def dispatch(self, *args, **kwargs):
|
def dispatch(self, *args, **kwargs):
|
||||||
return super(AccountStatBalance, self).dispatch(*args, **kwargs)
|
return super().dispatch(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
# ------------------------
|
# ------------------------
|
||||||
|
|
Loading…
Reference in a new issue