Main resources¶
VosaeCustomer¶
- class core.models.VosaeCustomer(*args, **values)¶
The VosaeCustomer represent the customer organization in the Vosae’s SaaS environnement.
- class Address(*args, **kwargs)¶
An address wrapper which can be embedded in any object.
- static concat_fields(field1, field2)¶
Method used in the get_formatted() method to concatenate fields like state and country.
- get_formatted()¶
Returns a concatenated list of Address attributes:
- Street address
- Extended address, post office box
- Postal code, City
- State, Country
- VosaeCustomer.delete(force=False, cascade=True, *args, **kwargs)¶
Secure hook to delete customers.
Parameters: - force – security, must explicitely set force to True to confirm deletion
- cascade – also deletes all linked documents, default to True
- classmethod VosaeCustomer.post_save(sender, document, created, **kwargs)¶
If created, the VosaeCustomer should be initialized.
- classmethod VosaeCustomer.pre_save(sender, document, **kwargs)¶
If the slug does not exists (eg. on creation), it is generated.
- classmethod VosaeCustomer.pre_save_post_validation(sender, document, **kwargs)¶
The VosaeCustomer is associated to a Django group. If the group doesn’t exist, it is created.
- class core.api.resources.VosaeCustomerResource(api_name=None)¶
- full_hydrate(bundle)¶
Handle specific fields (supported_currencies/default_currency) on creation
- get_object_list(request)¶
Filters associated customers
- obj_create(bundle, **kwargs)¶
Some mandatory actions shoud be synchrounous after VosaeCustomer creation but before returning the response and should not be in post_save hooks since issuer is required (got from request).
These actions are:
- Adding the creator to the Django group (represents the VosaeCustomer)
- Creation of the VosaeUser linked to the customer
- Initial data filling
VosaeGroup¶
- class core.models.VosaeGroup(*args, **values)¶
A group to organize VosaeCustomer‘s permissions.
- delete(force=False, *args, **kwargs)¶
Prevent deletion of the “admin” group. It is immutable by default.
- classmethod post_delete(sender, document, **kwargs)¶
Post delete hook handler
- De-index group from elasticsearch
- classmethod post_save(sender, document, **kwargs)¶
Post save hook handler
- Refresh all related VosaeUser permissions. Occurs in a delayed task.
- Index group in elasticsearch
- classmethod pre_save(sender, document, **kwargs)¶
Pre save hook handler
- Refresh group’s permissions cache
- save(force=False, *args, **kwargs)¶
Prevent save of the “admin” group. It is immutable by default.
VosaeUser¶
- class core.models.VosaeUser(*args, **values)¶
A user class linking VosaeCustomer to Django’s user in our SaaS environnement.
- has_perm(perm)¶
True if the VosaeUser has the specified permission and if the VosaeCustomer has the corresponding subscription active.
- photo_uri¶
Return the photo URI (if available).
- classmethod post_delete(sender, document, **kwargs)¶
Post delete hook handler
- Removes the django user from the django group
- De-index user from elasticsearch
- classmethod post_save(sender, document, created, **kwargs)¶
Post save hook handler
- Initialize user on creation
- Index user in elasticsearch
- classmethod pre_save(sender, document, **kwargs)¶
Merge groups and own permissions and refresh cache
- class core.api.resources.VosaeUserResource(api_name=None)¶
- dehydrate_permissions(bundle)¶
Returns the list of acquired permissions
- hydrate_email(bundle)¶
Email can only be used on POST (creation) in order to link the VosaeUser to the Django user.
- obj_create(bundle, **kwargs)¶
Fills initial data (based on request’s language) after VosaeUser creation
VosaeFile¶
- class core.models.VosaeFile(*args, **values)¶
A wrapper for a file stored through django-storages.
- download_link¶
Returns the download link.
Has the ‘attachment’ header, which forces download.
- classmethod pre_delete(sender, document, **kwargs)¶
Pre delete hook handler
- Process deletion of the GridFS file before the wrapper.
- classmethod pre_save(sender, document, **kwargs)¶
Pre save hook handler.
- Retrieve uploaded_file. If set on instanciation, present in _data, else present as attribute
- Compute SHA1 checksum, extract content-type, size, name
- Saves on storage backend