Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalization of roll number done #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions backend/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
class UserManager(BaseUserManager):
use_in_migrations = True

def normalize_roll_number(self, roll_number):
return roll_number.upper()

def _create_user(self, roll_number, email, password, **extra_fields):
"""
Create and save a user with the given roll number, email, and password.
"""
if not roll_number:
raise ValueError("The given roll number must be set")
email = self.normalize_email(email)
roll_number = self.normalize_roll_number(roll_number)
user = self.model(roll_number=roll_number, email=email, **extra_fields)
user.password = make_password(password)
user.save(using=self._db)
Expand Down