Module collectives.models

Contents

Module collectives.models#

Model module for collectives

This module contains other submodules for collectives model. Persistence is made by SQLAlchemy. This module exposes most important submodules classes by importing them. It also create the db object

Module collectives.models.activity_type#

Module to describe the type of activity.

class collectives.models.activity_type.ActivityKind(*values)#

Enum listing kinds of activities.

classmethod display_names() str#

Display name for all activity kinds. :return: activity kind name

class collectives.models.activity_type.ActivityType(**kwargs)#

Class of the type of activity.

An activity type is a sport (climbing, hiking) or a service. Previously it could also be another occupation (training), but this distinction should now be made using event types. Persistence is done with SQLAlchemy and in the table activity_types

badge_custom_levels#

Custom badge levels for this activity

Type:

collectives.models.badge.BadgeCustomLevel

badges#

Person with a badge with this activity

Type:

collectives.models.user.User

deprecated#

Indicates a deprecated activity type, now replaced by an event type

Kept in the table for backward compatibility, but excluded from activity lists

Type:

bool

email#

Activity dedicated email.

Mail to be used to send notifications to activity leader.

Type:

string

classmethod get(required_id)#

Get the name of the specified activity id

Parameters:

required_id (integer) – the id of the Activity type

Returns:

name of the activity type

Return type:

ActivityType

classmethod get_all_types(include_deprecated: bool = False, include_services: bool = True) list[ActivityType]#

List all activity_types in database

Parameters:

include_deprecated (bool) – Whether to include deprecated activity types

Returns:

list of types

Return type:

list(ActivityType)

classmethod js_values()#

Class method to get all actitivity type as js dict

Returns:

types as js Dictionnary

Return type:

String

kind#

Kind of activity

name#

Activity name.

Type:

string

order#

Order to display this activity

Type:

int

persons#

Person with a role with this activity

Type:

collectives.models.user.User

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

short#

Activity short name.

It is especially used for icon CSS classes.

Type:

string

trigram#

Three-letter code.

Mainly used to identify activity type in payment order references

Type:

string

truncate_string(key, value)#

Truncates a string to the max SQL field length

In contrast to one may naively think, trigrams may be longer than three letters. Make sure the value is truncated before trying to insert it in base

Parameters:
  • key (string) – name of field to validate

  • value (string) – tentative value

Returns:

Truncated string.

Return type:

string

Module collectives.models.auth#

Module to manage authentification model

Example: Account creation tokens. However, User is in module collectives.model.user.

class collectives.models.auth.ConfirmationToken(user_license, existing_user, duration=None)#

Class of a Token

A confirmation token is a way to check the mail address of a user. An UUID is sent to an email address and user has to be able to access the email address to validate the token. Tokens have a limited life duration.

existing_user#

The user to which this token is linked.

existing_user_id#

Associated Id if the token affects an existing account

Type:

int

expiry_date#

Token expiration date

Expiration date is automatically set during token creation, in constructor.

Type:

datetime.datetime

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

status#

Sending status of this token.

Type:

collectives.models.auth.TokenEmailStatus

token_type#

Type of token (account creation, reset, …)

Type:

collectives.models.auth.ConfirmationTokenType

user_license#

License number of relevant user

It is mainly used for account activation where user account does not exists yet. Thus, activation token must remember which user is associated.

Type:

string

uuid#

UUID to indentify the token

Type:

string

class collectives.models.auth.ConfirmationTokenType(*values)#

Enum listing types of token

ActivateAccount = 0#

Token for account activation

RecoverAccount = 1#

Token to recover the lost password of an account

class collectives.models.auth.TokenEmailStatus(*values)#

Enum Status for this token

Failed = 2#

Token has failed during its expedition

Pending = 0#

Token will be sent

Success = 1#

Token has been succesfully sent

Module collectives.models.badge#

Module for user badges related classes

class collectives.models.badge.Badge(**kwargs)#

Badge for a specific user.

These objects are linked to collectives.models.user.User and to a collectives.models.activity_type.ActivityType. A same user can have several badges, including on the same activity type.

Roles are stored in SQL table badges.

activity_id#

