konova/compensation/views.py

110 lines
2.1 KiB
Python
Raw Normal View History

2021-07-01 13:36:07 +02:00
from django.contrib.auth.decorators import login_required
from django.http import HttpRequest
from django.shortcuts import render
from compensation.models import Compensation, EcoAccount
from compensation.tables import CompensationTable, EcoAccountTable
from konova.contexts import BaseContext
from konova.decorators import *
@login_required
def index_view(request: HttpRequest):
"""
Renders the index view for compensation
Args:
request (HttpRequest): The incoming request
Returns:
A rendered view
"""
template = "generic_index.html"
user = request.user
2021-07-01 14:38:57 +02:00
compensations = None # ToDo
2021-07-01 13:36:07 +02:00
table = CompensationTable(
request=request,
queryset=compensations
)
context = {
"table": table,
}
context = BaseContext(request, context).context
return render(request, template, context)
@login_required
def new_view(request: HttpRequest):
# ToDo
pass
@login_required
def edit_view(request: HttpRequest, id: str):
# ToDo
pass
@login_required
def open_view(request: HttpRequest, id: str):
# ToDo
pass
@login_required
def remove_view(request: HttpRequest, id: str):
# ToDo
pass
@login_required
def account_index_view(request: HttpRequest):
"""
Renders the index view for eco accounts
Args:
request (HttpRequest): The incoming request
Returns:
A rendered view
"""
template = "generic_index.html"
user = request.user
eco_accounts = EcoAccount.objects.filter(
created_by=user,
is_deleted=False,
)
table = EcoAccountTable(
request=request,
queryset=eco_accounts
)
context = {
"table": table,
}
context = BaseContext(request, context).context
return render(request, template, context)
@login_required
def account_new_view(request: HttpRequest):
# ToDo
pass
@login_required
def account_edit_view(request: HttpRequest, id: str):
# ToDo
pass
@login_required
def account_open_view(request: HttpRequest, id: str):
# ToDo
pass
@login_required
def account_remove_view(request: HttpRequest, id: str):
# ToDo
pass