start oef
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.views.generic.edit import UpdateView, CreateView
|
||||
|
||||
from .models import Entry, Formats
|
||||
# Create your views here.
|
||||
from .tables import EntryTable
|
||||
from .filters import EntryFilter
|
||||
from django_filters.views import FilterView
|
||||
|
||||
from django_tables2 import SingleTableView, SingleTableMixin
|
||||
|
||||
class EntryUpdateView(UpdateView):
|
||||
model = Entry
|
||||
template_name = "oef/entry_update_view.html"
|
||||
fields = ['modality', 'exam_code', 'exam_name', 'questions', 'comments']
|
||||
|
||||
class FormatsCreateView(CreateView):
|
||||
model = Formats
|
||||
template_name_suffix = "_update_form"
|
||||
fields = ['name', 'format', 'inherits']
|
||||
|
||||
class FormatsUpdateView(UpdateView):
|
||||
model = Formats
|
||||
template_name_suffix = "_update_form"
|
||||
fields = ['name', 'format', 'inherits']
|
||||
|
||||
class EntryTableView(SingleTableMixin, FilterView):
|
||||
model = Entry
|
||||
table_class = EntryTable
|
||||
|
||||
template_name = "oef/entry_table.html"
|
||||
|
||||
filterset_class = EntryFilter
|
||||
|
||||
def formats_view(request):
|
||||
formats = Formats.objects.all()
|
||||
return render(request, "oef/formats_view.html", {"formats": formats})
|
||||
|
||||
def formats_apply(request, pk):
|
||||
format = get_object_or_404(Formats, pk=pk)
|
||||
|
||||
search_text = format.get_format()
|
||||
|
||||
entries = Entry.objects.filter(questions__icontains=search_text)
|
||||
|
||||
entry_list = []
|
||||
for entry in entries:
|
||||
entry_list.append((entry, entry.questions.replace(search_text, "")))
|
||||
return render(request, "oef/formats_apply.html", {"format": format, "entry_list": entry_list, "entries": entries})
|
||||
Reference in New Issue
Block a user