ID of the activity to which the badge is applied.

Type:

int

property activity_name#

Returns the name of the corresponding activity

Returns:

name of the corresponding activity

Return type:

string

badge_id#

Type of the badge.

Type:

BadgeIds

creation_time#

Timestamp at which the payment was created

Type:

datetime.datetime

expiration_date#

Date at which this badge will expire

Type:

datetime.date

grantor_id#

User id of person who granted this badge.

Type:

int

id#

Database primary key

Type:

int

is_expired() bool#

Returns True if badge is no longer valid now.

level#

Level of the badge. Depending of the type of badge, might be: level of expertise, nb of absences,…

Type:

int

level_name(short: bool = False, with_activity: bool = False) str#

Returns the name of the badge level.

Parameters:
  • short – if True, returns the short name (abbreviation/emoji)

  • with_activity – if True, includes the activity name in the returned string

Returns:

name of the badge.

property name#

Returns the name of the badge.

Returns:

name of the badge.

Return type:

string

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

registration#

Resgitration associated to this badge.

Type:

collectives.models.registration.Registration

registration_id#

Registration id associated to this badge.

Type:

int

user_id#

ID of the user to which the badge is applied.

Type:

int

class collectives.models.badge.BadgeCustomLevel(**kwargs)#

Model representing a custom badge level.

abbrev#

Abbreviation for the badge level.

Type:

str

activity_id#

ID of the activity to which the level is applicable.

Type:

int

activity_name() str#

Returns the name of the corresponding activity

Returns:

name of the corresponding activity

badge_id#

Type of the badge.

Type:

BadgeIds

default_validity#

Default period of validity (in months) for this badge level.

deprecated#

Whether this custom level is deprecated.

property descriptor: BadgeLevelDescriptor#

Returns the descriptor for this custom level.

classmethod get_all(badge_id: BadgeIds, activity_id: int | None = None, include_deprecated: bool = False) list[BadgeCustomLevel]#

Returns all custom badge level, possibly filtering out deprecated ones.

Parameters:
  • badge_id – badge type to get custom levels for

  • activity_id – if set, filters custom levels to those compatible with this activity

  • include_deprecated – if True, includes deprecated custom badge levels

Returns:

list of custom badge levels

id#

Database primary key

Type:

int

level#

Database primary key

Type:

int

name#

Description of the badge level.

Type:

str

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

truncate_string(key: str, value: str) str#

Truncates a string to the max SQL field length :param key: name of field to validate :param value: tentative value :return: Truncated string.

class collectives.models.badge.BadgeIds(*values)#

Enum listing the type of a badge

Practitioner = 4#

Practitioner level for a given activity.

Skill = 5#

Particular competence.

Suspended = 3#

User has been suspended.

UnjustifiedAbsenceWarning = 2#

User has been issued a warning regarding late unregistrations and unjustified absences.

accepts_activity() bool#

Check if this badge may be associated with an activity.

Returns:

True if the badge may be associated with an activity.

classmethod display_names()#

Display name for all badges

Returns:

badge name

Return type:

string

has_custom_levels(activity_id: int | None = None) bool#

Whether the levels for this badge are user-defined

has_ordered_levels() bool#

Whether the levels for this badge are ordered. I.e, whether having a badge of level N implies having all levels < N.

classmethod js_levels(badge_ids: Iterable[BadgeIds] | None = None, activity_ids: list[int] | None = None, include_deprecated: bool = False) str#

Class method to return levels as js dict

Returns:

levels as js Dictionnary

level(level: int, activity_id: int | None = None) BadgeLevelDescriptor | None#

Returns the descriptor for a given level of this badge.

Parameters:

level – level to get the descriptor for

Returns:

level descriptor, or None if the level does not exist

levels(activity_id: int | None = None, include_deprecated: bool = False, include_defaults: bool = True, only_defaults: bool = False) dict[int, BadgeLevelDescriptor]#

Returns the human-readable levels for this type of badge.

Parameters:
  • include_deprecated – if True, includes deprecated custom badge levels

  • activity_id – if set, filters custom levels to those compatible with this activity

  • include_defaults – if True, includes default levels (if any)

