MCPcopy Create free account
hub / github.com/adobe/Marinus / create_first_groups

Function create_first_groups

python3_cron_scripts/setup.py:174–220  ·  view source on GitHub ↗

The default Marinus install supports two types of groups: admins and data-admins. The group authorization checks exist in both development and production modes. This will list the "marinus" user as the creator for those groups and add "marinus" as a member. The "marinus" user is the

(mongo_connector, username)

Source from the content-addressed store, hash-verified

172
173
174def create_first_groups(mongo_connector, username):
175 """
176 The default Marinus install supports two types of groups: admins and data-admins.
177 The group authorization checks exist in both development and production modes.
178 This will list the "marinus" user as the creator for those groups and add "marinus" as a member.
179 The "marinus" user is the default user when Marinus is in local development mode.
180 """
181 group_collection = mongo_connector.get_groups_connection()
182
183 if group_collection.count_documents({}) > 0:
184 print("WARNING: The group collection already exists. Skipping initialization.")
185 return
186
187 now = datetime.now()
188
189 existing_check = group_collection.count_documents({"name": "admin"})
190 if existing_check != 0:
191 print(
192 "The groups have already been created! You should add users to the groups instead."
193 )
194 return
195
196 members = [username]
197 admins = [username]
198
199 group_collection.insert_one(
200 {
201 "name": "admin",
202 "status": "active",
203 "creation_date": now,
204 "updated": now,
205 "creator": username,
206 "members": members,
207 "admins": admins,
208 }
209 )
210 group_collection.insert_one(
211 {
212 "name": "data_admin",
213 "status": "active",
214 "creation_date": now,
215 "updated": now,
216 "creator": username,
217 "members": members,
218 "admins": admins,
219 }
220 )
221
222
223def add_user_to_group(mongo_connector, username, group):

Callers 1

mainFunction · 0.85

Calls 1

get_groups_connectionMethod · 0.80

Tested by

no test coverage detected