updates
This commit is contained in:
1 parent
b791a2992e
commit
d4696b8fee
54 files changed
+1639
-5032
No files matched your search
+45
-17
@@ -1,17 +1,45 @@
|
||||
from django import forms
|
||||
from .models import Subject, Course
|
||||
|
||||
|
||||
class SubjectForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Subject
|
||||
fields = ["name", "course", "duration"] # Include 'name' field here
|
||||
|
||||
# Optionally, you can add custom validation if needed.
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields[
|
||||
"course"
|
||||
].queryset = (
|
||||
Course.objects.all()
|
||||
) # Dynamically set the course queryset if needed
|
||||
from django import forms
|
||||
from django.contrib.auth.hashers import make_password
|
||||
from .models import Staff, Student
|
||||
|
||||
|
||||
class StudentAdminForm(forms.ModelForm):
|
||||
new_password = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.PasswordInput,
|
||||
help_text="Enter a new password if you want to reset it. Leave blank otherwise.",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Student
|
||||
fields = "__all__"
|
||||
|
||||
def save(self, commit=True):
|
||||
student = super().save(commit=False)
|
||||
new_password = self.cleaned_data.get("new_password")
|
||||
if new_password:
|
||||
student.password = make_password(new_password)
|
||||
if commit:
|
||||
student.save()
|
||||
return student
|
||||
|
||||
|
||||
class StaffAdminForm(forms.ModelForm):
|
||||
new_password = forms.CharField(
|
||||
required=False,
|
||||
widget=forms.PasswordInput,
|
||||
help_text="Enter a new password if you want to reset it. Leave blank otherwise.",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
model = Staff
|
||||
fields = "__all__"
|
||||
|
||||
def save(self, commit=True):
|
||||
student = super().save(commit=False)
|
||||
new_password = self.cleaned_data.get("new_password")
|
||||
if new_password:
|
||||
student.password = make_password(new_password)
|
||||
if commit:
|
||||
student.save()
|
||||
return student
|
||||
Reference in new issue
Block a user