Returns:

dict of levels descriptors

requires_activity() bool#

Check if this badge needs an activity.

Returns:

True if the badge requires an activity.

requires_level() bool#

Whether this badge requires specifying a level.

class collectives.models.badge.BadgeLevelDescriptor(name: str, abbrev: str, activity_id: int | None = None, months_of_validity: int = 0, accepts_activity: bool = True)#

Descriptor for a badge level

abbrev: str#

Abbreviation for the level (or emoji)

accepts_activity: bool = True#

Whether this level accepts being associated with an activity

activity_id: int | None = None#

If not None, the level is only valid for this activity

activity_name() str#

Returns the name of the corresponding activity

Returns:

name of the corresponding activity

expiry_date(from_date: date | None = None) date | None#

Computes the expiry date of this level, if it has a limited validity.

Parameters:

from_date – date from which the validity should be computed (default: today)

Returns:

expiry date, or None if the level has unlimited validity

is_compatible_with_activity(activity_id: int | None) bool#

Check if this level is compatible with the given activity.

Parameters:

activity_id – activity to check compatibility with (or None)

Returns:

True if the level is compatible with the activity

months_of_validity: int = 0#

Number of months this level is valid for, 0 if unlimited

name: str#

Full name of the level

Module collectives.models.event#

Module collectives.models.event_tag#

Module for event tag classes.

class collectives.models.event_tag.EventTag(tag_id)#

Class of an event tag.

An event tag is related to a single event and is defined by a type.

classmethod all(include_deprecated=False) Dict[int, Dict[str, Any]]#

Returns tag dictionnary as defined by EVENT_TAGS in config.

Parameters:

include_deprecated (bool) – Whether to include deprecated activity types

Type:

dict

classmethod choices()#

Returns all tag types formatted for a wtform multiple selection field.

Type:

array

property csv_code: str#

Alternative name of the tag type, to be used in CSV imports

Type:

string

event_id#

Primary key of the event which holds this tag (see collectives.models.event.Event)

Type:

int

property full: Dict[str, Any]#

All information about the tag type.

Type:

dict

classmethod get_type_from_csv_code(csv_code: str) int#
Parameters:

short (string) – CSV code of the searched tag

Returns:

Tag id

classmethod get_type_from_short(short) int#
Parameters:

short (string) – Shortname of the searched tag

Returns:

Tag id

Return type:

int

id#

Event tag unique id.

ID is used as DB primary key

Type:

int

property name: str#

Name of the tag type

Type:

string

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

property short: str#

Short name of the tag type, used as css class

Type:

string

type#

Type of the tag.

Possible values are keys of config EVENT_TAGS.

Type:

collectives.models.event_tag.EventTagTypes

Module collectives.models.globals#

System wide model tools

collectives.models.globals.db = <SQLAlchemy>#

SQL Alchemy object to manipulate DB.

Module collectives.models.payment#

Module collectives.models.question#

Module defining question-related models

class collectives.models.question.Question(**kwargs)#

Database model describing a set of questions

choices#

Possible answers for this question, one per line

type: string

choices_array() List[str]#
Returns:

the list of possible choices for the question

copy(new_event_id: int = None)#

Copy current question.

Returns:

Copied questions

description#

Longer description for this question

Type:

string

enabled#

Whether this question is enabled

Type:

string

event_id#

Key of the event the questionnaire is associated to

Type:

int

id#

Database primary key

Type:

int

static make_choices_array(choices_text: str) List[str]#

Converts choices stored as a single string to an array of individual choices :param choices_text: the string containing one choice per non-empty line :returns: the list of possible choices

order#

Number for ordering questions within a questionnaire

Type:

int

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

question_type#

Type of question

Type:

collectives.models.question.QuestionType

required#

Whether answering this question is required

Type:

string

title#

Subtitle for this question

Type:

string

class collectives.models.question.QuestionAnswer(**kwargs)#

Database model describing a set of questions

id#

Database primary key

Type:

int

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

question_id#

Primary key of the question which is being answered

Type:

int

static user_answers(event_id: int, user_id: int) List[QuestionAnswer]#
Returns:

the list of answers to an event’s questions by a given user

