# Index EcoAccount refactoring
* refactors index view for eco account
This commit is contained in:
parent
21bb988d86
commit
67acddf701
@ -8,8 +8,8 @@ Created on: 24.08.21
|
||||
from django.urls import path
|
||||
|
||||
from compensation.autocomplete.eco_account import EcoAccountAutocomplete
|
||||
from compensation.views.eco_account.eco_account import index_view, new_view, new_id_view, edit_view, remove_view, \
|
||||
detail_view
|
||||
from compensation.views.eco_account.eco_account import new_view, new_id_view, edit_view, remove_view, \
|
||||
detail_view, EcoAccountIndexView
|
||||
from compensation.views.eco_account.log import EcoAccountLogView
|
||||
from compensation.views.eco_account.record import EcoAccountRecordView
|
||||
from compensation.views.eco_account.report import report_view
|
||||
@ -28,7 +28,7 @@ from compensation.views.eco_account.deduction import NewEcoAccountDeductionView,
|
||||
|
||||
app_name = "acc"
|
||||
urlpatterns = [
|
||||
path("", index_view, name="index"),
|
||||
path("", EcoAccountIndexView.as_view(), name="index"),
|
||||
path('new/', new_view, name='new'),
|
||||
path('new/id', new_id_view, name='new-id'),
|
||||
path('<id>', detail_view, name='detail'),
|
||||
|
||||
@ -7,7 +7,7 @@ Created on: 19.08.22
|
||||
"""
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.db.models import Sum
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpRequest, JsonResponse
|
||||
from django.shortcuts import get_object_or_404, redirect, render
|
||||
from django.urls import reverse
|
||||
@ -24,36 +24,20 @@ from konova.settings import ETS_GROUP, DEFAULT_GROUP, ZB_GROUP
|
||||
from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
||||
from konova.utils.message_templates import CANCEL_ACC_RECORDED_OR_DEDUCTED, RECORDED_BLOCKS_EDIT, FORM_INVALID, \
|
||||
IDENTIFIER_REPLACED, DO_NOT_FORGET_TO_SHARE, GEOMETRY_SIMPLIFIED, GEOMETRIES_IGNORED_TEMPLATE
|
||||
from konova.views.base import BaseIndexView
|
||||
|
||||
|
||||
@login_required
|
||||
@any_group_check
|
||||
def index_view(request: HttpRequest):
|
||||
"""
|
||||
Renders the index view for eco accounts
|
||||
class EcoAccountIndexView(LoginRequiredMixin, BaseIndexView):
|
||||
_INDEX_TABLE_CLS = EcoAccountTable
|
||||
_TAB_TITLE = _("Eco-account - Overview")
|
||||
|
||||
Args:
|
||||
request (HttpRequest): The incoming request
|
||||
|
||||
Returns:
|
||||
A rendered view
|
||||
"""
|
||||
template = "generic_index.html"
|
||||
eco_accounts = EcoAccount.objects.filter(
|
||||
deleted=None,
|
||||
).order_by(
|
||||
"-modified__timestamp"
|
||||
)
|
||||
table = EcoAccountTable(
|
||||
request=request,
|
||||
queryset=eco_accounts
|
||||
)
|
||||
context = {
|
||||
"table": table,
|
||||
TAB_TITLE_IDENTIFIER: _("Eco-account - Overview"),
|
||||
}
|
||||
context = BaseContext(request, context).context
|
||||
return render(request, template, context)
|
||||
def _get_queryset(self):
|
||||
qs = EcoAccount.objects.filter(
|
||||
deleted=None,
|
||||
).order_by(
|
||||
"-modified__timestamp"
|
||||
)
|
||||
return qs
|
||||
|
||||
|
||||
@login_required
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user