SOITA/categories/views.py

20 lines
660 B
Python
Raw Normal View History

2021-12-12 11:35:35 +01:00
from rest_framework import viewsets
from categories.models import Category
from categories.serializers import CategorySerializer
2022-01-08 22:15:30 +01:00
from django.contrib.auth.decorators import login_required
from django.shortcuts import render, redirect
from django.template import loader
2022-01-09 22:29:40 +01:00
from trials.models import Test
2021-12-12 11:35:35 +01:00
class CategoryModelViewSet(viewsets.ModelViewSet):
queryset = Category.objects.all()
serializer_class = CategorySerializer
2022-01-08 22:15:30 +01:00
@login_required
def category(request, category_name):
context = {}
context['name'] = category_name
2022-01-09 22:29:40 +01:00
context['tests'] = Test.objects.filter(category=category_name)
2022-01-08 22:15:30 +01:00
return render(request, 'category.html', context)