huge updates
This commit is contained in:
57 files changed
+10143
-4185
No files matched your search
+12
-2
@@ -17,7 +17,7 @@ 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.",
|
||||
help_text="Enter a new password if you want to reset it. Leave blank otherwise. Default is '123'.",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -27,8 +27,13 @@ class StudentAdminForm(forms.ModelForm):
|
||||
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)
|
||||
# Set default password to '123' for new students if no password provided
|
||||
elif not student.pk and not student.password: # New student without password
|
||||
student.password = make_password("123")
|
||||
|
||||
if commit:
|
||||
student.save()
|
||||
return student
|
||||
@@ -38,7 +43,7 @@ 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.",
|
||||
help_text="Enter a new password if you want to reset it. Leave blank otherwise. Default is '123'.",
|
||||
)
|
||||
|
||||
class Meta:
|
||||
@@ -48,8 +53,13 @@ class StaffAdminForm(forms.ModelForm):
|
||||
def save(self, commit=True):
|
||||
staff = super().save(commit=False)
|
||||
new_password = self.cleaned_data.get("new_password")
|
||||
|
||||
if new_password:
|
||||
staff.password = make_password(new_password)
|
||||
# Set default password to '123' for new staff if no password provided
|
||||
elif not staff.pk and not staff.password: # New staff without password
|
||||
staff.password = make_password("123")
|
||||
|
||||
if commit:
|
||||
staff.save()
|
||||
return staff
|
||||
Reference in new issue
Block a user