Method
load_or_create
(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): |