Merge branch 'develop' of bitbucket.org:ecropdev/ielts-be into develop
This commit is contained in:
@@ -44,7 +44,7 @@ class BatchUsers:
|
||||
|
||||
result = self._upload_users('./tmp', file_name)
|
||||
if result.returncode != 0:
|
||||
error_msg = f"Couldn't upload users. Failed to run command firebase auth import -> ```cmd {result.stderr}```"
|
||||
error_msg = f"Couldn't upload users. Failed to run command firebase auth import -> ```cmd {result.stdout}```"
|
||||
self._logger.error(error_msg)
|
||||
return error_msg
|
||||
|
||||
@@ -55,7 +55,11 @@ class BatchUsers:
|
||||
|
||||
@staticmethod
|
||||
def _map_to_batch(request_data: Dict) -> BatchUsersDTO:
|
||||
users: list[UserDTO] = [UserDTO(**user) for user in request_data["users"]]
|
||||
users_list = [{**user} for user in request_data["users"]]
|
||||
for user in users_list:
|
||||
user["studentID"] = str(user["studentID"])
|
||||
|
||||
users: list[UserDTO] = [UserDTO(**user) for user in users_list]
|
||||
return BatchUsersDTO(makerID=request_data["makerID"], users=users)
|
||||
|
||||
@staticmethod
|
||||
@@ -171,14 +175,14 @@ class BatchUsers:
|
||||
def _assign_user_to_group_by_name(self, user: UserDTO, maker_id: str):
|
||||
user_id = str(user.id)
|
||||
|
||||
group = self._db.groups.find_one(
|
||||
groups = list(self._db.groups.find(
|
||||
{
|
||||
"admin": maker_id,
|
||||
"name": user.groupName.strip()
|
||||
}
|
||||
)
|
||||
))
|
||||
|
||||
if group:
|
||||
if len(groups) == 0:
|
||||
new_group = {
|
||||
'id': str(uuid.uuid4()),
|
||||
'admin': maker_id,
|
||||
@@ -188,10 +192,11 @@ class BatchUsers:
|
||||
}
|
||||
self._db.groups.insert_one(new_group)
|
||||
else:
|
||||
participants = group.participants
|
||||
group = groups[0]
|
||||
participants = group["participants"]
|
||||
if user_id not in participants:
|
||||
participants.append(user_id)
|
||||
self._db.groups.update_one(
|
||||
{"id": group.id},
|
||||
{"id": group["id"]},
|
||||
{"$set": {"participants": participants}}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user