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

feat: add force modify mail and add student to courses #285

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 7 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,11 @@ 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
4 changes: 2 additions & 2 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Empty file added recover.py
Empty file.
Loading