1
0
mirror of https://github.com/Damillora/Altessimo synced 2024-11-22 05:57:31 +00:00
Altessimo/categories/views.py

27 lines
1.0 KiB
Python
Raw Normal View History

2020-12-16 18:02:21 +00:00
from django.core.paginator import Paginator
2020-12-15 21:32:20 +00:00
from django.shortcuts import render
from django.http import HttpResponse
2020-12-16 17:36:29 +00:00
from .models import Branch, Category
from songs.models import Song
from artists.models import Artist
2020-12-15 21:32:20 +00:00
# Create your views here.
2020-12-16 17:36:29 +00:00
def category_index(request):
categories = Category.objects.all()
return render(request,"categories/index.html",{'categories':categories})
def category_show(request, slug):
category = Category.objects.filter(slug=slug)[0]
return render(request,"categories/show.html",{'category':category})
def branch_index(request):
branches = Branch.objects.all()
return render(request,"branches/index.html",{'branches':branches})
def branch_show(request, acronym):
branch = Branch.objects.filter(acronym=acronym)[0]
songs = Song.objects.filter(branch=branch)
2020-12-16 18:02:21 +00:00
paginator = Paginator(songs, 100)
page_number = request.GET.get('page',1)
page_obj = paginator.get_page(page_number)
return render(request,"branches/show.html",{'branch':branch,'page_obj':page_obj})