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

editing subject doesn't allow to modify screening number

parent dfb1e503
No related branches found
No related tags found
No related merge requests found
...@@ -40,6 +40,19 @@ class SubjectEditForm(ModelForm): ...@@ -40,6 +40,19 @@ class SubjectEditForm(ModelForm):
widget=forms.SelectDateWidget(years=YEAR_CHOICES) widget=forms.SelectDateWidget(years=YEAR_CHOICES)
) )
def __init__(self, *args, **kwargs):
super(SubjectEditForm, self).__init__(*args, **kwargs)
instance = getattr(self, 'instance', None)
if instance and instance.id:
self.fields['screening_number'].widget.attrs['readonly'] = True
def clean_foo_field(self):
instance = getattr(self, 'instance', None)
if instance and instance.id:
return instance.screening_number
else:
return self.cleaned_data['screening_number']
class Meta: class Meta:
model = Subject model = Subject
fields = '__all__' fields = '__all__'
......
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