MCPcopy Create free account
hub / github.com/alephdata/aleph / load_or_create

Method load_or_create

aleph/model/role.py:229–248  ·  view source on GitHub ↗
(cls, foreign_id, type_, name, email=None, is_admin=False)

Source from the content-addressed store, hash-verified

227
228 @classmethod
229 def load_or_create(cls, foreign_id, type_, name, email=None, is_admin=False):
230 role = cls.by_foreign_id(foreign_id)
231
232 if role is None:
233 role = cls()
234 role.foreign_id = foreign_id
235 role.name = name or email
236 role.type = type_
237 role.is_admin = is_admin
238 role.is_muted = False
239 role.is_tester = False
240 role.is_blocked = False
241 role.notified_at = datetime.utcnow()
242
243 if email is not None:
244 role.email = email
245
246 db.session.add(role)
247 db.session.flush()
248 return role
249
250 @classmethod
251 def load_cli_user(cls):

Callers 10

handle_oauthFunction · 0.80
load_cli_userMethod · 0.80
create_system_rolesFunction · 0.80
create_userFunction · 0.80
create_groupFunction · 0.80
create_userMethod · 0.80
create_groupMethod · 0.80

Calls 3

addMethod · 0.80
by_foreign_idMethod · 0.45
flushMethod · 0.45