user_id#

Primary key of the user who answered the question

Type:

int

value#

Answer value for non choice-based answers

class collectives.models.question.QuestionType(*values)#

Enumeration listing possible question types

MultipleChoices = 1#

Question with a multiple possible answers among a predefined list

Numeric = 2#

Question with an integer answer

SingleChoice = 0#

Question with a single possible answer among a predefined list

Text = 3#

Question with arbitrary textual answer

YesNo = 5#

Boolean question

classmethod display_names()#
Returns:

a dict defining display names for all enum values

Return type:

dict

Module collectives.models.registration#

Module for registration related classes

class collectives.models.registration.Registration(**kwargs)#

Object linking a user (participant) and an event.

Co-leader are also registering. Leader are not registered to their events.

badges#

List of badges associated to this registration.

Type:

list(collectives.models.badge.Badge)

event_id#
Primary key of the event to which the user is registered (see

collectives.models.event.Event)

Type:

int

holding_index() int#

Returns the chronlogical place this registration has in all holding place registrations. -1 if not active. Starts at 0.

id#

Database primary key

Type:

int

is_active()#

Check if this registation is active.

Returns:

True if status is Active or Present and the user’s license has not expired

Return type:

boolean

is_duplicate() bool#

Check if this registration is the duplicate of another one (an earlier registration exists for the same user)

is_holding_slot()#

Check if this registation is holding a slot.

Returns:

Is status active or pending?

Return type:

boolean

is_in_late_unregistration_period(time: datetime | None = None) bool#
Parameters:

time – Time for which to make the test, defaults to curren time

Returns:

whether unregistering now should be considered “late”

is_overbooked() bool#

Check if the registration is overbooking.

An overbooked registration is:

  • an online registration with more previous Waiting registration
    than online slots
  • or an holding place registration with more previous holding place registration
    than total slots
  • a Waiting registration with more previous Waiting registration
    than Waiting slots
is_pending_payment()#

Check if this registation is pending payment.

Returns:

Is status pending payment ?

Return type:

boolean

is_pending_renewal()#

Check if this registation is pending license renewal.

Returns:

True if the user’s license expires before the end of the event

Return type:

boolean

is_rejected()#

Check if this registation is rejected.

Returns:

Is status rejected ?

Return type:

boolean

is_self#

Whether this is a self-registration (by the user themselves)

Type:

bool

is_unregistered()#

Check if this registation is unregistered.

Returns:

Is status unregistered ?

Return type:

boolean

level#

Level of the participant for this event (normal, co-leader…)

Type:

collectives.models.registration.RegistrationLevels

online_index() int#

Returns the chronological place this registration has in all online and holding slot registrations. -1 if not holding slot and online. Starts at 0.

payments#

List of payments associated to this registration.

Type:

list(collectives.models.payment.Payment)

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

registration_time#

Date of the registration of a user to an event.

Type:

datetime.datetime

status#

Status of the registration (active, rejected…)

Type:

collectives.models.registration.RegistrationStatus

unsettled_payments()#

Returns the list of unsettled payments associated to this registration

Returns:

The list of payments with ‘Initiated’ status

Return type:

list[collectives.modes.payment.Payment]

user_id#

Primary key of the registered user (see collectives.models.user.User)

Type:

int

valid_transitions()#
Returns:

The list of all achievable transitions from the current status

Return type:

list[collectives.models.registration.RegistrationStatus]

waiting_index() int#

Returns the chronological place this registration has in waiting registrations. -1 if not waiting. Starts at 0.

class collectives.models.registration.RegistrationLevels(*values)#

Enum listing acceptable registration levels.

A registration level is type of event participant, such as a co-leader or a regular participant.

CoLeader = 1#

Participant that will help the event leader.

Normal = 0#

Normal participant, no specific power.

classmethod display_names()#
Returns:

a dict defining display names for all enum values

Return type:

dict

class collectives.models.registration.RegistrationStatus(*values)#

Enum listing acceptable registration status.

Active = 0#

Registered user is planned to be present.

JustifiedAbsentee = 4#

User has been absent to the event, but excused by the leader.

LateSelfUnregistered = 8#

