From 5c58b27c5bb89c644e06c260b25e55bec311e056 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Tue, 24 Aug 2021 11:43:42 +0200 Subject: [PATCH] super is called using python 3 syntax --- .pylintrc | 2 -- smash/web/forms/appointment_form.py | 10 +++++----- smash/web/forms/contact_attempt_forms.py | 6 +++--- .../forms/custom_study_subject_field_forms.py | 10 +++++----- smash/web/forms/forms.py | 12 ++++++------ smash/web/forms/mail_template.py | 4 ++-- smash/web/forms/study_forms.py | 11 +++++------ smash/web/forms/study_subject_forms.py | 18 +++++++++--------- smash/web/forms/subject_forms.py | 4 ++-- smash/web/forms/voucher_forms.py | 4 ++-- smash/web/forms/worker_form.py | 8 ++++---- smash/web/models/appointment_type_link.py | 2 +- smash/web/tests/__init__.py | 2 +- smash/web/tests/api_views/test_visit.py | 2 +- smash/web/tests/api_views/test_voucher.py | 2 +- smash/web/tests/api_views/test_voucher_type.py | 2 +- .../forms/test_visit_import_data_forms.py | 2 +- smash/web/tests/forms/test_voucher_forms.py | 2 +- smash/web/tests/forms/test_worker_forms.py | 2 +- smash/web/tests/view/test_appointments.py | 2 +- .../view/test_custom_study_subject_field.py | 2 +- smash/web/tests/view/test_study.py | 2 +- .../web/tests/view/test_voucher_type_price.py | 2 +- smash/web/views/__init__.py | 4 ++-- smash/web/views/appointment.py | 4 ++-- smash/web/views/appointment_type.py | 10 +++++----- smash/web/views/language.py | 10 +++++----- smash/web/views/mails.py | 6 +++--- smash/web/views/privacy_notice.py | 4 ++-- smash/web/views/provenance.py | 2 +- smash/web/views/subject.py | 4 ++-- smash/web/views/voucher.py | 12 ++++++------ smash/web/views/voucher_partner_session.py | 2 +- smash/web/views/voucher_type.py | 8 ++++---- smash/web/views/voucher_type_price.py | 2 +- smash/web/widgets/secure_file_widget.py | 4 ++-- 36 files changed, 91 insertions(+), 94 deletions(-) diff --git a/.pylintrc b/.pylintrc index 20d3b002..6378986e 100644 --- a/.pylintrc +++ b/.pylintrc @@ -26,7 +26,6 @@ disable= I1101, # c-extension-no-member R0904, # too-many-public-methods C0123, # unidiomatic-typecheck - R1725, # super-with-arguments E1101, # no-member W0235, # useless-super-delegation W0702, # bare-except @@ -52,7 +51,6 @@ disable= W0102, # dangerous-default-value C0200, # consider-using-enumerate W5104, # modelform-uses-exclude - E1003, # bad-super-call R0911, # too-many-return-statements [FORMAT] diff --git a/smash/web/forms/appointment_form.py b/smash/web/forms/appointment_form.py index 0fe2d0e3..333c302b 100644 --- a/smash/web/forms/appointment_form.py +++ b/smash/web/forms/appointment_form.py @@ -21,7 +21,7 @@ class AppointmentForm(ModelForm): min_value=0) def __init__(self, *args, **kwargs): - super(AppointmentForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['worker_assigned'].queryset = Worker.get_workers_by_worker_type(WORKER_STAFF).filter( locations__in=get_filter_locations(self.user)).distinct().order_by('first_name', 'last_name') self.changes = [] @@ -88,7 +88,7 @@ class AppointmentEditForm(AppointmentForm): self.user = Worker.get_by_user(user) if self.user is None: raise TypeError("Worker not defined for: " + user.username) - super(AppointmentEditForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) if 'instance' in kwargs: initial_appointment_types = AppointmentTypeLink.objects.filter(appointment=kwargs['instance']).values_list( 'appointment_type', flat=True) @@ -120,7 +120,7 @@ class AppointmentEditForm(AppointmentForm): def save(self, commit=True): - appointment = super(AppointmentEditForm, self).save(commit) + appointment = super().save(commit) # if appointment date change, remove appointment_type links if 'datetime_when' in self.changed_data: AppointmentTypeLink.objects.filter(appointment=appointment).delete() @@ -159,7 +159,7 @@ class AppointmentAddForm(AppointmentForm): if self.user is None: raise TypeError("Worker not defined for: " + user.username) - super(AppointmentAddForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) fields = OrderedDict() for i, field_tuple in enumerate(self.fields.items()): key, value = field_tuple @@ -189,7 +189,7 @@ class AppointmentAddForm(AppointmentForm): return location def save(self, commit=True): - appointment = super(AppointmentAddForm, self).save(commit) + appointment = super().save(commit) appointment_types = self.cleaned_data['appointment_types'] for appointment_type in appointment_types: appointment_type_link = AppointmentTypeLink(appointment=appointment, appointment_type=appointment_type) diff --git a/smash/web/forms/contact_attempt_forms.py b/smash/web/forms/contact_attempt_forms.py index 39bb260e..dc0486dc 100644 --- a/smash/web/forms/contact_attempt_forms.py +++ b/smash/web/forms/contact_attempt_forms.py @@ -18,7 +18,7 @@ class ContactAttemptForm(ModelForm): self.user = Worker.get_by_user(user) if self.user is None: raise TypeError("Worker not defined for: " + user.username) - super(ContactAttemptForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['subject'].disabled = True self.fields['worker'].queryset = Worker.get_workers_by_worker_type(WORKER_STAFF).distinct().order_by( 'first_name', 'last_name') @@ -31,7 +31,7 @@ class ContactAttemptAddForm(ContactAttemptForm): def __init__(self, *args, **kwargs): subject = kwargs.pop('subject', None) - super(ContactAttemptAddForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['subject'].initial = subject.id self.fields['worker'].initial = self.user @@ -42,4 +42,4 @@ class ContactAttemptEditForm(ContactAttemptForm): fields = '__all__' def __init__(self, *args, **kwargs): - super(ContactAttemptEditForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) diff --git a/smash/web/forms/custom_study_subject_field_forms.py b/smash/web/forms/custom_study_subject_field_forms.py index a986a466..6016fe5b 100644 --- a/smash/web/forms/custom_study_subject_field_forms.py +++ b/smash/web/forms/custom_study_subject_field_forms.py @@ -13,10 +13,10 @@ class CustomStudySubjectFieldForm(forms.ModelForm): required=False) def __init__(self, *args, **kwargs): - super(CustomStudySubjectFieldForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def clean(self): - cleaned_data = super(CustomStudySubjectFieldForm, self).clean() + cleaned_data = super().clean() if cleaned_data['default_value'] != '' \ and cleaned_data['default_value'] is not None: @@ -56,11 +56,11 @@ class CustomStudySubjectFieldAddForm(CustomStudySubjectFieldForm): def __init__(self, *args, **kwargs): self.study = kwargs.pop('study', None) - super(CustomStudySubjectFieldForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def save(self, commit=True) -> CustomStudySubjectField: self.instance.study_id = self.study.id - return super(CustomStudySubjectFieldAddForm, self).save(commit) + return super().save(commit) class CustomStudySubjectFieldEditForm(CustomStudySubjectFieldForm): @@ -69,4 +69,4 @@ class CustomStudySubjectFieldEditForm(CustomStudySubjectFieldForm): fields = '__all__' def __init__(self, *args, **kwargs): - super(CustomStudySubjectFieldForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) diff --git a/smash/web/forms/forms.py b/smash/web/forms/forms.py index c5b3caad..0afb4694 100644 --- a/smash/web/forms/forms.py +++ b/smash/web/forms/forms.py @@ -58,7 +58,7 @@ class VisitDetailForm(ModelForm): queryset=AppointmentType.objects.all()) def __init__(self, *args, **kwargs): - super(VisitDetailForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) instance = getattr(self, 'instance', None) if instance.is_finished: # set form as readonly for key in list(self.fields.keys()): @@ -86,7 +86,7 @@ class VisitAddForm(ModelForm): exclude = ['is_finished', 'visit_number'] def clean(self): - super(VisitAddForm, self).clean() + super().clean() if 'datetime_begin' not in self.cleaned_data or 'datetime_end' not in self.cleaned_data: return if self.cleaned_data['datetime_begin'] >= self.cleaned_data['datetime_end']: @@ -108,7 +108,7 @@ class KitRequestForm(Form): class StatisticsForm(Form): def __init__(self, *args, **kwargs): - super(StatisticsForm, self).__init__(*args) + super().__init__(*args) visit_choices = kwargs['visit_choices'] month = kwargs['month'] year = kwargs['year'] @@ -139,7 +139,7 @@ class StatisticsForm(Form): class AvailabilityAddForm(ModelForm): def __init__(self, *args, **kwargs): - super(AvailabilityAddForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['person'].widget.attrs['readonly'] = True available_from = forms.TimeField(label="Available from", @@ -175,7 +175,7 @@ class AvailabilityEditForm(ModelForm): fields = '__all__' def __init__(self, *args, **kwargs): - super(ModelForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) instance = getattr(self, 'instance', None) if instance is not None: self.availability_id = instance.id @@ -224,7 +224,7 @@ class FlyingTeamEditForm(ModelForm): class HolidayAddForm(ModelForm): def __init__(self, *args, **kwargs): - super(HolidayAddForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['person'].widget.attrs['readonly'] = True datetime_start = forms.DateTimeField(widget=forms.DateTimeInput(DATETIMEPICKER_DATE_ATTRS), diff --git a/smash/web/forms/mail_template.py b/smash/web/forms/mail_template.py index e642ec53..40bf3e87 100644 --- a/smash/web/forms/mail_template.py +++ b/smash/web/forms/mail_template.py @@ -11,12 +11,12 @@ class MailTemplateForm(ModelForm): fields = '__all__' def __init__(self, *args, **kwargs): - super(MailTemplateForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['Multilingual'] = forms.BooleanField(label='Multilingual', disabled=True, required=False, help_text='Only for voucher context. Check this option if the voucher template is multilingual.', widget=forms.CheckboxInput(attrs={'class': 'hidden_form_field', 'id': 'multilingual_checkbox'})) def clean(self): - cleaned_data = super(MailTemplateForm, self).clean() + cleaned_data = super().clean() return cleaned_data diff --git a/smash/web/forms/study_forms.py b/smash/web/forms/study_forms.py index 6bb22821..f601bcb6 100644 --- a/smash/web/forms/study_forms.py +++ b/smash/web/forms/study_forms.py @@ -10,10 +10,10 @@ logger = logging.getLogger(__name__) class StudyEditForm(ModelForm): def __init__(self, *args, **kwargs): - super(StudyEditForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) def clean(self): - cleaned_data = super(StudyEditForm, self).clean() + cleaned_data = super().clean() # check regex nd_number_study_subject_regex = cleaned_data.get('nd_number_study_subject_regex') @@ -35,8 +35,7 @@ class StudyEditForm(ModelForm): class StudyNotificationParametersEditForm(ModelForm): def __init__(self, *args, **kwargs): - super(StudyNotificationParametersEditForm, - self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) class Meta: model = StudyNotificationParameters @@ -46,7 +45,7 @@ class StudyNotificationParametersEditForm(ModelForm): class StudyColumnsEditForm(ModelForm): def __init__(self, *args, **kwargs): - super(StudyColumnsEditForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) class Meta: model = StudyColumns @@ -56,7 +55,7 @@ class StudyColumnsEditForm(ModelForm): class StudyRedCapColumnsEditForm(ModelForm): def __init__(self, *args, **kwargs): - super(StudyRedCapColumnsEditForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) class Meta: model = StudyRedCapColumns diff --git a/smash/web/forms/study_subject_forms.py b/smash/web/forms/study_subject_forms.py index f31538f7..ed63c572 100644 --- a/smash/web/forms/study_subject_forms.py +++ b/smash/web/forms/study_subject_forms.py @@ -105,7 +105,7 @@ class StudySubjectForm(ModelForm): queryset=VoucherType.objects.all()) def __init__(self, *args, **kwargs): - super(StudySubjectForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) instance = kwargs.get('instance') if instance: for value in instance.custom_data_values: @@ -120,7 +120,7 @@ class StudySubjectForm(ModelForm): WORKER_HEALTH_PARTNER) def clean(self): - cleaned_data = super(StudySubjectForm, self).clean() + cleaned_data = super().clean() subject_id = -1 if getattr(self, 'instance', None) is not None: subject_id = getattr(self, 'instance', None).id @@ -149,13 +149,13 @@ class StudySubjectAddForm(StudySubjectForm): self.user = get_worker_from_args(kwargs) self.study = get_study_from_args(kwargs) - super(StudySubjectAddForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) prepare_study_subject_fields(fields=self.fields, study=self.study) def save(self, commit=True) -> StudySubject: self.instance.study_id = self.study.id - instance = super(StudySubjectAddForm, self).save(commit) + instance = super().save(commit) # we can add custom values only after object exists in the database for field_type in CustomStudySubjectField.objects.filter(study=self.study): if not field_type.readonly: @@ -172,7 +172,7 @@ class StudySubjectAddForm(StudySubjectForm): return screening_number def clean(self): - cleaned_data = super(StudySubjectAddForm, self).clean() + cleaned_data = super().clean() screening_number = self.build_screening_number(cleaned_data) if screening_number is not None and self.study.columns.screening_number: cleaned_data['screening_number'] = screening_number @@ -218,7 +218,7 @@ class StudySubjectDetailForm(StudySubjectForm): fields = '__all__' def __init__(self, *args, **kwargs): - super(StudySubjectDetailForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) instance = getattr(self, 'instance', None) self.study = get_study_from_study_subject_instance(instance) @@ -271,7 +271,7 @@ class StudySubjectEditForm(StudySubjectForm): def __init__(self, *args, **kwargs): was_resigned = kwargs.pop('was_resigned', False) endpoint_was_reached = kwargs.pop('endpoint_was_reached', False) - super(StudySubjectEditForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) instance = getattr(self, 'instance', None) if instance and instance.id: self.fields['screening_number'].widget.attrs['readonly'] = True @@ -283,7 +283,7 @@ class StudySubjectEditForm(StudySubjectForm): prepare_study_subject_fields(fields=self.fields, study=self.study) def clean(self): - cleaned_data = super(StudySubjectEditForm, self).clean() + cleaned_data = super().clean() validate_subject_nd_number(self, cleaned_data) validate_subject_resign_reason(self, cleaned_data) return cleaned_data @@ -293,7 +293,7 @@ class StudySubjectEditForm(StudySubjectForm): if not field_type.readonly: self.instance.set_custom_data_value(field_type, get_study_subject_field_value(field_type, self[ get_study_subject_field_id(field_type)])) - return super(StudySubjectForm, self).save(commit) + return super().save(commit) class Meta: model = StudySubject diff --git a/smash/web/forms/subject_forms.py b/smash/web/forms/subject_forms.py index 38555a34..c7269fbb 100644 --- a/smash/web/forms/subject_forms.py +++ b/smash/web/forms/subject_forms.py @@ -38,7 +38,7 @@ class SubjectAddForm(ModelForm): exclude = ['dead'] def clean(self): - cleaned_data = super(SubjectAddForm, self).clean() + cleaned_data = super().clean() validate_subject_country(self, cleaned_data) validate_social_security_number(self, cleaned_data["social_security_number"]) return cleaned_data @@ -54,7 +54,7 @@ class SubjectEditForm(ModelForm): was_dead = kwargs.get('was_dead', False) if 'was_dead' in kwargs: kwargs.pop('was_dead') - super(SubjectEditForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) if was_dead: self.fields['dead'].disabled = True diff --git a/smash/web/forms/voucher_forms.py b/smash/web/forms/voucher_forms.py index e8f02bd1..9e7034eb 100644 --- a/smash/web/forms/voucher_forms.py +++ b/smash/web/forms/voucher_forms.py @@ -58,7 +58,7 @@ class VoucherForm(ModelForm): def __init__(self, *args, **kwargs): voucher_types = kwargs.pop('voucher_types', VoucherType.objects.all()) - super(VoucherForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['voucher_type'].choices = VoucherForm._voucher_type_optgroup(voucher_types, VoucherType.objects.all()) @@ -98,7 +98,7 @@ class VoucherForm(ModelForm): self.cleaned_data['issue_date'] = timezone.now() def save(self, commit=True): - instance = super(VoucherForm, self).save(commit=False) + instance = super().save(commit=False) if not instance.id: instance.expiry_date = instance.issue_date + relativedelta\ (months=+instance.study_subject.study.default_voucher_expiration_in_months) diff --git a/smash/web/forms/worker_form.py b/smash/web/forms/worker_form.py index 09986d0d..ddbac8ca 100644 --- a/smash/web/forms/worker_form.py +++ b/smash/web/forms/worker_form.py @@ -20,7 +20,7 @@ class WorkerAcceptPrivacyNoticeForm(ModelForm): fields = ('privacy_notice_accepted', ) def __init__(self, *args, **kwargs): - super(WorkerAcceptPrivacyNoticeForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['privacy_notice_accepted'].label = 'Do you accept the privacy notice?' def clean(self): @@ -35,7 +35,7 @@ class WorkerForm(ModelForm): def __init__(self, *args, **kwargs): worker_type = kwargs.pop('worker_type', WORKER_STAFF) - super(WorkerForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) instance = getattr(self, 'instance', None) initial_role = None @@ -110,7 +110,7 @@ class WorkerForm(ModelForm): email=self.cleaned_data['email'], password=self.cleaned_data['password']) - instance = super(WorkerForm, self).save(commit) + instance = super().save(commit) if create_user: instance.user = user @@ -130,7 +130,7 @@ class WorkerForm(ModelForm): role.save() def clean(self): - cleaned_data = super(WorkerForm, self).clean() + cleaned_data = super().clean() if cleaned_data.get('password', None) is not None: password = cleaned_data['password'] if cleaned_data['password'] != cleaned_data['password2']: diff --git a/smash/web/models/appointment_type_link.py b/smash/web/models/appointment_type_link.py index 682acd43..9a41e607 100644 --- a/smash/web/models/appointment_type_link.py +++ b/smash/web/models/appointment_type_link.py @@ -14,5 +14,5 @@ class AppointmentTypeLink(models.Model): def save(self, *args, **kwargs): if self.date_when is not None: self.date_when = self.date_when.replace(tzinfo=None) - super(AppointmentTypeLink, self).save(*args, **kwargs) + super().save(*args, **kwargs) return self diff --git a/smash/web/tests/__init__.py b/smash/web/tests/__init__.py index 7fa27a7d..5485ecf9 100644 --- a/smash/web/tests/__init__.py +++ b/smash/web/tests/__init__.py @@ -58,5 +58,5 @@ class LoggedInTestCase(TestCase): class LoggedInWithWorkerTestCase(LoggedInTestCase): def setUp(self): - super(LoggedInWithWorkerTestCase, self).setUp() + super().setUp() self.worker = create_worker(self.user, True) diff --git a/smash/web/tests/api_views/test_visit.py b/smash/web/tests/api_views/test_visit.py index 65f60d55..fd61ae3a 100644 --- a/smash/web/tests/api_views/test_visit.py +++ b/smash/web/tests/api_views/test_visit.py @@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) class TestVisitApi(LoggedInWithWorkerTestCase): def setUp(self): - super(TestVisitApi, self).setUp() + super().setUp() self.study_subject = create_study_subject() self.visit = create_visit(self.study_subject) diff --git a/smash/web/tests/api_views/test_voucher.py b/smash/web/tests/api_views/test_voucher.py index 7985d788..edeabb59 100644 --- a/smash/web/tests/api_views/test_voucher.py +++ b/smash/web/tests/api_views/test_voucher.py @@ -17,7 +17,7 @@ logger = logging.getLogger(__name__) class TestVoucherApi(LoggedInWithWorkerTestCase): def setUp(self): - super(TestVoucherApi, self).setUp() + super().setUp() self.voucher = create_voucher() def test_vouchers_general(self): diff --git a/smash/web/tests/api_views/test_voucher_type.py b/smash/web/tests/api_views/test_voucher_type.py index 11ea6cbe..f60e2a0e 100644 --- a/smash/web/tests/api_views/test_voucher_type.py +++ b/smash/web/tests/api_views/test_voucher_type.py @@ -11,7 +11,7 @@ logger = logging.getLogger(__name__) class TestVoucherTypeApi(LoggedInWithWorkerTestCase): def setUp(self): - super(TestVoucherTypeApi, self).setUp() + super().setUp() self.voucher_type = create_voucher_type() def test_voucher_types_render(self): diff --git a/smash/web/tests/forms/test_visit_import_data_forms.py b/smash/web/tests/forms/test_visit_import_data_forms.py index bae4ac5a..5e4db7f6 100644 --- a/smash/web/tests/forms/test_visit_import_data_forms.py +++ b/smash/web/tests/forms/test_visit_import_data_forms.py @@ -10,7 +10,7 @@ logger = logging.getLogger(__name__) class VisitImportDataEditFormTests(LoggedInWithWorkerTestCase): def setUp(self): - super(VisitImportDataEditFormTests, self).setUp() + super().setUp() self.visit_import_data = VisitImportData.objects.create(study=get_test_study(), import_worker=create_worker()) diff --git a/smash/web/tests/forms/test_voucher_forms.py b/smash/web/tests/forms/test_voucher_forms.py index f5e02409..7d148f7d 100644 --- a/smash/web/tests/forms/test_voucher_forms.py +++ b/smash/web/tests/forms/test_voucher_forms.py @@ -14,7 +14,7 @@ logger = logging.getLogger(__name__) class VoucherFormTests(LoggedInWithWorkerTestCase): def setUp(self): - super(VoucherFormTests, self).setUp() + super().setUp() self.worker = create_worker() self.voucher_partner = create_voucher_partner() diff --git a/smash/web/tests/forms/test_worker_forms.py b/smash/web/tests/forms/test_worker_forms.py index 90e18947..19eed63a 100644 --- a/smash/web/tests/forms/test_worker_forms.py +++ b/smash/web/tests/forms/test_worker_forms.py @@ -10,7 +10,7 @@ logger = logging.getLogger(__name__) class VoucherFormTests(LoggedInWithWorkerTestCase): def setUp(self): - super(VoucherFormTests, self).setUp() + super().setUp() def test_password_miss_match_on_create(self): worker_data = VoucherFormTests.create_valid_worker_data() diff --git a/smash/web/tests/view/test_appointments.py b/smash/web/tests/view/test_appointments.py index f9003e31..3272add6 100644 --- a/smash/web/tests/view/test_appointments.py +++ b/smash/web/tests/view/test_appointments.py @@ -18,7 +18,7 @@ logger = logging.getLogger(__name__) class AppointmentsViewTests(LoggedInTestCase): def setUp(self): - super(AppointmentsViewTests, self).setUp() + super().setUp() create_worker(self.user, True) def test_get_add_general_appointment(self): diff --git a/smash/web/tests/view/test_custom_study_subject_field.py b/smash/web/tests/view/test_custom_study_subject_field.py index 72bb61dc..243ba525 100644 --- a/smash/web/tests/view/test_custom_study_subject_field.py +++ b/smash/web/tests/view/test_custom_study_subject_field.py @@ -13,7 +13,7 @@ logger = logging.getLogger(__name__) class CustomStudySubjectFieldViewTests(LoggedInWithWorkerTestCase): def setUp(self): - super(CustomStudySubjectFieldViewTests, self).setUp() + super().setUp() self.study = get_test_study() def test_render_add(self): diff --git a/smash/web/tests/view/test_study.py b/smash/web/tests/view/test_study.py index d71abed6..b957e538 100644 --- a/smash/web/tests/view/test_study.py +++ b/smash/web/tests/view/test_study.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) class StudyViewTests(LoggedInWithWorkerTestCase): def setUp(self): - super(StudyViewTests, self).setUp() + super().setUp() self.study = get_test_study() def test_render_study_edit(self): diff --git a/smash/web/tests/view/test_voucher_type_price.py b/smash/web/tests/view/test_voucher_type_price.py index f526eb34..e1d7b1e1 100644 --- a/smash/web/tests/view/test_voucher_type_price.py +++ b/smash/web/tests/view/test_voucher_type_price.py @@ -12,7 +12,7 @@ logger = logging.getLogger(__name__) class VoucherTypePriceViewTests(LoggedInTestCase): def setUp(self): - super(VoucherTypePriceViewTests, self).setUp() + super().setUp() self.voucher_type = create_voucher_type() def test_render_add_voucher_type_price_request(self): diff --git a/smash/web/views/__init__.py b/smash/web/views/__init__.py index c70997a0..c5ff9f4c 100644 --- a/smash/web/views/__init__.py +++ b/smash/web/views/__init__.py @@ -84,11 +84,11 @@ def extend_context(params, request: HttpRequest): class WrappedView(ContextMixin): def get_context_data(self, **kwargs): - context = super(WrappedView, self).get_context_data(**kwargs) + context = super().get_context_data(**kwargs) return extend_context(context, self.request) def dispatch(self, *args, **kwargs): - return super(WrappedView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) # pylint: disable=wrong-import-position diff --git a/smash/web/views/appointment.py b/smash/web/views/appointment.py index 0004d639..42aeb290 100644 --- a/smash/web/views/appointment.py +++ b/smash/web/views/appointment.py @@ -195,8 +195,8 @@ class AppointmentDeleteView(DeleteView, WrappedView): modified_field = '', ) p.save() - return super(AppointmentDeleteView, self).delete(request, *args, **kwargs) + return super().delete(request, *args, **kwargs) @PermissionDecorator('delete_appointment', 'configuration') def dispatch(self, *args, **kwargs): - return super(AppointmentDeleteView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) diff --git a/smash/web/views/appointment_type.py b/smash/web/views/appointment_type.py index 410f4e34..42f43a53 100644 --- a/smash/web/views/appointment_type.py +++ b/smash/web/views/appointment_type.py @@ -14,7 +14,7 @@ class AppointmentTypeListView(ListView, WrappedView): @PermissionDecorator('change_appointmenttype', 'equipment') def dispatch(self, *args, **kwargs): - return super(AppointmentTypeListView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) class AppointmentTypeCreateView(CreateView, WrappedView): @@ -26,7 +26,7 @@ class AppointmentTypeCreateView(CreateView, WrappedView): @PermissionDecorator('change_appointmenttype', 'equipment') def dispatch(self, *args, **kwargs): - return super(AppointmentTypeCreateView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) class AppointmentTypeEditView(UpdateView, WrappedView): @@ -39,7 +39,7 @@ class AppointmentTypeEditView(UpdateView, WrappedView): @PermissionDecorator('change_appointmenttype', 'equipment') def dispatch(self, *args, **kwargs): - return super(AppointmentTypeEditView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) class AppointmentTypeDeleteView(DeleteView, WrappedView): @@ -49,8 +49,8 @@ class AppointmentTypeDeleteView(DeleteView, WrappedView): def delete(self, request, *args, **kwargs): messages.success(request, "Appointment Type deleted") - return super(AppointmentTypeDeleteView, self).delete(request, *args, **kwargs) + return super().delete(request, *args, **kwargs) @PermissionDecorator('change_appointmenttype', 'equipment') def dispatch(self, *args, **kwargs): - return super(AppointmentTypeDeleteView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) diff --git a/smash/web/views/language.py b/smash/web/views/language.py index ed550ac8..c46fe946 100644 --- a/smash/web/views/language.py +++ b/smash/web/views/language.py @@ -17,7 +17,7 @@ class LanguageListView(ListView, WrappedView): @PermissionDecorator('change_language', 'configuration') def dispatch(self, *args, **kwargs): - return super(LanguageListView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) class LanguageCreateView(CreateView, WrappedView): model = Language @@ -28,7 +28,7 @@ class LanguageCreateView(CreateView, WrappedView): @PermissionDecorator('change_language', 'configuration') def dispatch(self, *args, **kwargs): - return super(LanguageCreateView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) class LanguageDeleteView(DeleteView, WrappedView): model = Language @@ -37,11 +37,11 @@ class LanguageDeleteView(DeleteView, WrappedView): def delete(self, request, *args, **kwargs): messages.success(request, "Language deleted") - return super(LanguageDeleteView, self).delete(request, *args, **kwargs) + return super().delete(request, *args, **kwargs) @PermissionDecorator('change_language', 'configuration') def dispatch(self, *args, **kwargs): - return super(LanguageDeleteView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) class LanguageEditView(UpdateView, WrappedView): model = Language @@ -53,4 +53,4 @@ class LanguageEditView(UpdateView, WrappedView): @PermissionDecorator('change_language', 'configuration') def dispatch(self, *args, **kwargs): - return super(LanguageEditView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) diff --git a/smash/web/views/mails.py b/smash/web/views/mails.py index 2dbd1d70..c94b4de9 100644 --- a/smash/web/views/mails.py +++ b/smash/web/views/mails.py @@ -35,10 +35,10 @@ class MailTemplatesListView(ListView, WrappedView): @PermissionDecorator('change_mailtemplate', 'mailtemplate') def dispatch(self, *args, **kwargs): - return super(MailTemplatesListView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) def get_context_data(self, *args, **kwargs): - context = super(MailTemplatesListView, self).get_context_data() + context = super().get_context_data() context['explanations'] = {"generic": MailTemplate.MAILS_TEMPLATE_GENERIC_TAGS, "subject": MailTemplate.MAILS_TEMPLATE_SUBJECT_TAGS, "visit": MailTemplate.MAILS_TEMPLATE_VISIT_TAGS, @@ -93,7 +93,7 @@ class MailTemplatesDeleteView(DeleteView, WrappedView): def delete(self, request, *args, **kwargs): messages.success(request, "Template deleted") try: - return super(MailTemplatesDeleteView, self).delete(request, *args, **kwargs) + return super().delete(request, *args, **kwargs) except: messages.add_message(request, messages.ERROR, 'There was a problem when deleting template. ' 'Contact system administrator.') diff --git a/smash/web/views/privacy_notice.py b/smash/web/views/privacy_notice.py index 2441ea4d..7b50de1c 100644 --- a/smash/web/views/privacy_notice.py +++ b/smash/web/views/privacy_notice.py @@ -23,7 +23,7 @@ class PrivacyNoticeListView(ListView, WrappedView): @PermissionDecorator('change_privacynotice', 'privacynotice') def dispatch(self, *args, **kwargs): - return super(PrivacyNoticeListView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) @PermissionDecorator('change_privacynotice', 'privacynotice') @@ -73,7 +73,7 @@ class PrivacyNoticeDeleteView(DeleteView, WrappedView): @PermissionDecorator('change_privacynotice', 'privacynotice') def delete(self, request, *args, **kwargs): messages.success(request, "Privacy Notice deleted") - return super(PrivacyNoticeDeleteView, self).delete(request, *args, **kwargs) + return super().delete(request, *args, **kwargs) def privacy_notice_accept(request, pk): diff --git a/smash/web/views/provenance.py b/smash/web/views/provenance.py index 9d1be577..bdaa8468 100644 --- a/smash/web/views/provenance.py +++ b/smash/web/views/provenance.py @@ -12,4 +12,4 @@ class ProvenanceListView(ListView, WrappedView): @PermissionDecorator('view_provenance', 'configuration') def dispatch(self, *args, **kwargs): - return super(ProvenanceListView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) diff --git a/smash/web/views/subject.py b/smash/web/views/subject.py index 6ba8f1fe..14671333 100644 --- a/smash/web/views/subject.py +++ b/smash/web/views/subject.py @@ -78,7 +78,7 @@ class SubjectDeleteView(DeleteView, WrappedView): def delete(self, request, *args, **kwargs): messages.success(request, "Subject deleted") try: - return super(SubjectDeleteView, self).delete(request, *args, **kwargs) + return super().delete(request, *args, **kwargs) except: messages.add_message(request, messages.ERROR, 'There was a problem when deleting the subject. ' 'Contact system administrator.') @@ -103,7 +103,7 @@ class StudySubjectDeleteView(DeleteView, WrappedView): def delete(self, request, *args, **kwargs): messages.success(request, "Study Subject deleted") try: - return super(StudySubjectDeleteView, self).delete(request, *args, **kwargs) + return super().delete(request, *args, **kwargs) except: messages.add_message(request, messages.ERROR, 'There was a problem when deleting the Study Subject. ' 'Contact system administrator.') diff --git a/smash/web/views/voucher.py b/smash/web/views/voucher.py index e68918f6..dc003a08 100644 --- a/smash/web/views/voucher.py +++ b/smash/web/views/voucher.py @@ -26,7 +26,7 @@ class VoucherListView(ListView, WrappedView): @PermissionDecorator('change_voucher', 'configuration') def dispatch(self, *args, **kwargs): - return super(VoucherListView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) def voucher_types_for_study_subject(study_subject_id): @@ -53,20 +53,20 @@ class VoucherCreateView(CreateView, WrappedView): form.instance.study_id = GLOBAL_STUDY_ID # noinspection PyUnresolvedReferences form.instance.study_subject_id = self.request.GET.get("study_subject_id", -1) - return super(VoucherCreateView, self).form_valid(form) + return super().form_valid(form) def get_success_url(self, **kwargs): # noinspection PyUnresolvedReferences return reverse_lazy('web.views.subject_edit', kwargs={'id': self.request.GET.get("study_subject_id", -1)}) def get_form_kwargs(self): - kwargs = super(VoucherCreateView, self).get_form_kwargs() + kwargs = super().get_form_kwargs() kwargs['voucher_types'] = voucher_types_for_study_subject(self.request.GET.get("study_subject_id", -1)) return kwargs @PermissionDecorator('change_voucher', 'configuration') def dispatch(self, *args, **kwargs): - return super(VoucherCreateView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) class VoucherEditView(SuccessMessageMixin, UpdateView, WrappedView): form_class = VoucherForm @@ -85,13 +85,13 @@ class VoucherEditView(SuccessMessageMixin, UpdateView, WrappedView): return Voucher.objects.get(id=self.kwargs['pk']).study_subject.id def get_context_data(self, *args, **kwargs): - context = super(VoucherEditView, self).get_context_data(*args, **kwargs) + context = super().get_context_data(*args, **kwargs) context['mail_templates'] = MailTemplate.get_voucher_mail_templates([]) return context @PermissionDecorator('change_voucher', 'configuration') def dispatch(self, *args, **kwargs): - return super(VoucherEditView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) class ExpireVouchersJob(CronJobBase): diff --git a/smash/web/views/voucher_partner_session.py b/smash/web/views/voucher_partner_session.py index 77972d30..27553497 100644 --- a/smash/web/views/voucher_partner_session.py +++ b/smash/web/views/voucher_partner_session.py @@ -23,7 +23,7 @@ class VoucherPartnerSessionCreateView(CreateView, WrappedView): def form_valid(self, form): form.instance.voucher_id = self.kwargs['pk'] - response = super(VoucherPartnerSessionCreateView, self).form_valid(form) + response = super().form_valid(form) voucher = Voucher.objects.get(pk=self.kwargs['pk']) if voucher.status == VOUCHER_STATUS_NEW: voucher.status = VOUCHER_STATUS_IN_USE diff --git a/smash/web/views/voucher_type.py b/smash/web/views/voucher_type.py index 1c47a8e6..c9e14212 100644 --- a/smash/web/views/voucher_type.py +++ b/smash/web/views/voucher_type.py @@ -17,7 +17,7 @@ class VoucherTypeListView(ListView, WrappedView): @PermissionDecorator('change_vouchertype', 'configuration') def dispatch(self, *args, **kwargs): - return super(VoucherTypeListView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) class VoucherTypeCreateView(CreateView, WrappedView): form_class = VoucherTypeForm @@ -29,11 +29,11 @@ class VoucherTypeCreateView(CreateView, WrappedView): def form_valid(self, form): form.instance.study_id = GLOBAL_STUDY_ID - return super(VoucherTypeCreateView, self).form_valid(form) + return super().form_valid(form) @PermissionDecorator('change_vouchertype', 'configuration') def dispatch(self, *args, **kwargs): - return super(VoucherTypeCreateView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) #@PermissionDecorator('change_vouchertype', 'configuration') class VoucherTypeEditView(UpdateView, WrappedView): @@ -47,4 +47,4 @@ class VoucherTypeEditView(UpdateView, WrappedView): @PermissionDecorator('change_vouchertype', 'configuration') def dispatch(self, *args, **kwargs): - return super(VoucherTypeEditView, self).dispatch(*args, **kwargs) + return super().dispatch(*args, **kwargs) diff --git a/smash/web/views/voucher_type_price.py b/smash/web/views/voucher_type_price.py index 11f6f4dd..a5b4e8af 100644 --- a/smash/web/views/voucher_type_price.py +++ b/smash/web/views/voucher_type_price.py @@ -22,7 +22,7 @@ class VoucherTypePriceCreateView(CreateView, WrappedView): def form_valid(self, form): # noinspection PyUnresolvedReferences form.instance.voucher_type_id = self.kwargs['voucher_type_id'] - return super(VoucherTypePriceCreateView, self).form_valid(form) + return super().form_valid(form) def get_success_url(self, **kwargs): # noinspection PyUnresolvedReferences diff --git a/smash/web/widgets/secure_file_widget.py b/smash/web/widgets/secure_file_widget.py index 4d87384c..604b6780 100644 --- a/smash/web/widgets/secure_file_widget.py +++ b/smash/web/widgets/secure_file_widget.py @@ -14,7 +14,7 @@ class SecuredFileWidget(forms.FileInput): def __init__(self, attrs=None): if attrs is None: attrs = {} - super(SecuredFileWidget, self).__init__(attrs) + super().__init__(attrs) def render(self, name, value, attrs=None, renderer=None): output = [] @@ -22,5 +22,5 @@ class SecuredFileWidget(forms.FileInput): url = reverse('web.views.uploaded_files') + '?file=' + str(value) out = '<a href="{}">{}</a><br />{} ' output.append(out.format(url, _('Download'), _('Change:'))) - output.append(super(SecuredFileWidget, self).render(name, value, attrs, renderer=renderer)) + output.append(super().render(name, value, attrs, renderer=renderer)) return mark_safe(''.join(output)) -- GitLab