This will add a new admin to a group. An admin has the authority to add additional members to the group. This functionality is intended for a future feature where additional sub-groups beyond admin and data-admin are supported.
(mongo_connector, username, group)
| 244 | |
| 245 | |
| 246 | def add_admin_to_group(mongo_connector, username, group): |
| 247 | """ |
| 248 | This will add a new admin to a group. An admin has the authority to add additional members to the group. |
| 249 | This functionality is intended for a future feature where additional sub-groups beyond admin and data-admin are supported. |
| 250 | """ |
| 251 | user_collection = mongo_connector.get_users_connection() |
| 252 | group_collection = mongo_connector.get_groups_connection() |
| 253 | now = datetime.now() |
| 254 | |
| 255 | user_exists = user_collection.count_documents({"userid": username}) |
| 256 | if user_exists == 0: |
| 257 | print("User does not yet exist. Please create the user first.") |
| 258 | return |
| 259 | |
| 260 | group_collection.update_one( |
| 261 | {"name": group}, {"$addToSet": {"admins": username}, "$set": {"updated": now}} |
| 262 | ) |
| 263 | |
| 264 | |
| 265 | def create_config_collection(mongo_collection): |
no test coverage detected