Skip to content
Snippets Groups Projects
Commit 5c58b27c authored by Piotr Gawron's avatar Piotr Gawron
Browse files

super is called using python 3 syntax

parent e837736b
No related branches found
No related tags found
1 merge request!350Additional pylint checks
Showing
with 52 additions and 55 deletions
...@@ -26,7 +26,6 @@ disable= ...@@ -26,7 +26,6 @@ disable=
I1101, # c-extension-no-member I1101, # c-extension-no-member
R0904, # too-many-public-methods R0904, # too-many-public-methods
C0123, # unidiomatic-typecheck C0123, # unidiomatic-typecheck
R1725, # super-with-arguments
E1101, # no-member E1101, # no-member
W0235, # useless-super-delegation W0235, # useless-super-delegation
W0702, # bare-except W0702, # bare-except
...@@ -52,7 +51,6 @@ disable= ...@@ -52,7 +51,6 @@ disable=
W0102, # dangerous-default-value W0102, # dangerous-default-value
C0200, # consider-using-enumerate C0200, # consider-using-enumerate
W5104, # modelform-uses-exclude W5104, # modelform-uses-exclude
E1003, # bad-super-call
R0911, # too-many-return-statements R0911, # too-many-return-statements
[FORMAT] [FORMAT]
......
...@@ -21,7 +21,7 @@ class AppointmentForm(ModelForm): ...@@ -21,7 +21,7 @@ class AppointmentForm(ModelForm):
min_value=0) min_value=0)
def __init__(self, *args, **kwargs): 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( 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') locations__in=get_filter_locations(self.user)).distinct().order_by('first_name', 'last_name')
self.changes = [] self.changes = []
...@@ -88,7 +88,7 @@ class AppointmentEditForm(AppointmentForm): ...@@ -88,7 +88,7 @@ class AppointmentEditForm(AppointmentForm):
self.user = Worker.get_by_user(user) self.user = Worker.get_by_user(user)
if self.user is None: if self.user is None:
raise TypeError("Worker not defined for: " + user.username) raise TypeError("Worker not defined for: " + user.username)
super(AppointmentEditForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
if 'instance' in kwargs: if 'instance' in kwargs:
initial_appointment_types = AppointmentTypeLink.objects.filter(appointment=kwargs['instance']).values_list( initial_appointment_types = AppointmentTypeLink.objects.filter(appointment=kwargs['instance']).values_list(
'appointment_type', flat=True) 'appointment_type', flat=True)
...@@ -120,7 +120,7 @@ class AppointmentEditForm(AppointmentForm): ...@@ -120,7 +120,7 @@ class AppointmentEditForm(AppointmentForm):
def save(self, commit=True): def save(self, commit=True):
appointment = super(AppointmentEditForm, self).save(commit) appointment = super().save(commit)
# if appointment date change, remove appointment_type links # if appointment date change, remove appointment_type links
if 'datetime_when' in self.changed_data: if 'datetime_when' in self.changed_data:
AppointmentTypeLink.objects.filter(appointment=appointment).delete() AppointmentTypeLink.objects.filter(appointment=appointment).delete()
...@@ -159,7 +159,7 @@ class AppointmentAddForm(AppointmentForm): ...@@ -159,7 +159,7 @@ class AppointmentAddForm(AppointmentForm):
if self.user is None: if self.user is None:
raise TypeError("Worker not defined for: " + user.username) raise TypeError("Worker not defined for: " + user.username)
super(AppointmentAddForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
fields = OrderedDict() fields = OrderedDict()
for i, field_tuple in enumerate(self.fields.items()): for i, field_tuple in enumerate(self.fields.items()):
key, value = field_tuple key, value = field_tuple
...@@ -189,7 +189,7 @@ class AppointmentAddForm(AppointmentForm): ...@@ -189,7 +189,7 @@ class AppointmentAddForm(AppointmentForm):
return location return location
def save(self, commit=True): def save(self, commit=True):
appointment = super(AppointmentAddForm, self).save(commit) appointment = super().save(commit)
appointment_types = self.cleaned_data['appointment_types'] appointment_types = self.cleaned_data['appointment_types']
for appointment_type in appointment_types: for appointment_type in appointment_types:
appointment_type_link = AppointmentTypeLink(appointment=appointment, appointment_type=appointment_type) appointment_type_link = AppointmentTypeLink(appointment=appointment, appointment_type=appointment_type)
......
...@@ -18,7 +18,7 @@ class ContactAttemptForm(ModelForm): ...@@ -18,7 +18,7 @@ class ContactAttemptForm(ModelForm):
self.user = Worker.get_by_user(user) self.user = Worker.get_by_user(user)
if self.user is None: if self.user is None:
raise TypeError("Worker not defined for: " + user.username) 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['subject'].disabled = True
self.fields['worker'].queryset = Worker.get_workers_by_worker_type(WORKER_STAFF).distinct().order_by( self.fields['worker'].queryset = Worker.get_workers_by_worker_type(WORKER_STAFF).distinct().order_by(
'first_name', 'last_name') 'first_name', 'last_name')
...@@ -31,7 +31,7 @@ class ContactAttemptAddForm(ContactAttemptForm): ...@@ -31,7 +31,7 @@ class ContactAttemptAddForm(ContactAttemptForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
subject = kwargs.pop('subject', None) subject = kwargs.pop('subject', None)
super(ContactAttemptAddForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields['subject'].initial = subject.id self.fields['subject'].initial = subject.id
self.fields['worker'].initial = self.user self.fields['worker'].initial = self.user
...@@ -42,4 +42,4 @@ class ContactAttemptEditForm(ContactAttemptForm): ...@@ -42,4 +42,4 @@ class ContactAttemptEditForm(ContactAttemptForm):
fields = '__all__' fields = '__all__'
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ContactAttemptEditForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
...@@ -13,10 +13,10 @@ class CustomStudySubjectFieldForm(forms.ModelForm): ...@@ -13,10 +13,10 @@ class CustomStudySubjectFieldForm(forms.ModelForm):
required=False) required=False)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(CustomStudySubjectFieldForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def clean(self): def clean(self):
cleaned_data = super(CustomStudySubjectFieldForm, self).clean() cleaned_data = super().clean()
if cleaned_data['default_value'] != '' \ if cleaned_data['default_value'] != '' \
and cleaned_data['default_value'] is not None: and cleaned_data['default_value'] is not None:
...@@ -56,11 +56,11 @@ class CustomStudySubjectFieldAddForm(CustomStudySubjectFieldForm): ...@@ -56,11 +56,11 @@ class CustomStudySubjectFieldAddForm(CustomStudySubjectFieldForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.study = kwargs.pop('study', None) self.study = kwargs.pop('study', None)
super(CustomStudySubjectFieldForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def save(self, commit=True) -> CustomStudySubjectField: def save(self, commit=True) -> CustomStudySubjectField:
self.instance.study_id = self.study.id self.instance.study_id = self.study.id
return super(CustomStudySubjectFieldAddForm, self).save(commit) return super().save(commit)
class CustomStudySubjectFieldEditForm(CustomStudySubjectFieldForm): class CustomStudySubjectFieldEditForm(CustomStudySubjectFieldForm):
...@@ -69,4 +69,4 @@ class CustomStudySubjectFieldEditForm(CustomStudySubjectFieldForm): ...@@ -69,4 +69,4 @@ class CustomStudySubjectFieldEditForm(CustomStudySubjectFieldForm):
fields = '__all__' fields = '__all__'
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(CustomStudySubjectFieldForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
...@@ -58,7 +58,7 @@ class VisitDetailForm(ModelForm): ...@@ -58,7 +58,7 @@ class VisitDetailForm(ModelForm):
queryset=AppointmentType.objects.all()) queryset=AppointmentType.objects.all())
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(VisitDetailForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
instance = getattr(self, 'instance', None) instance = getattr(self, 'instance', None)
if instance.is_finished: # set form as readonly if instance.is_finished: # set form as readonly
for key in list(self.fields.keys()): for key in list(self.fields.keys()):
...@@ -86,7 +86,7 @@ class VisitAddForm(ModelForm): ...@@ -86,7 +86,7 @@ class VisitAddForm(ModelForm):
exclude = ['is_finished', 'visit_number'] exclude = ['is_finished', 'visit_number']
def clean(self): 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: if 'datetime_begin' not in self.cleaned_data or 'datetime_end' not in self.cleaned_data:
return return
if self.cleaned_data['datetime_begin'] >= self.cleaned_data['datetime_end']: if self.cleaned_data['datetime_begin'] >= self.cleaned_data['datetime_end']:
...@@ -108,7 +108,7 @@ class KitRequestForm(Form): ...@@ -108,7 +108,7 @@ class KitRequestForm(Form):
class StatisticsForm(Form): class StatisticsForm(Form):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(StatisticsForm, self).__init__(*args) super().__init__(*args)
visit_choices = kwargs['visit_choices'] visit_choices = kwargs['visit_choices']
month = kwargs['month'] month = kwargs['month']
year = kwargs['year'] year = kwargs['year']
...@@ -139,7 +139,7 @@ class StatisticsForm(Form): ...@@ -139,7 +139,7 @@ class StatisticsForm(Form):
class AvailabilityAddForm(ModelForm): class AvailabilityAddForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(AvailabilityAddForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields['person'].widget.attrs['readonly'] = True self.fields['person'].widget.attrs['readonly'] = True
available_from = forms.TimeField(label="Available from", available_from = forms.TimeField(label="Available from",
...@@ -175,7 +175,7 @@ class AvailabilityEditForm(ModelForm): ...@@ -175,7 +175,7 @@ class AvailabilityEditForm(ModelForm):
fields = '__all__' fields = '__all__'
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(ModelForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
instance = getattr(self, 'instance', None) instance = getattr(self, 'instance', None)
if instance is not None: if instance is not None:
self.availability_id = instance.id self.availability_id = instance.id
...@@ -224,7 +224,7 @@ class FlyingTeamEditForm(ModelForm): ...@@ -224,7 +224,7 @@ class FlyingTeamEditForm(ModelForm):
class HolidayAddForm(ModelForm): class HolidayAddForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(HolidayAddForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields['person'].widget.attrs['readonly'] = True self.fields['person'].widget.attrs['readonly'] = True
datetime_start = forms.DateTimeField(widget=forms.DateTimeInput(DATETIMEPICKER_DATE_ATTRS), datetime_start = forms.DateTimeField(widget=forms.DateTimeInput(DATETIMEPICKER_DATE_ATTRS),
......
...@@ -11,12 +11,12 @@ class MailTemplateForm(ModelForm): ...@@ -11,12 +11,12 @@ class MailTemplateForm(ModelForm):
fields = '__all__' fields = '__all__'
def __init__(self, *args, **kwargs): 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, 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.', 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'})) widget=forms.CheckboxInput(attrs={'class': 'hidden_form_field', 'id': 'multilingual_checkbox'}))
def clean(self): def clean(self):
cleaned_data = super(MailTemplateForm, self).clean() cleaned_data = super().clean()
return cleaned_data return cleaned_data
...@@ -10,10 +10,10 @@ logger = logging.getLogger(__name__) ...@@ -10,10 +10,10 @@ logger = logging.getLogger(__name__)
class StudyEditForm(ModelForm): class StudyEditForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(StudyEditForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
def clean(self): def clean(self):
cleaned_data = super(StudyEditForm, self).clean() cleaned_data = super().clean()
# check regex # check regex
nd_number_study_subject_regex = cleaned_data.get('nd_number_study_subject_regex') nd_number_study_subject_regex = cleaned_data.get('nd_number_study_subject_regex')
...@@ -35,8 +35,7 @@ class StudyEditForm(ModelForm): ...@@ -35,8 +35,7 @@ class StudyEditForm(ModelForm):
class StudyNotificationParametersEditForm(ModelForm): class StudyNotificationParametersEditForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(StudyNotificationParametersEditForm, super().__init__(*args, **kwargs)
self).__init__(*args, **kwargs)
class Meta: class Meta:
model = StudyNotificationParameters model = StudyNotificationParameters
...@@ -46,7 +45,7 @@ class StudyNotificationParametersEditForm(ModelForm): ...@@ -46,7 +45,7 @@ class StudyNotificationParametersEditForm(ModelForm):
class StudyColumnsEditForm(ModelForm): class StudyColumnsEditForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(StudyColumnsEditForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
class Meta: class Meta:
model = StudyColumns model = StudyColumns
...@@ -56,7 +55,7 @@ class StudyColumnsEditForm(ModelForm): ...@@ -56,7 +55,7 @@ class StudyColumnsEditForm(ModelForm):
class StudyRedCapColumnsEditForm(ModelForm): class StudyRedCapColumnsEditForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(StudyRedCapColumnsEditForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
class Meta: class Meta:
model = StudyRedCapColumns model = StudyRedCapColumns
......
...@@ -105,7 +105,7 @@ class StudySubjectForm(ModelForm): ...@@ -105,7 +105,7 @@ class StudySubjectForm(ModelForm):
queryset=VoucherType.objects.all()) queryset=VoucherType.objects.all())
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(StudySubjectForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
instance = kwargs.get('instance') instance = kwargs.get('instance')
if instance: if instance:
for value in instance.custom_data_values: for value in instance.custom_data_values:
...@@ -120,7 +120,7 @@ class StudySubjectForm(ModelForm): ...@@ -120,7 +120,7 @@ class StudySubjectForm(ModelForm):
WORKER_HEALTH_PARTNER) WORKER_HEALTH_PARTNER)
def clean(self): def clean(self):
cleaned_data = super(StudySubjectForm, self).clean() cleaned_data = super().clean()
subject_id = -1 subject_id = -1
if getattr(self, 'instance', None) is not None: if getattr(self, 'instance', None) is not None:
subject_id = getattr(self, 'instance', None).id subject_id = getattr(self, 'instance', None).id
...@@ -149,13 +149,13 @@ class StudySubjectAddForm(StudySubjectForm): ...@@ -149,13 +149,13 @@ class StudySubjectAddForm(StudySubjectForm):
self.user = get_worker_from_args(kwargs) self.user = get_worker_from_args(kwargs)
self.study = get_study_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) prepare_study_subject_fields(fields=self.fields, study=self.study)
def save(self, commit=True) -> StudySubject: def save(self, commit=True) -> StudySubject:
self.instance.study_id = self.study.id 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 # we can add custom values only after object exists in the database
for field_type in CustomStudySubjectField.objects.filter(study=self.study): for field_type in CustomStudySubjectField.objects.filter(study=self.study):
if not field_type.readonly: if not field_type.readonly:
...@@ -172,7 +172,7 @@ class StudySubjectAddForm(StudySubjectForm): ...@@ -172,7 +172,7 @@ class StudySubjectAddForm(StudySubjectForm):
return screening_number return screening_number
def clean(self): def clean(self):
cleaned_data = super(StudySubjectAddForm, self).clean() cleaned_data = super().clean()
screening_number = self.build_screening_number(cleaned_data) screening_number = self.build_screening_number(cleaned_data)
if screening_number is not None and self.study.columns.screening_number: if screening_number is not None and self.study.columns.screening_number:
cleaned_data['screening_number'] = screening_number cleaned_data['screening_number'] = screening_number
...@@ -218,7 +218,7 @@ class StudySubjectDetailForm(StudySubjectForm): ...@@ -218,7 +218,7 @@ class StudySubjectDetailForm(StudySubjectForm):
fields = '__all__' fields = '__all__'
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(StudySubjectDetailForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
instance = getattr(self, 'instance', None) instance = getattr(self, 'instance', None)
self.study = get_study_from_study_subject_instance(instance) self.study = get_study_from_study_subject_instance(instance)
...@@ -271,7 +271,7 @@ class StudySubjectEditForm(StudySubjectForm): ...@@ -271,7 +271,7 @@ class StudySubjectEditForm(StudySubjectForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
was_resigned = kwargs.pop('was_resigned', False) was_resigned = kwargs.pop('was_resigned', False)
endpoint_was_reached = kwargs.pop('endpoint_was_reached', 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) instance = getattr(self, 'instance', None)
if instance and instance.id: if instance and instance.id:
self.fields['screening_number'].widget.attrs['readonly'] = True self.fields['screening_number'].widget.attrs['readonly'] = True
...@@ -283,7 +283,7 @@ class StudySubjectEditForm(StudySubjectForm): ...@@ -283,7 +283,7 @@ class StudySubjectEditForm(StudySubjectForm):
prepare_study_subject_fields(fields=self.fields, study=self.study) prepare_study_subject_fields(fields=self.fields, study=self.study)
def clean(self): def clean(self):
cleaned_data = super(StudySubjectEditForm, self).clean() cleaned_data = super().clean()
validate_subject_nd_number(self, cleaned_data) validate_subject_nd_number(self, cleaned_data)
validate_subject_resign_reason(self, cleaned_data) validate_subject_resign_reason(self, cleaned_data)
return cleaned_data return cleaned_data
...@@ -293,7 +293,7 @@ class StudySubjectEditForm(StudySubjectForm): ...@@ -293,7 +293,7 @@ class StudySubjectEditForm(StudySubjectForm):
if not field_type.readonly: if not field_type.readonly:
self.instance.set_custom_data_value(field_type, get_study_subject_field_value(field_type, self[ self.instance.set_custom_data_value(field_type, get_study_subject_field_value(field_type, self[
get_study_subject_field_id(field_type)])) get_study_subject_field_id(field_type)]))
return super(StudySubjectForm, self).save(commit) return super().save(commit)
class Meta: class Meta:
model = StudySubject model = StudySubject
......
...@@ -38,7 +38,7 @@ class SubjectAddForm(ModelForm): ...@@ -38,7 +38,7 @@ class SubjectAddForm(ModelForm):
exclude = ['dead'] exclude = ['dead']
def clean(self): def clean(self):
cleaned_data = super(SubjectAddForm, self).clean() cleaned_data = super().clean()
validate_subject_country(self, cleaned_data) validate_subject_country(self, cleaned_data)
validate_social_security_number(self, cleaned_data["social_security_number"]) validate_social_security_number(self, cleaned_data["social_security_number"])
return cleaned_data return cleaned_data
...@@ -54,7 +54,7 @@ class SubjectEditForm(ModelForm): ...@@ -54,7 +54,7 @@ class SubjectEditForm(ModelForm):
was_dead = kwargs.get('was_dead', False) was_dead = kwargs.get('was_dead', False)
if 'was_dead' in kwargs: if 'was_dead' in kwargs:
kwargs.pop('was_dead') kwargs.pop('was_dead')
super(SubjectEditForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
if was_dead: if was_dead:
self.fields['dead'].disabled = True self.fields['dead'].disabled = True
......
...@@ -58,7 +58,7 @@ class VoucherForm(ModelForm): ...@@ -58,7 +58,7 @@ class VoucherForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
voucher_types = kwargs.pop('voucher_types', VoucherType.objects.all()) 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, self.fields['voucher_type'].choices = VoucherForm._voucher_type_optgroup(voucher_types,
VoucherType.objects.all()) VoucherType.objects.all())
...@@ -98,7 +98,7 @@ class VoucherForm(ModelForm): ...@@ -98,7 +98,7 @@ class VoucherForm(ModelForm):
self.cleaned_data['issue_date'] = timezone.now() self.cleaned_data['issue_date'] = timezone.now()
def save(self, commit=True): def save(self, commit=True):
instance = super(VoucherForm, self).save(commit=False) instance = super().save(commit=False)
if not instance.id: if not instance.id:
instance.expiry_date = instance.issue_date + relativedelta\ instance.expiry_date = instance.issue_date + relativedelta\
(months=+instance.study_subject.study.default_voucher_expiration_in_months) (months=+instance.study_subject.study.default_voucher_expiration_in_months)
......
...@@ -20,7 +20,7 @@ class WorkerAcceptPrivacyNoticeForm(ModelForm): ...@@ -20,7 +20,7 @@ class WorkerAcceptPrivacyNoticeForm(ModelForm):
fields = ('privacy_notice_accepted', ) fields = ('privacy_notice_accepted', )
def __init__(self, *args, **kwargs): 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?' self.fields['privacy_notice_accepted'].label = 'Do you accept the privacy notice?'
def clean(self): def clean(self):
...@@ -35,7 +35,7 @@ class WorkerForm(ModelForm): ...@@ -35,7 +35,7 @@ class WorkerForm(ModelForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
worker_type = kwargs.pop('worker_type', WORKER_STAFF) worker_type = kwargs.pop('worker_type', WORKER_STAFF)
super(WorkerForm, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
instance = getattr(self, 'instance', None) instance = getattr(self, 'instance', None)
initial_role = None initial_role = None
...@@ -110,7 +110,7 @@ class WorkerForm(ModelForm): ...@@ -110,7 +110,7 @@ class WorkerForm(ModelForm):
email=self.cleaned_data['email'], email=self.cleaned_data['email'],
password=self.cleaned_data['password']) password=self.cleaned_data['password'])
instance = super(WorkerForm, self).save(commit) instance = super().save(commit)
if create_user: if create_user:
instance.user = user instance.user = user
...@@ -130,7 +130,7 @@ class WorkerForm(ModelForm): ...@@ -130,7 +130,7 @@ class WorkerForm(ModelForm):
role.save() role.save()
def clean(self): def clean(self):
cleaned_data = super(WorkerForm, self).clean() cleaned_data = super().clean()
if cleaned_data.get('password', None) is not None: if cleaned_data.get('password', None) is not None:
password = cleaned_data['password'] password = cleaned_data['password']
if cleaned_data['password'] != cleaned_data['password2']: if cleaned_data['password'] != cleaned_data['password2']:
......
...@@ -14,5 +14,5 @@ class AppointmentTypeLink(models.Model): ...@@ -14,5 +14,5 @@ class AppointmentTypeLink(models.Model):
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
if self.date_when is not None: if self.date_when is not None:
self.date_when = self.date_when.replace(tzinfo=None) self.date_when = self.date_when.replace(tzinfo=None)
super(AppointmentTypeLink, self).save(*args, **kwargs) super().save(*args, **kwargs)
return self return self
...@@ -58,5 +58,5 @@ class LoggedInTestCase(TestCase): ...@@ -58,5 +58,5 @@ class LoggedInTestCase(TestCase):
class LoggedInWithWorkerTestCase(LoggedInTestCase): class LoggedInWithWorkerTestCase(LoggedInTestCase):
def setUp(self): def setUp(self):
super(LoggedInWithWorkerTestCase, self).setUp() super().setUp()
self.worker = create_worker(self.user, True) self.worker = create_worker(self.user, True)
...@@ -20,7 +20,7 @@ logger = logging.getLogger(__name__) ...@@ -20,7 +20,7 @@ logger = logging.getLogger(__name__)
class TestVisitApi(LoggedInWithWorkerTestCase): class TestVisitApi(LoggedInWithWorkerTestCase):
def setUp(self): def setUp(self):
super(TestVisitApi, self).setUp() super().setUp()
self.study_subject = create_study_subject() self.study_subject = create_study_subject()
self.visit = create_visit(self.study_subject) self.visit = create_visit(self.study_subject)
......
...@@ -17,7 +17,7 @@ logger = logging.getLogger(__name__) ...@@ -17,7 +17,7 @@ logger = logging.getLogger(__name__)
class TestVoucherApi(LoggedInWithWorkerTestCase): class TestVoucherApi(LoggedInWithWorkerTestCase):
def setUp(self): def setUp(self):
super(TestVoucherApi, self).setUp() super().setUp()
self.voucher = create_voucher() self.voucher = create_voucher()
def test_vouchers_general(self): def test_vouchers_general(self):
......
...@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__) ...@@ -11,7 +11,7 @@ logger = logging.getLogger(__name__)
class TestVoucherTypeApi(LoggedInWithWorkerTestCase): class TestVoucherTypeApi(LoggedInWithWorkerTestCase):
def setUp(self): def setUp(self):
super(TestVoucherTypeApi, self).setUp() super().setUp()
self.voucher_type = create_voucher_type() self.voucher_type = create_voucher_type()
def test_voucher_types_render(self): def test_voucher_types_render(self):
......
...@@ -10,7 +10,7 @@ logger = logging.getLogger(__name__) ...@@ -10,7 +10,7 @@ logger = logging.getLogger(__name__)
class VisitImportDataEditFormTests(LoggedInWithWorkerTestCase): class VisitImportDataEditFormTests(LoggedInWithWorkerTestCase):
def setUp(self): def setUp(self):
super(VisitImportDataEditFormTests, self).setUp() super().setUp()
self.visit_import_data = VisitImportData.objects.create(study=get_test_study(), self.visit_import_data = VisitImportData.objects.create(study=get_test_study(),
import_worker=create_worker()) import_worker=create_worker())
......
...@@ -14,7 +14,7 @@ logger = logging.getLogger(__name__) ...@@ -14,7 +14,7 @@ logger = logging.getLogger(__name__)
class VoucherFormTests(LoggedInWithWorkerTestCase): class VoucherFormTests(LoggedInWithWorkerTestCase):
def setUp(self): def setUp(self):
super(VoucherFormTests, self).setUp() super().setUp()
self.worker = create_worker() self.worker = create_worker()
self.voucher_partner = create_voucher_partner() self.voucher_partner = create_voucher_partner()
......
...@@ -10,7 +10,7 @@ logger = logging.getLogger(__name__) ...@@ -10,7 +10,7 @@ logger = logging.getLogger(__name__)
class VoucherFormTests(LoggedInWithWorkerTestCase): class VoucherFormTests(LoggedInWithWorkerTestCase):
def setUp(self): def setUp(self):
super(VoucherFormTests, self).setUp() super().setUp()
def test_password_miss_match_on_create(self): def test_password_miss_match_on_create(self):
worker_data = VoucherFormTests.create_valid_worker_data() worker_data = VoucherFormTests.create_valid_worker_data()
......
...@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__) ...@@ -18,7 +18,7 @@ logger = logging.getLogger(__name__)
class AppointmentsViewTests(LoggedInTestCase): class AppointmentsViewTests(LoggedInTestCase):
def setUp(self): def setUp(self):
super(AppointmentsViewTests, self).setUp() super().setUp()
create_worker(self.user, True) create_worker(self.user, True)
def test_get_add_general_appointment(self): def test_get_add_general_appointment(self):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment