Skip to content

Commit

Permalink
feat: add force modify mail and add student to courses
Browse files Browse the repository at this point in the history
  • Loading branch information
aokblast committed Sep 12, 2024
1 parent b82175a commit 053fbfc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mongo/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def batch_signup(
except engine.DoesNotExist:
new_user = cls.get_by_email(u['email'])
if force:
new_user.force_update(u)
new_user.force_update(u, course)
registered_users.append(new_user)
if course is not None:
new_student_nicknames = {
Expand All @@ -103,7 +103,7 @@ def batch_signup(
course.update_student_namelist(new_student_nicknames)
return new_users

def force_update(self, new_user: Dict[str, Any]):
def force_update(self, new_user: Dict[str, Any], course: Optional[Course]):
'''
Force update an existent user in batch update procedure
'''
Expand All @@ -113,6 +113,10 @@ def force_update(self, new_user: Dict[str, Any]):
self.update(role=role)
if (password := new_user.get('password')) is not None:
self.change_password(password)
if (email := new_user.get('email')) is not None:
self.update(email=email, md5=hashlib.md5(email.encode()).hexdigest())
if course is not None:
self.update(add_to_set__courses=course.id)
self.reload()

@classmethod
Expand Down
Empty file added recover.py
Empty file.

0 comments on commit 053fbfc

Please sign in to comment.