AccountContact View

AccountContact views for smarter api.

class smarter.apps.account.api.v1.views.account_contact.AccountContactListView(*args, **kwargs)[source]

Bases: ContractListMixin, AccountListViewBase

AccountContact list view for smarter api: AccountApiContact models.

contract_model

alias of AccountApiContact

get_queryset()[source]

Return every AccountContact for a superuser, else those of the user’s Account.

Returns:

The queryset, ordered by pk; empty for an anonymous request.

serializer_class

alias of AccountContactSerializer

class smarter.apps.account.api.v1.views.account_contact.AccountContactView(*args, **kwargs)[source]

Bases: AccountViewBase

AccountContact view for smarter api.

Its GET returns an AccountApiContact.

account_contact: AccountContact
delete(request, account_contact_id)[source]

Delete an AccountContact, and the AccountContact of the request user, in one transaction.

The request user’s AccountContact is the one in the same account with the user’s email. When there is none, nothing is deleted.

Parameters:
  • request – The request.

  • account_contact_id (int) – The AccountContact’s id.

Returns:

A redirect to the parent url, a 404 response when the request user has no AccountContact in the account, or a 500 response when the delete fails.

Raises:

Http404 – when the AccountContact does not exist, or is another account’s.

get(request, account_contact_id)[source]

Return an AccountContact as json.

Parameters:
  • request (Request) – The request.

  • account_contact_id (int) – The AccountContact’s id.

Returns:

The AccountApiContact of the AccountContact.

Raises:

Http404 – when the AccountContact does not exist, or is another account’s.

patch(request, account_contact_id=None)[source]

Refuse to update an AccountContact: this endpoint does not support it.

Parameters:
  • request (Request) – The request.

  • account_contact_id (int | None) – Unused.

Returns:

A 400 response.

post(request)[source]

Refuse to create an AccountContact: this endpoint does not support it.

Parameters:

request (Request) – The request.

Returns:

A 400 response.

serializer_class

alias of AccountContactSerializer

smarter.apps.account.api.v1.views.account_contact.readable_contacts(request, user_profile)[source]

Return the AccountContacts that the request’s user may see and change.

A superuser may see every AccountContact, anyone else only those of their own account.

Parameters:
  • request (Request | None) – The request.

  • user_profile (UserProfile | None) – The request user’s profile.

Return type:

QuerySet[AccountContact]

Returns:

The AccountContacts, ordered by pk; none for an anonymous request.