Journal API Views
Smarter Journal api views.
They are mounted at /api/v1/journal/, and only superusers may call them: a journal entry’s
documents hold every user’s content, e.g. prompts and manifests. Each read is
signaled, with smarter.lib.journal.signals.journal_entry_accessed or
smarter.lib.journal.signals.journal_entries_listed.
- class smarter.lib.journal.api.v1.views.SAMJournalListView(*args, **kwargs)[source]
Bases:
SmarterAdminListAPIViewOne page of the journal entries, newest first, without their request and response documents.
The response is a
SAMJournalApiPage. The query parameterspage,page_size,searchandorderingare those ofsmarter.lib.django.pagination.paginate_listview(). A search matches an entry’s key, thing or command.- get_queryset()[source]
Return every journal entry with its user, newest first, without its documents.
- Return type:
- list(request, *args, **kwargs)[source]
Return one page of the journal entries, and a description of the page.
Sends the
journal_entries_listedsignal.- Parameters:
request (
Request) – The request, whose query parameters choose the page, search and ordering.args – Unused.
kwargs – Unused.
- Returns:
A
SAMJournalApiPage, as JSON.
- serializer_class
alias of
SAMJournalMiniSerializer
- class smarter.lib.journal.api.v1.views.SAMJournalView(*args, **kwargs)[source]
Bases:
SmarterAdminAPIViewA journal entry, by its key, with its request and response documents: a
SAMJournalApiEntry.- get(request, key, *args, **kwargs)[source]
Return the journal entry, and send the
journal_entry_accessedsignal.- Parameters:
request (
Request) – The request.key (
str) – The journal entry’s key.args – Unused.
kwargs – Unused.
- Returns:
The entry as a
SAMJournalApiEntrydict.- Raises:
Http404 – If there is no entry with this key.
- post(request, key, *args, **kwargs)[source]
Same as
get(): Smarter detail views are also served by POST.- Parameters:
request (
Request) – The request.key (
str) – The journal entry’s key.args – Unused.
kwargs – Unused.
- Returns:
The entry as a
SAMJournalApiEntrydict.- Raises:
Http404 – If there is no entry with this key.
- serializer_class
alias of
SAMJournalSerializer
- smarter.lib.journal.api.v1.views.SEARCH_FIELDS = ('key', 'thing', 'command')
The fields that a search of the list matches.
('key', 'thing', 'command')
- smarter.lib.journal.api.v1.views.SORT_FIELDS = {'command': 'command', 'createdAt': 'created_at', 'statusCode': 'status_code', 'thing': 'thing', 'user': 'user__username'}
The columns that the list may be sorted by.
See
smarter.lib.django.pagination.DEFAULT_SORT_FIELDS.{ 'command': 'command', 'createdAt': 'created_at', 'statusCode': 'status_code', 'thing': 'thing', 'user': 'user__username', }
- smarter.lib.journal.api.v1.views.journal_entries()[source]
Return every journal entry, newest first, with its user.
- Return type:
- Returns:
The journal entries, with each entry’s user fetched in the same query.
URL configuration for the Smarter Journal api.
These are mounted at /api/v1/journal/. See smarter.lib.journal.api.v1.views.