rattail.db.model.core

Core Data Models

class rattail.db.model.core.ModelBase[source]

Base class for all data models.

model_title

Optionally set this to a “humanized” version of the model name, for display in templates etc. Default value will be guessed from the model class name, e.g. ‘Product’ => “Products” and ‘CustomerOrder’ => “Customer Order”.

model_title_plural

Optionally set this to a “humanized” version of the plural model name, for display in templates etc. Default value will be guessed from the model class name, e.g. ‘Product’ => “Products” and ‘CustomerOrder’ => “Customer Orders”.

class rattail.db.model.core.Setting(**kwargs)[source]

Represents a “raw” config setting stored within the database.

class rattail.db.model.core.Change(**kwargs)[source]

Represents a changed (or deleted) record, which is pending synchronization to another database.

instance_uuid

Key for the object which was changed/etc. In most cases this will simply be the object’s UUID value, hence the column name. However in some cases it may contain something else; this is often needed in order to properly sync deletions to non-rattail systems, where the UUID is meaningless.

object_key

Synonym to the instance_uuid column. New code should perhaps reference the attribute by this (object_key) name instead, as the instance_uuid column may be renamed at some point, to this name.

uuid

UUID primary key for the table.

Data Models for Contact Info

class rattail.db.model.contact.ContactMixin[source]

Mixin which provides some useful methods for “contact” models, i.e. those which can play “parent” to email, phone and address records.

add_address(**kwargs)[source]

Add a new “address” record to the contact.

add_email(**kwargs)[source]

Add a new “email” record to the contact.

add_phone(**kwargs)[source]

Add a new “phone” record to the contact.

first_address(**kwargs)[source]

Return the first available address record for the contact.

first_email(invalid=False, **kwargs)[source]

Return the first available email record for the contact.

Parameters:

invalid – If true, then this may return an email marked invalid; if false then only valid email will be returned.

first_email_address(invalid=False, **kwargs)[source]

Return the first available email address for the contact.

first_phone(**kwargs)[source]

Return the first available phone record for the contact.

first_phone_number(**kwargs)[source]

Return the first available phone number for the contact.

make_address(**kwargs)[source]

Make a new “address” record for the contact.

make_email(**kwargs)[source]

Make a new “email” record for the contact.

make_phone(**kwargs)[source]

Make a new “phone” record for the contact.

remove_address(address, **kwargs)[source]

Remove the given address record from the contact.

remove_email(email, **kwargs)[source]

Remove the given email record from the contact.

remove_phone(phone, **kwargs)[source]

Remove the given phone record from the contact.

set_primary_address(address, flush=True)[source]

Will re-arrange the contact’s address records as needed to ensure that the given address record is “primary” - i.e. first in the list.

set_primary_email(email, flush=True)[source]

Will re-arrange the contact’s email records as needed to ensure that the given email record is “primary” - i.e. first in the list.

set_primary_phone(phone, flush=True)[source]

Will re-arrange the contact’s phone records as needed to ensure that the given phone record is “primary” - i.e. first in the list.

class rattail.db.model.contact.EmailAddress(**kwargs)[source]

Represents an email address associated with a contactable entity.

invalid

Flag indicating whether the email address is known to be invalid. Defaults to NULL, meaning the validity is “not known”.

uuid

UUID primary key for the table.

class rattail.db.model.contact.MailingAddress(**kwargs)[source]

Represents a physical / mailing address associated with a contactable entity.

uuid

UUID primary key for the table.

class rattail.db.model.contact.PhoneNumber(**kwargs)[source]

Represents a phone (or fax) number associated with a contactable entity.

uuid

UUID primary key for the table.

Todo

Geez a lot of work left here…