rasenmaeher_api.db.enrollments

Abstractions for enrollments

Module Contents

Classes

EnrollmentPool

Enrollment pools aka links, pk is UUID and comes from basemodel

EnrollmentState

Enrollment states

Enrollment

Enrollments, pk is UUID and comes from basemodel

Attributes

LOGGER

CODE_CHAR_COUNT

CODE_ALPHABET

CODE_MAX_ATTEMPTS

LOGGER[source]
CODE_CHAR_COUNT = 8[source]
CODE_ALPHABET[source]
CODE_MAX_ATTEMPTS = 100[source]
class EnrollmentPool[source]

Bases: rasenmaeher_api.db.base.ORMBaseModel

Enrollment pools aka links, pk is UUID and comes from basemodel

__tablename__ = 'enrollmentpools'[source]
owner[source]
active[source]
extra[source]
invitecode[source]
async classmethod by_pk_or_invitecode(inval, allow_deleted=False)[source]

Get pool by pk or by invitecode

Parameters:
Return type:

EnrollmentPool

async create_enrollment(callsign)[source]

Create enrollment from this pool

Parameters:

callsign (str)

Return type:

Enrollment

async set_active(state)[source]

Set active and return refreshed object

Parameters:

state (bool)

Return type:

Self

async classmethod list(by_owner=None, include_deleted=False)[source]

List pools, optionally by owner or including deleted pools

Parameters:
Return type:

AsyncGenerator[EnrollmentPool, None]

async classmethod _generate_unused_code()[source]

Internal helper to generate a code that is free NOTE: This MUST ONLY be used inside a transaction for nothing is guaranteed

Return type:

str

async classmethod create_for_owner(person, extra=None)[source]

Creates one for given owner

Parameters:
Return type:

Self

async reset_invitecode()[source]

Reset invitecode

Return type:

str

async classmethod by_invitecode(invitecode, allow_deleted=False)[source]

Get by invitecode

Parameters:
  • invitecode (str)

  • allow_deleted (bool)

Return type:

Self

class EnrollmentState[source]

Bases: enum.IntEnum

Enrollment states

PENDING = 0[source]
APPROVED = 1[source]
REJECTED = 2[source]
class Enrollment[source]

Bases: rasenmaeher_api.db.base.ORMBaseModel

Enrollments, pk is UUID and comes from basemodel

__tablename__ = 'enrollments'[source]
approvecode[source]
callsign[source]
decided_on[source]
decided_by[source]
person[source]
pool[source]
state[source]
extra[source]
async classmethod by_pk_or_callsign(inval)[source]

Get enrollment by pk or by callsign

Parameters:

inval (Union[str, uuid.UUID])

Return type:

Enrollment

async approve(approver)[source]

Creates the person record, their certs etc

Parameters:

approver (rasenmaeher_api.db.people.Person)

Return type:

rasenmaeher_api.db.people.Person

async reject(decider)[source]

Reject

Parameters:

decider (rasenmaeher_api.db.people.Person)

Return type:

None

async classmethod list(by_pool=None)[source]

List enrollments, optionally by pool (enrollment deletion is not allowed, they can only be rejected)

Parameters:

by_pool (Optional[EnrollmentPool])

Return type:

AsyncGenerator[Enrollment, None]

async classmethod by_callsign(callsign)[source]

Get by callsign

Parameters:

callsign (str)

Return type:

Self

async classmethod by_approvecode(code)[source]

Get by approvecode

Parameters:

code (str)

Return type:

Self

async classmethod reset_approvecode4callsign(callsign)[source]

Reset approvecode code for callsign

Parameters:

callsign (str)

Return type:

str

async reset_approvecode()[source]

Reset approvecode

Return type:

str

async classmethod _generate_unused_code()[source]

Internal helper to generate a code that is free NOTE: This MUST ONLY be used inside a transaction for nothing is guaranteed

Return type:

str

async classmethod create_for_callsign(callsign, pool=None, extra=None)[source]

Create a new one with random code for the callsign

Parameters:
Return type:

Self

async delete()[source]

Deletion of enrollments is not allowed

Return type:

bool