jerrycan.db package¶
Submodules¶
jerrycan.db.ApiKey module¶
- class jerrycan.db.ApiKey.ApiKey(**kwargs)¶
Bases:
jerrycan.db.IDModelMixin.IDModelMixin
,sqlalchemy.orm.decl_api.Model
Model that describes the ‘api_keys’ SQL table An ApiKey is used for API access using HTTP basic auth
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- creation_time: int¶
The time at which this API key was created as a UNIX timestamp
- has_expired() bool ¶
Checks if the API key has expired. API Keys expire after 30 days :return: True if the key has expired, False otherwise
- id¶
The ID is the primary key of the table and increments automatically
- key_hash: str¶
The hash of the API key
- user: jerrycan.db.User.User¶
The user associated with this API key
- user_id: int¶
The ID of the user associated with this API key
- verify_key(key: str) bool ¶
Checks if a given key is valid :param key: The key to check :return: True if the key is valid, False otherwise
jerrycan.db.IDModelMixin module¶
- class jerrycan.db.IDModelMixin.IDModelMixin¶
Bases:
jerrycan.db.ModelMixin.ModelMixin
A mixin class that specifies a couple of methods all database models should implement. Includes an automatically incrementing ID.
- id = Column(None, Integer(), table=None, primary_key=True, nullable=False)¶
The ID is the primary key of the table and increments automatically
jerrycan.db.ModelMixin module¶
- class jerrycan.db.ModelMixin.ModelMixin¶
Bases:
object
A mixin class that specifies a couple of methods all database models should implement. Does not include an automatically incrementing ID.
jerrycan.db.TelegramChatId module¶
- class jerrycan.db.TelegramChatId.TelegramChatId(**kwargs)¶
Bases:
jerrycan.db.IDModelMixin.IDModelMixin
,sqlalchemy.orm.decl_api.Model
Model that describes the ‘telegram_chat_ids’ SQL table Maps telegram chat ids to users
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- chat_id: str¶
The telegram chat ID
- id¶
The ID is the primary key of the table and increments automatically
- send_message(message_text: str)¶
Sends a message to the telegram chat :param message_text: The message text to send :return: None
- user: jerrycan.db.User.User¶
The user associated with this telegram chat ID
- user_id: int¶
The ID of the user associated with this telegram chat ID
jerrycan.db.User module¶
- class jerrycan.db.User.User(**kwargs)¶
Bases:
jerrycan.db.IDModelMixin.IDModelMixin
,sqlalchemy.orm.decl_api.Model
Model that describes the ‘users’ SQL table A User stores a user’s information, including their email address, username and password hash
- __init__(**kwargs)¶
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs
.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- api_keys: List[ApiKey]¶
API keys for this user
- confirmation_hash: str¶
The account’s confirmation hash. This is the hash of a key emailed to the user. Only once the user follows the link in the email containing the key will their account be activated
- confirmed: bool¶
The account’s confirmation status. Logins should be impossible as long as this value is False.
- email: str¶
The user’s email address
- get_id() str ¶
Method required by flask-login :return: The user’s ID as a unicode string
- id¶
The ID is the primary key of the table and increments automatically
- property is_active: bool¶
Property required by flask-login :return: True
- property is_anonymous: bool¶
Property required by flask-login :return: True if the user is not confirmed, False otherwise
- property is_authenticated: bool¶
Property required by flask-login :return: True if the user is confirmed, False otherwise
- password_hash: str¶
The user’s hashed password, salted and hashed.
- telegram_chat_id: Optional[TelegramChatId]¶
Telegram chat ID for the user if set up
- username: str¶
The user’s username
- verify_confirmation(confirmation_key: str) bool ¶
Verifies a confirmation key against the confirmation hash :param confirmation_key: The key to check :return: True if the key matches, False otherwise
- verify_password(password: str) bool ¶
Verifies a password against the password hash :param password: The password to check :return: True if the password matches, False otherwise