huge updates i donot track what updates i have made
This commit is contained in:
55 files changed
+11072
-1415
No files matched your search
+14
-4
@@ -1,8 +1,18 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.hashers import make_password
|
||||
from django.contrib.auth.forms import SetPasswordForm
|
||||
from .models import Staff, Student
|
||||
|
||||
|
||||
class CustomSetPasswordForm(SetPasswordForm):
|
||||
def save(self, commit=True):
|
||||
user = self.user
|
||||
user.set_password(self.cleaned_data["new_password1"])
|
||||
if commit:
|
||||
user.save()
|
||||
return user
|
||||
|
||||
|
||||
class StudentAdminForm(forms.ModelForm):
|
||||
new_password = forms.CharField(
|
||||
required=False,
|
||||
@@ -36,10 +46,10 @@ class StaffAdminForm(forms.ModelForm):
|
||||
fields = "__all__"
|
||||
|
||||
def save(self, commit=True):
|
||||
student = super().save(commit=False)
|
||||
staff = super().save(commit=False)
|
||||
new_password = self.cleaned_data.get("new_password")
|
||||
if new_password:
|
||||
student.password = make_password(new_password)
|
||||
staff.password = make_password(new_password)
|
||||
if commit:
|
||||
student.save()
|
||||
return student
|
||||
staff.save()
|
||||
return staff
|
||||
Reference in new issue
Block a user