Views¶
Contents
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 copy in the URLs from hordak.urls (GitHub) you wish to modify.
# With this
urlpatterns = [
...
url(r'^transactions/create/$', MyCustomTransactionCreateView.as_view(), name='transactions_create'),
url(r'^', include('hordak.urls', namespace='hordak'))
]
Accounts¶
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= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
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'), ]
-
model¶ alias of
Account
-
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= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
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= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-
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= <django.utils.functional.lazy.<locals>.__proxy__ object>¶
-