Fakultas Ilmu Komputer UI

Commit 49ef345c authored by I Gusti Putu Agastya Indrayana's avatar I Gusti Putu Agastya Indrayana
Browse files

Merge branch 'Coldfix-Staging-Bugfix' into 'staging'

Coldfix staging bugfix

See merge request ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-digipus/marjinal-digipus!27
parents cba020d1 bf334331
File deleted
......@@ -12,7 +12,9 @@ db.sqlite3
db.sqlite3-journal
media
*/__pycache__/*
static/
/static/
media/
.coverage
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
......
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{"name":"Python: Django test","type":"python","request":"launch","program":"${workspaceFolder}\\manage.py","args":["test"],"django":true},
{
"name": "Python: Django",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}\\manage.py",
"args": [
"runserver",
"--noreload"
],
"django": true
}
]
}
\ No newline at end of file
......@@ -2,4 +2,4 @@ from django.apps import AppConfig
class AdministrationConfig(AppConfig):
name = 'administration'
name = "administration"
[
{
"model": "administration.verificationsetting",
"pk": 1,
"fields": {
"title": "Kriteria 1",
"description": "Materi Harus memenuhi kriteria 1",
"archived": false
}
},
{
"model": "administration.verificationsetting",
"pk": 2,
"fields": {
"title": "Kriteria 2",
"description": "Materi Harus memenuhi kriteria 2",
"archived": false
}
},
{
"model": "administration.verificationsetting",
"pk": 3,
"fields": {
"title": "Kriteria 3",
"description": "Materi Harus memenuhi kriteria 3",
"archived": false
}
}
]
from django.forms import ModelForm
from app.models import Category
from administration.models import VerificationSetting
from app.models import Category
class CategoryForm(ModelForm):
class Meta:
model = Category
fields = ["name", "description"]
def __init__(self, *args, **kwargs):
super(CategoryForm, self).__init__(*args, **kwargs)
for field_name, field in self.fields.items():
field.widget.attrs['class'] = 'widget-control'
field.widget.attrs["class"] = "widget-control"
class VerificationSettingForm(ModelForm):
class Meta:
model = VerificationSetting
fields = ["title", "description"]
def __init__(self, *args, **kwargs):
super(VerificationSettingForm, self).__init__(*args, **kwargs)
for field_name, field in self.fields.items():
field.widget.attrs['class'] = 'widget-control'
\ No newline at end of file
field.widget.attrs["class"] = "widget-control"
# Generated by Django 3.0.3 on 2020-04-22 20:10
# Generated by Django 3.0.3 on 2020-04-24 17:07
from django.db import migrations, models
......@@ -7,14 +7,16 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
]
dependencies = []
operations = [
migrations.CreateModel(
name='VerificationSetting',
name="VerificationSetting",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("title", models.CharField(max_length=250)),
("description", models.TextField(default="")),
("archived", models.BooleanField(default=False)),
],
),
]
# Generated by Django 3.0.3 on 2020-04-22 20:17
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('administration', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='verificationsetting',
name='archived',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='verificationsetting',
name='description',
field=models.TextField(default=''),
),
migrations.AddField(
model_name='verificationsetting',
name='title',
field=models.CharField(default='', max_length=250),
preserve_default=False,
),
]
from django.db import models
class VerificationSetting(models.Model):
title = models.CharField(max_length=250, blank=False)
title = models.CharField(max_length=250, blank=False)
description = models.TextField(blank=False, default="")
archived = models.BooleanField(default=False, blank=False)
\ No newline at end of file
archived = models.BooleanField(default=False, blank=False)
from django.test import TestCase, Client
from django.contrib.auth import get_user_model
from django.test import Client, TestCase
from django.urls import resolve
from administration import models, views
from app.models import Materi
from administration import views, models
from django.contrib.auth import get_user_model
class VerifikasiMateriTest(TestCase):
def setUp(self):
......@@ -11,14 +13,14 @@ class VerifikasiMateriTest(TestCase):
# def test_verifikasi_materi_url_exist(self):
# response = self.client.get('/administration/')
# self.assertEqual(response.status_code, 200)
# def test_verifikasi_materi_using_correct_template(self):
# found = resolve('/administration/')
# self.assertEqual(found.func.__name__, views.verification.__name__)
# found2 = resolve('/admin/')
# self.assertNotEqual(found2.func.__name__, views.verification.__name__)
# def test_verifikasi_materi_title(self):
# response = self.client.get('/administration/')
......@@ -35,13 +37,16 @@ class VerifikasiMateriTest(TestCase):
# self.assertNotContains(response, 'Halaman Katalog')
class SettingVerifikasiTest(TestCase):
def setUp(self):
self.client = Client()
self.url = "/administration/setting/verification/"
self.model = models.VerificationSetting
self.admin = get_user_model().objects.create_user(password='admin123', email='admin@admin.com', is_admin=True)
self.contributor = get_user_model().objects.create_user(password='kontributor123', email='kontributor@kontributor.com', is_contributor=True)
self.admin = get_user_model().objects.create_user(password="admin123", email="admin@admin.com", is_admin=True)
self.contributor = get_user_model().objects.create_user(
password="kontributor123", email="kontributor@kontributor.com", is_contributor=True
)
# def test_setting_verifikasi_url_exist(self):
# # Test not authenticated
......@@ -63,11 +68,11 @@ class SettingVerifikasiTest(TestCase):
# self.client.login(email = 'admin@admin.com', password = 'admin123')
# response = self.client.get(self.url)
# self.assertTemplateUsed(response, 'setting_verifikasi.html')
# def test_setting_verifikasi_func(self):
# found = resolve(self.url)
# self.assertEqual(found.func.__name__, views.VerificationSettingView.as_view().__name__)
# def test_setting_verifikasi_model(self):
# self.assertEqual(self.model.objects.all().count(), 0)
# s1 = self.model(title = "Point 1",description= "Deskripsi Point 1")
......@@ -98,5 +103,3 @@ class SettingVerifikasiTest(TestCase):
# response = self.client.post(self.url, data)
# self.assertNotIn(response.content, b'Deskripsi Point 2')
# self.assertEqual(response.status_code, 200)
from django.urls import path
from . import views
app_name = 'administration'
app_name = "administration"
urlpatterns = [
path('', views.verification),
path('api/approve/<int:pk>', views.verification),
path('api/disapprove/<int:pk>', views.verification),
path('setting/verification/', views.VerificationSettingView.as_view()),
path('setting/category/', views.CategorySettingView.as_view()),
]
\ No newline at end of file
path("", views.verification),
path("api/approve/<int:pk>", views.verification),
path("api/disapprove/<int:pk>", views.verification),
path("setting/verification/", views.VerificationSettingView.as_view()),
path("setting/category/", views.CategorySettingView.as_view()),
]
from django.shortcuts import render, get_object_or_404
from django.core.exceptions import PermissionDenied
from django.http import HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.views.generic import TemplateView
from django.core.exceptions import PermissionDenied
from .models import VerificationSetting
from app.models import Category, Materi
from .forms import CategoryForm, VerificationSettingForm
from .models import VerificationSetting
from app.models import Materi, Category
# Create your views here.
def verification(request):
return render(request, 'verif.html')
return render(request, "verif.html")
def approve(request, pk):
if request.user.is_authenticated == False or request.user.is_admin != True:
raise PermissionDenied(request)
materi = get_object_or_404(Materi,pk=pk)
materi.status = ('APPROVE','Diterima')
materi = get_object_or_404(Materi, pk=pk)
materi.status = ("APPROVE", "Diterima")
materi.save()
return render(request, 'verif.html')
return render(request, "verif.html")
def disapprove(request, pk):
if request.user.is_authenticated == False or request.user.is_admin != True:
raise PermissionDenied(request)
materi = get_object_or_404(Materi,pk=pk)
materi.status = ('DISAPROVE','Ditolat')
materi = get_object_or_404(Materi, pk=pk)
materi.status = ("DISAPROVE", "Ditolat")
materi.save()
return render(request, 'verif.html')
return render(request, "verif.html")
class VerificationSettingView(TemplateView):
template_name = "setting_verifikasi.html"
def get_context_data(self, **kwargs):
context = super(VerificationSettingView, self ).get_context_data(**kwargs)
context = super(VerificationSettingView, self).get_context_data(**kwargs)
context["verification_settings"] = VerificationSetting.objects.filter(archived=False)
return context
def get(self, request, *args, **kwargs):
if request.user.is_authenticated == False or request.user.is_admin != True:
raise PermissionDenied(request)
......@@ -56,16 +60,16 @@ class VerificationSettingView(TemplateView):
context = self.get_context_data(**kwargs)
context["form"] = form
return self.render_to_response(context)
class CategorySettingView(TemplateView):
template_name = "setting_category.html"
def get_context_data(self, **kwargs):
context = super(CategorySettingView, self ).get_context_data(**kwargs)
context = super(CategorySettingView, self).get_context_data(**kwargs)
context["category_settings"] = Category.objects.all()
return context
def get(self, request, *args, **kwargs):
if request.user.is_authenticated == False or request.user.is_admin != True:
raise PermissionDenied(request)
......@@ -86,4 +90,3 @@ class CategorySettingView(TemplateView):
context = self.get_context_data(**kwargs)
context["form"] = form
return self.render_to_response(context)
\ No newline at end of file
......@@ -2,4 +2,4 @@ from django.apps import AppConfig
class AppConfig(AppConfig):
name = 'app'
name = "app"
[
{
"model": "app.category",
"pk": 1,
"fields": { "name": "kategori A", "description": "Sebuah kategori A" }
},
{
"model": "app.category",
"pk": 2,
"fields": { "name": "kategori B", "description": "Sebuah kategori B" }
},
{
"model": "app.category",
"pk": 3,
"fields": { "name": "kategori 1", "description": "Sebuah kategori 1" }
},
{
"model": "app.category",
"pk": 4,
"fields": { "name": "kategori 2", "description": "Sebuah kategori 2" }
}
]
from django import forms
from app.models import Materi
class UploadMateriForm(forms.ModelForm):
class Meta:
model = Materi
fields = ['title', 'author', 'publisher',
'categories', 'descriptions', 'cover', 'content']
fields = ["title", "author", "publisher", "categories", "descriptions", "cover", "content"]
def __init__(self, *args, **kwargs):
super(UploadMateriForm, self).__init__(*args, **kwargs)
for field_name, field in self.fields.items():
field.widget.attrs['class'] = 'form-control'
field.widget.attrs["class"] = "form-control"
# Generated by Django 3.0.3 on 2020-04-08 12:29
# Generated by Django 3.0.3 on 2020-04-24 17:07
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
......@@ -8,16 +10,59 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='Materi',
name="Category",
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('cover', models.URLField()),
('title', models.CharField(max_length=50)),
('author', models.CharField(max_length=30)),
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("name", models.CharField(max_length=20)),
("description", models.CharField(max_length=20)),
],
),
migrations.CreateModel(
name="Comment",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("user", models.CharField(default="84546dedbf5047acbf85e33258f0b636", max_length=100)),
("profile", models.CharField(default="4c3f58", max_length=100)),
("comment", models.CharField(default="comments", max_length=150)),
],
),
migrations.CreateModel(
name="Materi",
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("cover", models.ImageField(upload_to="")),
("content", models.FileField(upload_to="")),
("title", models.CharField(default="title", max_length=50)),
("author", models.CharField(default="author", max_length=30)),
("publisher", models.CharField(default="publiser", max_length=30)),
("descriptions", models.TextField(default="descriptions")),
(
"status",
models.CharField(
choices=[
("PENDING", "Diproses"),
("APPROVE", "Diterima"),
("DISAPROVE", "Ditolak"),
("REVISION", "Perbaikan"),
],
default=("PENDING", "Diproses"),
max_length=30,
),
),
("feedback", models.TextField(blank=True, default="")),
("categories", models.ManyToManyField(to="app.Category")),
("comments", models.ManyToManyField(to="app.Comment")),
(
"uploader",
models.ForeignKey(
null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL
),
),
],
),
]
# Generated by Django 3.0.3 on 2020-04-08 14:15
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='materi',
name='cover',
field=models.URLField(max_length=1000),
),
]
# Generated by Django 3.0.3 on 2020-04-18 07:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0002_auto_20200408_2115'),
]
operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=20)),
('description', models.CharField(max_length=20)),
],
),
migrations.AddField(
model_name='materi',
name='descriptions',
field=models.CharField(default='SOME STRING', max_length=300),
),
migrations.AddField(
model_name='materi',
name='publisher',
field=models.CharField(default='SOME STRING', max_length=30),
),
migrations.AddField(
model_name='materi',
name='uploader',
field=models.CharField(default='SOME STRING', max_length=30),
),
migrations.AlterField(
model_name='materi',
name='author',
field=models.CharField(default='SOME STRING', max_length=30),
),
migrations.AlterField(
model_name='materi',
name='title',
field=models.CharField(default='SOME STRING', max_length=50),
),
migrations.AddField(
model_name='materi',
name='categories',
field=models.ManyToManyField(to='app.Category'),
),
]
# Generated by Django 3.0.3 on 2020-04-21 08:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0003_auto_20200418_1452'),
]
operations = [
migrations.CreateModel(
name='Comment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('user', models.CharField(default='423a22c748b647d58f725be4ad1ffefb', max_length=100)),
('profile', models.CharField(default='795364', max_length=100)),
('comment', models.CharField(default='comments', max_length=200)),
],
),
migrations.AlterField(
model_name='materi',
name='author',
field=models.CharField(default='author', max_length=30),
),
migrations.AlterField(
model_name='materi',
name='descriptions',
field=models.CharField(default='descriptions', max_length=300),
),
migrations.AlterField(
model_name='materi',
name='publisher',
field=models.CharField(default='publiser', max_length=30),
),
migrations.AlterField(
model_name='materi',
name='title',
field=models.CharField(default='title', max_length=50),
),
migrations.AlterField(
model_name='materi',
name='uploader',
field=models.CharField(default='uploader', max_length=30),
),
migrations.AddField(
model_name='materi',
name='comments',
field=models.ManyToManyField(to='app.Comment'),
),
]
# Generated by Django 3.0.3 on 2020-04-21 09:25
from django.db import migrations, models