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

indentation

parent 6b5c1d88
No related branches found
No related tags found
1 merge request!336Pylint checks
......@@ -51,19 +51,21 @@ class WorkerForm(ModelForm):
choices = role_choices_by_worker_type(worker_type)
if worker_type in [WORKER_VOUCHER_PARTNER, WORKER_HEALTH_PARTNER]:
'''
Since ChoiceField expects tuples (id, label), for a *custom* HiddenInput field we need to create a charfield with TextInput widget
providing the value of the *id*. hidden_form_field CSS class is defined in templates/doctors/add.html and has display:none property.
'''
# Since ChoiceField expects tuples (id, label), for a *custom* HiddenInput field we need to create
# a charfield with TextInput widget providing the value of the *id*. hidden_form_field CSS class is defined
# in templates/doctors/add.html and has display:none property.
if initial_role is None:
initial_role = choices[0][0] # get 1st element of 1st tuple (('VOUCHER_PARTNER', 'Voucher Partner'),)
self.fields['role'] = forms.CharField(label='Role', widget=forms.TextInput(attrs={'class': 'hidden_form_field'}), disabled=True)
self.fields['role'] = forms.CharField(label='Role',
widget=forms.TextInput(attrs={'class': 'hidden_form_field'}),
disabled=True)
else:
self.fields['role'] = forms.ChoiceField(label='Role', choices=choices)
self.fields['role'].initial = initial_role
#use only the codename used in the code decorators
self.fields['permissions'] = forms.ModelMultipleChoiceField(required=False, queryset=PermissionDecorator.get_permissions())
# use only the codename used in the code decorators
self.fields['permissions'] = forms.ModelMultipleChoiceField(required=False,
queryset=PermissionDecorator.get_permissions())
if initial_permissions is not None:
self.fields['permissions'].initial = [c.pk for c in initial_permissions]
......@@ -88,7 +90,7 @@ class WorkerForm(ModelForm):
fields = OrderedDict()
if worker_type == WORKER_STAFF:
if worker_type == WORKER_STAFF:
if instance is None or instance.pk is None:
fields['login'] = forms.CharField(label='Login')
fields['password'] = forms.CharField(label='Password', widget=forms.PasswordInput)
......@@ -121,7 +123,9 @@ class WorkerForm(ModelForm):
role.permissions.set(self.cleaned_data['permissions'])
role.save()
else:
role = WorkerStudyRole.objects.create(worker=instance, study_id=GLOBAL_STUDY_ID, name=self.cleaned_data['role'])
role = WorkerStudyRole.objects.create(worker=instance,
study_id=GLOBAL_STUDY_ID,
name=self.cleaned_data['role'])
role.permissions.set(self.cleaned_data['permissions'])
role.save()
......
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