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)
|