User has self unregister to the event, but late.

PaymentPending = 2#

User has initiated but not yet completed payment

This registration is temporarily holding up a spot, but may be removed after timeout

Present = 7#

User has been present to the event.

Rejected = 1#

Registered user has been rejected by a leader.

A rejected user shall not be counted in occupied slots, nor be able to register again

SelfUnregistered = 3#

User has self unregister to the event.

User should not be able to register again without leader help.

ToBeDeleted = 99999#

Registration should be deleted. This is not a valid SQL enum entry and should only be used as a temporary marker

UnJustifiedAbsentee = 5#

User has been absent to the event, but not excused by the leader.

Waiting = 6#

User is in waiting list.

classmethod display_names()#
Returns:

a dict defining display names for all enum values

Return type:

dict

is_valid()#

Checks if registration is valid, ie active or present

Returns:

True or False

Return type:

bool

classmethod sanctioned_statuses() List[RegistrationStatus]#

Returns the list of status thay may trigger sanctions

classmethod transition_table(requires_payment)#
Returns:

a dict defining possible transitions for all enum values

Parameters:

requires_payment (bool) – whether this is a paid event.

Return type:

dict

classmethod valid_status() List[RegistrationStatus]#

Returns the list of registration status considered as valid.

See collectives.models.registration.RegistrationStatus.is_valid()

valid_transitions(requires_payment)#
Returns:

The list of all achievable transitions for a given status (excluding itself)

Parameters:

requires_payment (bool) – whether this is a paid event.

Return type:

list[collectives.models.registration.RegistrationStatus]

Module collectives.models.role#

Module for user roles related classes

class collectives.models.role.Role(**kwargs)#

Role for a specific user.

These objects are linked to collectives.models.user.User and sometimes to a collectives.models.activity_type.ActivityType. A same user can have several roles.

Roles are stored in SQL table roles.

activity_id#

ID of the activity to which the role is applied.

Is null if the role is global.

Type:

int

id#

Database primary key

Type:

int

property name: str#

Returns the name of the role.

Returns:

name of the role.

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

role_id#

Type of the role.

Type:

RoleIds

user_id#

ID of the user to which the role is applied.

Type:

int

class collectives.models.role.RoleIds(*values)#

Enum listing the type of a role

Global roles are not related to an activity and are website wide:

  • Moderator

  • Administrator

  • President

  • Technician

  • Hotline

  • Accountant

  • Staff

Activity related roles: - EventLeader: can lead an event of this activity type - ActivitySupervisor: supervises a whole activity - Trainee: Currently training to become a leader for an activity - ActivityStaff: can create event types that do not require leader

classmethod all_activity_leader_roles() List[RoleIds]#
Returns:

List of all roles that allow users to lead event activities

classmethod all_activity_organizer_roles() List[RoleIds]#
Returns:

List of all roles that allow users to organize events with an activity

classmethod all_equipment_management_roles() List[RoleIds]#
Returns:

List of all roles that allow users manage equipment

classmethod all_event_creator_roles() List[RoleIds]#
Returns:

List of all roles that allow users to create events

Return type:

list[RoleIds]

classmethod all_moderator_roles() List[RoleIds]#
Returns:

List of all roles that grant moderator capabilities

classmethod all_relates_to_activity() List[RoleIds]#
Returns:

List of all roles that are related to an activity.

classmethod all_reservation_creator_roles() List[RoleIds]#
Returns:

List of all roles that allow users to create reservation

Return type:

list[RoleIds]

classmethod all_reservation_management_roles() List[RoleIds]#
Returns:

List of all roles that allow users manage reservation

Return type:

list[RoleIds]

classmethod all_supervisor_manageable() List[RoleIds]#
Returns:

List of all roles that can be managed by an activity supervisor.

description()#

Display name of the current value

Returns:

name of the instance

Return type:

string

classmethod descriptions() Dict[RoleIds, str]#

Description for all roles

Returns:

dictionnary role -> role name

classmethod display_names() Dict[RoleIds, str]#

Display names for all rolesrole

Returns:

dictionnary role -> role name

relates_to_activity() bool#

