67 lines
2.0 KiB
Python
67 lines
2.0 KiB
Python
from django import forms
|
|
from django.core.validators import FileExtensionValidator
|
|
|
|
from apps.standards.models import (
|
|
StandardSource,
|
|
StandardCategory,
|
|
Standard,
|
|
StandardCompliance,
|
|
StandardAttachment
|
|
)
|
|
|
|
|
|
class StandardSourceForm(forms.ModelForm):
|
|
class Meta:
|
|
model = StandardSource
|
|
fields = ['name', 'name_ar', 'code', 'description', 'website', 'is_active']
|
|
widgets = {
|
|
'description': forms.Textarea(attrs={'rows': 3}),
|
|
}
|
|
|
|
|
|
class StandardCategoryForm(forms.ModelForm):
|
|
class Meta:
|
|
model = StandardCategory
|
|
fields = ['name', 'name_ar', 'description', 'order', 'is_active']
|
|
widgets = {
|
|
'description': forms.Textarea(attrs={'rows': 3}),
|
|
}
|
|
|
|
|
|
class StandardForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Standard
|
|
fields = ['source', 'category', 'code', 'title', 'title_ar', 'description',
|
|
'department', 'effective_date', 'review_date', 'is_active']
|
|
widgets = {
|
|
'description': forms.Textarea(attrs={'rows': 5}),
|
|
'effective_date': forms.DateInput(attrs={'type': 'date'}),
|
|
'review_date': forms.DateInput(attrs={'type': 'date'}),
|
|
}
|
|
|
|
|
|
class StandardComplianceForm(forms.ModelForm):
|
|
class Meta:
|
|
model = StandardCompliance
|
|
fields = ['status', 'last_assessed_date', 'assessor', 'notes', 'evidence_summary']
|
|
widgets = {
|
|
'last_assessed_date': forms.DateInput(attrs={'type': 'date'}),
|
|
'notes': forms.Textarea(attrs={'rows': 3}),
|
|
'evidence_summary': forms.Textarea(attrs={'rows': 3}),
|
|
}
|
|
|
|
|
|
class StandardAttachmentForm(forms.ModelForm):
|
|
class Meta:
|
|
model = StandardAttachment
|
|
fields = ['file', 'description']
|
|
widgets = {
|
|
'description': forms.Textarea(attrs={'rows': 2}),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.fields['file'].widget.attrs.update({
|
|
'accept': '.pdf,.doc,.docx,.xls,.xlsx,.jpg,.jpeg,.png,.zip'
|
|
})
|