Views¶
Hordak provides a number of off-the-shelf views to aid in development. You may need to implement your own version of (or extend) these views in order to provide customised functionality.
Extending views¶
To extend a view you will need to ensure Django loads it by updating your urls.py file.
To do this, alter you current urls.py:
# Replace this
urlpatterns = [
...
url(r'^', include('hordak.urls', namespace='hordak'))
]
And changes it as follows, copying in the patterns from hordak’s root urls.py:
# With this
from hordak import views as hordak_views
hordak_urls = [
... patterns from Hordak's root urls.py ...
]
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^', include(hordak_urls, namespace='hordak', app_name='hordak')),
...
]
Accounts¶
AccountListView¶
AccountCreateView¶
- class hordak.views.AccountCreateView(**kwargs)¶
View for creating accounts
Examples
urlpatterns = [ ... url(r'^accounts/create/$', AccountCreateView.as_view(success_url=reverse_lazy('accounts_list')), name='accounts_create'), ]
- form_class¶
alias of
AccountForm
- template_name = 'hordak/accounts/account_create.html'¶
- success_url = '/'¶
AccountUpdateView¶
- class hordak.views.AccountUpdateView(**kwargs)¶
View for updating accounts
Note that
hordak.forms.AccountFormprevents updating of thecurrencyandtypefields. Also note that this view expects to receive the Account’suuidfield in the URL (see example below).Examples
urlpatterns = [ ... url(r'^accounts/update/(?P<uuid>.+)/$', AccountUpdateView.as_view(success_url=reverse_lazy('accounts_list')), name='accounts_update'), ]
- form_class¶
alias of
AccountForm
- template_name = 'hordak/accounts/account_update.html'¶
- slug_field = 'uuid'¶
- slug_url_kwarg = 'uuid'¶
- context_object_name = 'account'¶
- success_url = '/'¶
AccountTransactionView¶
- class hordak.views.AccountTransactionsView(**kwargs)¶
- template_name = 'hordak/accounts/account_transactions.html'¶
- slug_field = 'uuid'¶
- slug_url_kwarg = 'uuid'¶
- get(request, *args, **kwargs)¶
- get_object(queryset=None)¶
Return the object the view is displaying.
Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.
- get_context_object_name(obj)¶
Get the name to use for the object.
- get_queryset()¶
Return the QuerySet that will be used to look up the object.
This method is called by the default implementation of get_object() and may not be called if get_object() is overridden.
Transactions¶
TransactionCreateView¶
- class hordak.views.TransactionCreateView(**kwargs)¶
View for creation of simple transactions.
This functionality is provided by
hordak.models.Account.transfer_to(), see the method’s documentation for additional details.Examples
urlpatterns = [ ... url(r'^transactions/create/$', TransactionCreateView.as_view(), name='transactions_create'), ]
- form_class¶
alias of
SimpleTransactionForm
- success_url = '/'¶
- template_name = 'hordak/transactions/transaction_create.html'¶
TransactionsReconcileView¶
- class hordak.views.TransactionsReconcileView(**kwargs)¶
Handle rendering and processing in the reconciliation view
Note that this only extends ListView, and we implement the form processing functionality manually.
Examples
urlpatterns = [ ... url(r'^transactions/reconcile/$', TransactionsReconcileView.as_view(), name='transactions_reconcile'), ]
- template_name = 'hordak/transactions/reconcile.html'¶
- model¶
alias of
StatementLine
- paginate_by = 50¶
- context_object_name = 'statement_lines'¶
- ordering = ['-date', '-pk']¶
- success_url = '/'¶