Check if this role needs an activity.

See RoleIds Global roles vs Event related roles.

Returns:

True if the role requires an activity.

Module collectives.models.upload#

Module for file upload related classes

collectives.models.upload.THUMBNAIL_HEIGHT = 480#

Default height in pixels for image thumbnails

collectives.models.upload.THUMBNAIL_WIDTH = 640#

Default width in pixels for image thumbnails

class collectives.models.upload.UploadedFile(**kwargs)#

User-uploaded file.

For now, each uploaded file is linked to an event. This may change in the future

activity#

Activity to which this file belong. May be null

Type:

collectives.models.event.Event

activity_id#

Primary key of the activity to which this file belong

Type:

int

date#

Upload date

Type:

datetime.datetime

delete_file()#

Deletes the on-disk file

event#

Event to which this file belongs. May be null

Type:

collectives.models.event.Event

event_id#

Primary key of the event to which this file belong

Type:

int

full_path()#
Returns:

the full on-disk file path

Return type:

string

has_edit_rights(user: User)#

Checks whether an user has edit rights on this file

  • if the file is associated to an activity, user needs to be a supervisor

  • if the file is associated to an event, user needs edit rights on event

  • if the file is unassociated, user needs to have uploaded it

Parameters:

user (collectives.models.User) – user to check

Returns:

whether the user has edit rights

Return type:

bool

id#

Upload unique id.

Type:

int

is_image()#

Checks if this file is an image

Returns:

True if extension is in flask_uploads.IMAGES

name#

Original file name

Type:

string

path#

On-disk path

Type:

string

static purge_old_uploads(current_session_id: int, days: int = 1)#

Removes uploaded files from temporary sessions that where never attached to an event

Parameters:
  • current_session_id (int) – Id of current editing session, or None. Files from the current editing session will not be purged.

  • days (int) – Number of days since upload to consider purging the file

query: t.ClassVar[Query]#

A SQLAlchemy query for a model. Equivalent to db.session.query(Model). Can be customized per-model by overriding query_class.

Warning

The query interface is considered legacy in SQLAlchemy. Prefer using session.execute(select()) instead.

save_file(file)#

Save from a raw file

Parameters:

file (werkzeug.datastructures.FileStorage) – The direct output of a FileInput

session_id#

If the upload is not associated to an event yet, id of the edit session

Type:

string

size#

Size, in bytes

Type:

Integer

thumbnail_url(width: int = 640, height: int = 480)#

If this file is an image, returns its thumbnail URL

Parameters:
  • width (int, optional) – max width of the thumbnail in pixels, defaults to THUMBNAIL_WIDTH

  • height (int, optional) – max height of the thumnail in pixels, defaults to THUMBNAIL_HEIGHT

Returns:

The thumbnail URL or None if not an image

Return type:

int

url()#
Returns:

the static URL for an uploaded file

Return type:

str

user#

User who uploaded this file

Type:

collectives.models.user.User

user_id#

Primary key of the user who uploaded this file

Type:

int

validate_filename(key, value)#

Makes a file name secure and truncates it to the max SQL field length :param string key: name of field to validate :param string value: tentative value :return: Truncated file name. :rtype: string

collectives.models.upload.documents = <flask_uploads.UploadSet object>#

Upload instance for documents

Type:

flask_uploads.UploadSet

Module collectives.models.user#

Module collectives.models.user_group#

Module collectives.models.utils#

Set utils classes for models

class collectives.models.utils.ChoiceEnum(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)#

Enum with additionnal methods which is easy to get lists from.

classmethod choices()#

Class method to get all choices

Returns:

list of Tuple with all choices as (id, name)

Return type:

Array

classmethod coerce(item)#

Check if an item if part the Enum

Parameters:

item – Item to check if it is in the Enum

Returns:

if item is part of the Enum

Return type:

boolean

display_name()#

Display name of the current value

Returns:

name of the instance

Return type:

string

classmethod js_keys() List[str]#

Class method to cast Enum keys as js dict

Returns:

JSON representation of enum keys dict

classmethod js_values()#

Class method to cast Enum as js dict

Returns:

enum as js Dictionnary

Return type:

String