510d77422a
* adds Ema model (basically Compensation inherited) * adds index view for EMAs * fixes drop-down link bug for menu 'More' in navbar * refactors some more forms to use process_request() * adds modified attribute to BaseResource for easy last_modified check * adds setting of modified attribute in all places where UserAction.EDITED is added to log * adds EMA_ACCOUNT_IDENTIFIER_LENGTH and EMA_ACCOUNT_IDENTIFIER_TEMPLATE to ema/settings.py * adds EmaAdmin to ema/admin.py * fixes wrong title in intervention detail view html for revocations * adds support for subtitle variable to BaseTable and generic_index.html * drops next_version attribute from models * adds/updates translations * adds default ordering for UserActionLogEntry * removes extra ordering in log modal rendering
71 lines
1.6 KiB
Python
71 lines
1.6 KiB
Python
from django.contrib.auth.decorators import login_required
|
|
from django.http import HttpRequest
|
|
from django.shortcuts import render, get_object_or_404
|
|
|
|
from ema.tables import EmaTable
|
|
from konova.contexts import BaseContext
|
|
from konova.decorators import conservation_office_group_required
|
|
from ema.models import Ema
|
|
|
|
|
|
@login_required
|
|
def index_view(request: HttpRequest):
|
|
""" Renders the index view for MAEs
|
|
|
|
Args:
|
|
request (HttpRequest): The incoming request
|
|
|
|
Returns:
|
|
|
|
"""
|
|
template = "generic_index.html"
|
|
emas = Ema.objects.filter(
|
|
deleted=None,
|
|
).order_by(
|
|
"-modified"
|
|
)
|
|
table = EmaTable(
|
|
request,
|
|
queryset=emas
|
|
)
|
|
context = {
|
|
"table": table,
|
|
}
|
|
context = BaseContext(request, context).context
|
|
return render(request, template, context)
|
|
|
|
|
|
@login_required
|
|
@conservation_office_group_required
|
|
def new_view(request: HttpRequest):
|
|
""" Renders the form for a new MAE
|
|
|
|
Args:
|
|
request (HttpRequest): The incoming request
|
|
|
|
Returns:
|
|
|
|
"""
|
|
template = "generic_index.html"
|
|
context = {}
|
|
context = BaseContext(request, context).context
|
|
return render(request, template, context)
|
|
|
|
|
|
@login_required
|
|
def open_view(request: HttpRequest, id: str):
|
|
""" Renders the form for a new MAE
|
|
|
|
Args:
|
|
request (HttpRequest): The incoming request
|
|
id (str): The MAE id
|
|
|
|
Returns:
|
|
|
|
"""
|
|
ema = get_object_or_404(Ema, id=id)
|
|
template = "generic_index.html"
|
|
context = {}
|
|
context = BaseContext(request, context).context
|
|
return render(request, template, context)
|