Account
Account views for smarter api.
- class smarter.apps.account.api.v1.views.account.AccountListView(*args, **kwargs)[source]
Bases:
ContractListMixin,AccountListViewBaseAccount list view for smarter api:
AccountApiAccountDetailmodels.- contract_model
alias of
AccountApiAccountDetail
- class smarter.apps.account.api.v1.views.account.AccountView(*args, **kwargs)[source]
Bases:
AccountViewBaseAccount view for smarter api.
Its
GETreturns anAccountApiAccountDetail.- delete(request, account_id)[source]
Delete an Account.
- Parameters:
request – The request.
account_id (
int) – The Account’s id.
- Returns:
A redirect to
/, or a 500 response when the delete fails.- Raises:
Http404 – when the Account does not exist.
- get(request, account_id)[source]
Return an Account as json.
- Parameters:
request (
Request) – The request.account_id (
int) – The Account’s id. Only a superuser may read another Account; anyone else gets the Account of their own UserProfile.
- Returns:
The
AccountApiAccountDetailof the Account.- Raises:
PermissionDenied – when a non-superuser has no UserProfile.
- patch(request, account_id)[source]
Update an Account’s fields from the json dict in the request body, and save it.
Keys that are not attributes of the Account are ignored.
- Parameters:
request (
Request) – The request, whose body holds the fields to change.account_id (
int) – The Account’s id.
- Returns:
The response: 404 when the Account does not exist, 400 when the body or the new values are not valid.