Coverage for sm / forms.py: 100%

16 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-03-24 12:43 +0000

1from django import forms 

2 

3# from django.forms import TextInput # If we want/need to override 

4from taggit.forms import TagWidget 

5 

6 

7class SMForm(forms.ModelForm): 

8 class Meta: 

9 fields = "__all__" 

10 

11 

12class SMFormDisabled(SMForm): 

13 """ 

14 Form for the detail view, disables all user input 

15 """ 

16 

17 def __init__(self, *args, **kwargs): 

18 super().__init__(*args, **kwargs) 

19 instance = getattr(self, "instance", None) 

20 if instance and instance.pk: 

21 for field in self.fields: 

22 if self.fields[field].widget.__class__ is not TagWidget: 

23 # self.fields[field].widget = TextInput() 

24 pass # No logic for this atm 

25 self.fields[field].widget.attrs["disabled"] = True 

26 

27 class Meta(SMForm.Meta): 

28 pass