Fakultas Ilmu Komputer UI

Commit 4eed9b68 authored by Mika dabelza abi's avatar Mika dabelza abi
Browse files

[GREEN] Materi's status filter implementation

parent adbaaa67
# Generated by Django 3.0.3 on 2020-04-22 14:44
# Generated by Django 3.0.3 on 2020-04-27 01:57
from django.db import migrations, models
......@@ -6,18 +6,18 @@ from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0007_auto_20200421_2151'),
('app', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='51e685', max_length=100),
field=models.CharField(default='9bb0d6', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='9a89fd18ef5d4351a884acf98b36b71d', max_length=100),
field=models.CharField(default='b38c137f9b6a4cd0b61fc72840358bbe', max_length=100),
),
]
# Generated by Django 3.0.3 on 2020-04-22 16:11
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0008_auto_20200422_2144'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='ca5be3', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='f88e20b6dcfc43daba68479578ecc003', max_length=100),
),
]
......@@ -26,29 +26,37 @@ class DaftarKatalog(TemplateView):
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
context["kategori_list"] = Category.objects.all()
context["materi_list"] = Materi.objects.all()
print(Materi.objects.get(pk=1).status[0])
context["materi_list"] = Materi.objects.all().filter(status = "(\"APPROVE\", \"Diterima\")")
getSearch = request.GET.get('search')
if getSearch:
list = Materi.objects.all().filter(
Q(title__icontains = getSearch) |
Q(descriptions__icontains = getSearch) |
list = Materi.objects.filter(
Q(title__icontains=getSearch) |
Q(author__icontains=getSearch) |
Q(uploader__icontains=getSearch) |
Q(uploader__name__icontains=getSearch) |
Q(descriptions__icontains=getSearch) |
Q(publisher__icontains=getSearch)
).distinct
context["materi_list"] = list
).distinct()
# list = Materi.objects.filter(
# Q(title__icontains=getSearch) |
# Q(descriptions__icontains=getSearch) |
# Q(author__icontains=getSearch) |
# Q(uploader__icontains=getSearch) |
# Q(publisher__icontains=getSearch)
# )
context["materi_list"] = list.filter(status = "(\"APPROVE\", \"Diterima\")")
getKategori = request.GET.get("kategori")
if getKategori:
pkGet = request.GET.get("kategori")
kategori = Category.objects.get(pk = pkGet)
list = Materi.objects.filter(categories = kategori.pk)
context["materi_list"] = list
context["materi_list"] = list.filter(status = "(\"APPROVE\", \"Diterima\")")
getSort = request.GET.get("sort")
if getSort:
list = Materi.objects.all()
list = Materi.objects.all().filter(status = "(\"APPROVE\", \"Diterima\")")
if(getSort == "judul"):
context["materi_list"] = list.order_by('title')
elif(getSort == "penulis"):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment