Replaced the function-based txn_detail() view with the class-based TransactionView view in the accounting application.
This commit is contained in:
parent
908fbedf0d
commit
f29e939de3
@ -81,7 +81,7 @@ urlpatterns = [
|
|||||||
path("transactions/<txn-type:txn_type>/store",
|
path("transactions/<txn-type:txn_type>/store",
|
||||||
views.txn_store, name="transactions.store"),
|
views.txn_store, name="transactions.store"),
|
||||||
path("transactions/<txn-type:txn_type>/<txn:txn>",
|
path("transactions/<txn-type:txn_type>/<txn:txn>",
|
||||||
views.txn_detail, name="transactions.detail"),
|
views.TransactionView.as_view(), name="transactions.detail"),
|
||||||
path("transactions/<txn-type:txn_type>/<txn:txn>/edit",
|
path("transactions/<txn-type:txn_type>/<txn:txn>/edit",
|
||||||
views.txn_edit, name="transactions.edit"),
|
views.txn_edit, name="transactions.edit"),
|
||||||
path("transactions/<txn-type:txn_type>/<txn:txn>/update",
|
path("transactions/<txn-type:txn_type>/<txn:txn>/update",
|
||||||
|
@ -799,22 +799,18 @@ def search(request):
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@require_GET
|
@method_decorator(require_GET, name="dispatch")
|
||||||
@login_required
|
@method_decorator(login_required, name="dispatch")
|
||||||
def txn_detail(request, txn_type, txn):
|
class TransactionView(DetailView):
|
||||||
"""The view of the details of an accounting transaction.
|
"""The view of the details of an accounting transaction."""
|
||||||
|
context_object_name = "txn"
|
||||||
|
|
||||||
Args:
|
def get_object(self, queryset=None):
|
||||||
request (HttpRequest): The request.
|
return self.request.resolver_match.kwargs["txn"]
|
||||||
txn_type (str): The transaction type.
|
|
||||||
txn (Transaction): The transaction.
|
|
||||||
|
|
||||||
Returns:
|
def get_template_names(self):
|
||||||
HttpResponse: The response.
|
return ["accounting/transactions/%s/detail.html"
|
||||||
"""
|
% (self.request.resolver_match.kwargs["txn_type"],)]
|
||||||
return render(request, F"accounting/transactions/{txn_type}/detail.html", {
|
|
||||||
"txn": txn,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
@require_GET
|
@require_GET
|
||||||
|
Loading…
Reference in New Issue
Block a user