WIP: 490_View_refactoring #491
@ -17,13 +17,13 @@ from compensation.views.compensation.action import NewCompensationActionView, Ed
|
|||||||
RemoveCompensationActionView
|
RemoveCompensationActionView
|
||||||
from compensation.views.compensation.state import NewCompensationStateView, EditCompensationStateView, \
|
from compensation.views.compensation.state import NewCompensationStateView, EditCompensationStateView, \
|
||||||
RemoveCompensationStateView
|
RemoveCompensationStateView
|
||||||
from compensation.views.compensation.compensation import index_view, new_view, new_id_view, detail_view, edit_view, \
|
from compensation.views.compensation.compensation import new_view, new_id_view, detail_view, edit_view, \
|
||||||
remove_view
|
remove_view, CompensationIndexView
|
||||||
from compensation.views.compensation.log import CompensationLogView
|
from compensation.views.compensation.log import CompensationLogView
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
# Main compensation
|
# Main compensation
|
||||||
path("", index_view, name="index"),
|
path("", CompensationIndexView.as_view(), name="index"),
|
||||||
path('new/id', new_id_view, name='new-id'),
|
path('new/id', new_id_view, name='new-id'),
|
||||||
path('new/<intervention_id>', new_view, name='new'),
|
path('new/<intervention_id>', new_view, name='new'),
|
||||||
path('new', new_view, name='new'),
|
path('new', new_view, name='new'),
|
||||||
|
|||||||
@ -7,8 +7,8 @@ Created on: 19.08.22
|
|||||||
"""
|
"""
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.core.exceptions import ObjectDoesNotExist
|
from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.db.models import Sum
|
|
||||||
from django.http import HttpRequest, JsonResponse
|
from django.http import HttpRequest, JsonResponse
|
||||||
from django.shortcuts import get_object_or_404, render, redirect
|
from django.shortcuts import get_object_or_404, render, redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@ -28,37 +28,21 @@ from konova.sub_settings.context_settings import TAB_TITLE_IDENTIFIER
|
|||||||
from konova.utils.message_templates import COMPENSATION_REMOVED_TEMPLATE, DATA_CHECKED_PREVIOUSLY_TEMPLATE, \
|
from konova.utils.message_templates import COMPENSATION_REMOVED_TEMPLATE, DATA_CHECKED_PREVIOUSLY_TEMPLATE, \
|
||||||
RECORDED_BLOCKS_EDIT, CHECK_STATE_RESET, FORM_INVALID, PARAMS_INVALID, IDENTIFIER_REPLACED, \
|
RECORDED_BLOCKS_EDIT, CHECK_STATE_RESET, FORM_INVALID, PARAMS_INVALID, IDENTIFIER_REPLACED, \
|
||||||
COMPENSATION_ADDED_TEMPLATE, DO_NOT_FORGET_TO_SHARE, GEOMETRY_SIMPLIFIED, GEOMETRIES_IGNORED_TEMPLATE
|
COMPENSATION_ADDED_TEMPLATE, DO_NOT_FORGET_TO_SHARE, GEOMETRY_SIMPLIFIED, GEOMETRIES_IGNORED_TEMPLATE
|
||||||
|
from konova.views.base import BaseIndexView
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
class CompensationIndexView(LoginRequiredMixin, BaseIndexView):
|
||||||
@any_group_check
|
_TAB_TITLE = _("Compensations - Overview")
|
||||||
def index_view(request: HttpRequest):
|
_INDEX_TABLE_CLS = CompensationTable
|
||||||
"""
|
|
||||||
Renders the index view for compensation
|
|
||||||
|
|
||||||
Args:
|
def _get_queryset(self):
|
||||||
request (HttpRequest): The incoming request
|
qs = Compensation.objects.filter(
|
||||||
|
|
||||||
Returns:
|
|
||||||
A rendered view
|
|
||||||
"""
|
|
||||||
template = "generic_index.html"
|
|
||||||
compensations = Compensation.objects.filter(
|
|
||||||
deleted=None, # only show those which are not deleted individually
|
deleted=None, # only show those which are not deleted individually
|
||||||
intervention__deleted=None, # and don't show the ones whose intervention has been deleted
|
intervention__deleted=None, # and don't show the ones whose intervention has been deleted
|
||||||
).order_by(
|
).order_by(
|
||||||
"-modified__timestamp"
|
"-modified__timestamp"
|
||||||
)
|
)
|
||||||
table = CompensationTable(
|
return qs
|
||||||
request=request,
|
|
||||||
queryset=compensations
|
|
||||||
)
|
|
||||||
context = {
|
|
||||||
"table": table,
|
|
||||||
TAB_TITLE_IDENTIFIER: _("Compensations - Overview"),
|
|
||||||
}
|
|
||||||
context = BaseContext(request, context).context
|
|
||||||
return render(request, template, context)
|
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user