Fakultas Ilmu Komputer UI

Commit 01202673 authored by I Gusti Putu Agastya Indrayana's avatar I Gusti Putu Agastya Indrayana Committed by igor lestin sianipar
Browse files

Coldfix staging migration files

parent 3e8e65f2
......@@ -48,6 +48,9 @@ share/python-wheels/
.installed.cfg
*.egg
MANIFEST
.pip_cache
pylint
coverage.svg
# PyInstaller
# Usually these files are written by a python script from a template
......
......@@ -3,6 +3,21 @@ stages:
- sonarqube
- deploy
pylint:
image: python:3.7
stage: test
before_script:
- pip install -r requirements.txt
script:
- mkdir ./pylint
- git ls-files | grep -v 'migrations' | grep -v 'settings.py' | grep -v 'manage.py' | grep -E '.py$' | xargs pylint -E --load-plugins=pylint_django --output-format=text --score=yes | tee ./pylint/pylint.log || pylint-exit $?
- PYLINT_SCORE=$(sed -n 's/^Your code has been rated at \([-0-9.]*\)\/.*/\1/p' ./pylint/pylint.log)
- anybadge --label=Pylint --file=pylint/pylint.svg --value=$PYLINT_SCORE 2=red 4=orange 8=yellow 10=green
- echo "Pylint score is $PYLINT_SCORE"
artifacts:
paths:
- ./pylint/
UnitTest:
services:
- postgres:alpine
......
# Generated by Django 3.0.3 on 2020-04-27 07:51
# Generated by Django 3.0.3 on 2020-05-08 14:42
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
......@@ -11,10 +12,22 @@ class Migration(migrations.Migration):
]
operations = [
migrations.CreateModel(
name='VerificationReport',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('report', django.contrib.postgres.fields.jsonb.JSONField()),
('timestamp', models.DateTimeField(auto_now_add=True)),
('status', models.CharField(choices=[('PENDING', 'Diproses'), ('APPROVE', 'Diterima'), (
'DISAPPROVE', 'Ditolak'), ('REVISION', 'Perbaikan')], default='PENDING', max_length=30)),
],
),
migrations.CreateModel(
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-05-04 01:12
from django.conf import settings
import django.contrib.postgres.fields.jsonb
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('app', '0019_auto_20200504_0812'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('administration', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='VerificationReport',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('report', django.contrib.postgres.fields.jsonb.JSONField()),
('timestamp', models.DateTimeField(auto_now_add=True)),
('status', models.CharField(choices=[('PENDING', 'Diproses'), ('APPROVE', 'Diterima'), ('DISAPPROVE', 'Ditolak'), ('REVISION', 'Perbaikan')], default='PENDING', max_length=30)),
('materi', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='app.Materi')),
('user', 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-05-03 06:26
# Generated by Django 3.0.3 on 2020-05-08 14:42
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('authentication', '0001_initial'),
('app', '0001_initial'),
('administration', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='user',
name='profile_picture',
field=models.ImageField(default='default-image.png', upload_to=''),
model_name='verificationreport',
name='materi',
field=models.ForeignKey(
null=True, on_delete=django.db.models.deletion.SET_NULL, to='app.Materi'),
),
]
# Generated by Django 3.0.3 on 2020-05-08 14:42
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('administration', '0002_verificationreport_materi'),
]
operations = [
migrations.AddField(
model_name='verificationreport',
name='user',
field=models.ForeignKey(
null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
]
from django.db import models
from django.contrib.postgres.fields import JSONField
from django.db import models
from app.models import Materi, VERIFICATION_STATUS
from app.models import VERIFICATION_STATUS, Materi
from authentication.models import User
......
from random import randint
from django.contrib.auth import get_user_model
from django.core.files.uploadedfile import SimpleUploadedFile
from django.test import Client, TestCase, tag
from django.urls import resolve
from administration import models, views
from app.models import Materi, Category
from administration.utils import id_generator
from app.models import Category, Materi
from bs4 import BeautifulSoup
......@@ -40,7 +36,7 @@ class VerifikasiMateriTest(TestCase):
)
Materi(title="Materi 1", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 1",
status="PENDING", cover=self.cover, content=self.content, feedback="").save()
status="PENDING", cover=self.cover, content=self.content).save()
self.materi1 = Materi.objects.first()
def test_verification_detail_admin_access(self):
......@@ -129,7 +125,7 @@ class DetailVerifikasiMateriTest(TestCase):
)
Materi(title="Materi 1", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 1",
status="PENDING", cover=self.cover, content=self.content, feedback="").save()
status="PENDING", cover=self.cover, content=self.content).save()
models.VerificationSetting(
title="Kriteria 1", description="Deskripsi Kriteria 1").save()
self.materi1 = Materi.objects.first()
......@@ -500,7 +496,8 @@ class SettingCategoriTest(TestCase):
# Logout
self.client.logout()
class ContributorListTest(TestCase ):
class ContributorListTest(TestCase):
def setUp(self):
self.client = Client()
self.url = '/administration/daftar-kontributor/'
......@@ -527,7 +524,7 @@ class ContributorListTest(TestCase ):
)
Materi(title="Materi 1", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 1",
status="PENDING", cover=self.cover, content=self.content, feedback="").save()
status="PENDING", cover=self.cover, content=self.content).save()
self.materi1 = Materi.objects.first()
def test_contributor_list_access(self):
......@@ -557,7 +554,8 @@ class ContributorListTest(TestCase ):
# Login
self.client.login(**self.admin_credential)
found = resolve(self.url)
self.assertEqual(found.func.__name__, views.ContributorListView.__name__)
self.assertEqual(found.func.__name__,
views.ContributorListView.__name__)
def test_contributor_list_title(self):
# Login
......@@ -567,7 +565,8 @@ class ContributorListTest(TestCase ):
self.assertContains(response, 'Dasbor Kontributor')
self.assertNotContains(response, 'Fake Title')
class ProfileContributorAdminTest(TestCase):
def setUp(self):
self.client = Client()
......@@ -595,7 +594,7 @@ class ProfileContributorAdminTest(TestCase):
)
Materi(title="Materi 1", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 1",
status="PENDING", cover=self.cover, content=self.content, feedback="").save()
status="PENDING", cover=self.cover, content=self.content).save()
self.materi1 = Materi.objects.first()
def test_profile_contributor_admin_anonymous_access(self):
......@@ -607,4 +606,5 @@ class ProfileContributorAdminTest(TestCase):
# Login
self.client.login(**self.admin_credential)
found = resolve(self.url)
self.assertEqual(found.func.__name__, views.ProfileContributorAdminView.__name__)
\ No newline at end of file
self.assertEqual(found.func.__name__,
views.ProfileContributorAdminView.__name__)
from django.urls import path
from . import views
from administration.views import VerificationView, DetailVerificationView, VerificationSettingView, CategorySettingView, ContributorListView, ProfileContributorAdminView
app_name = "administration"
urlpatterns = [
path("", views.VerificationView.as_view()),
path("detail-verif/<int:pk>/", views.DetailVerificationView.as_view()),
path("setting/verification/", views.VerificationSettingView.as_view()),
path("setting/category/", views.CategorySettingView.as_view()),
path("daftar-kontributor/", views.ContributorListView.as_view()),
path("profil/<int:pk>/", views.ProfileContributorAdminView.as_view()),
path("", VerificationView.as_view()),
path("detail-verif/<int:pk>/", DetailVerificationView.as_view()),
path("setting/verification/", VerificationSettingView.as_view()),
path("setting/category/", CategorySettingView.as_view()),
path("daftar-kontributor/", ContributorListView.as_view()),
path("profil/<int:pk>/", ProfileContributorAdminView.as_view()),
]
import string
import random
import string
def id_generator(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
\ No newline at end of file
def id_generator(size=6, chars=string.ascii_uppercase + string.digits): # pragma: no cover
return ''.join(random.choice(chars) for _ in range(size))
......@@ -6,8 +6,8 @@ from django.views.generic import TemplateView
from app.models import Category, Materi
from authentication.models import User
from .forms import CategoryForm, VerificationSettingForm
from .models import VerificationSetting, VerificationReport
from administration.forms import CategoryForm, VerificationSettingForm
from administration.models import VerificationReport, VerificationSetting
# Create your views here.
......@@ -156,6 +156,7 @@ class CategorySettingView(TemplateView):
context["form"] = form
return self.render_to_response(context)
class ContributorListView(TemplateView):
template_name = "daftar_kontributor.html"
......@@ -174,6 +175,7 @@ class ContributorListView(TemplateView):
context = self.get_context_data(**kwargs)
return self.render_to_response(context)
class ProfileContributorAdminView(TemplateView):
template_name = "detail_kontri_admin.html"
......@@ -189,4 +191,4 @@ class ProfileContributorAdminView(TemplateView):
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
context["user"] = get_object_or_404(User, pk=kwargs["pk"])
return self.render_to_response(context=context)
\ No newline at end of file
return self.render_to_response(context=context)
from django.apps import AppConfig
from django.apps import AppConfig as _AppConfig
class AppConfig(AppConfig):
class AppConfig(_AppConfig):
name = "app"
......@@ -3,22 +3,26 @@ from django import forms
from app.models import Materi
from authentication.models import User
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"
class SuntingProfilForm(forms.ModelForm):
class Meta:
model = User
fields = ["profile_picture", "linkedin", "facebook", "twitter", "instagram", "biography"]
fields = ["profile_picture", "linkedin",
"facebook", "twitter", "instagram", "biography"]
def __init__(self, *args, **kwargs):
super(SuntingProfilForm, self).__init__(*args, **kwargs)
for field_name, field in self.fields.items():
field.widget.attrs["class"] = "form-control"
\ No newline at end of file
field.widget.attrs["class"] = "form-control"
# Generated by Django 3.0.3 on 2020-04-24 17:07
# Generated by Django 3.0.3 on 2020-05-08 14:42
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
......@@ -10,59 +8,44 @@ class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name="Category",
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)),
('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",
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)),
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=100)),
('profile', models.CharField(default='56acdf', max_length=100)),
('comment', models.CharField(default='comments', max_length=150)),
],
),
migrations.CreateModel(
name="Materi",
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
),
),
('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)),
('pages', models.IntegerField(default=0)),
('descriptions', models.TextField(default='descriptions')),
('status', models.CharField(choices=[('PENDING', 'Diproses'), ('APPROVE', 'Diterima'), (
'DISAPPROVE', 'Ditolak'), ('REVISION', 'Perbaikan')], default='PENDING', max_length=30)),
('date_added', models.DateTimeField(auto_now_add=True)),
('categories', models.ManyToManyField(to='app.Category')),
],
),
]
# Generated by Django 3.0.3 on 2020-04-26 15:41
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='0db2a4', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='7f90724880024ace9444f17a0d1bd592', max_length=100),
),
]
# Generated by Django 3.0.3 on 2020-04-27 01:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='9bb0d6', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='b38c137f9b6a4cd0b61fc72840358bbe', max_length=100),
),
]
# Generated by Django 3.0.3 on 2020-05-01 18:47
# Generated by Django 3.0.3 on 2020-05-08 14:42
from django.db import migrations, models
import django.db.models.deletion
from django.conf import settings
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
('app', '0005_auto_20200502_0145'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('app', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='comment',
name='materi',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='app.Materi'),
model_name='materi',
name='uploader',
field=models.ForeignKey(
null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
migrations.AddField(
model_name='comment',
name='profile',
field=models.CharField(default='01560e', max_length=100),
name='materi',
field=models.ForeignKey(
null=True, on_delete=django.db.models.deletion.SET_NULL, to='app.Materi'),
),
migrations.AlterField(
migrations.AddField(
model_name='comment',
name='user',
field=models.CharField(default='bde24911bda74be5b98a63a2b4df87e0', max_length=100),
field=models.ForeignKey(
blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
]
# Generated by Django 3.0.3 on 2020-04-27 15:10
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0002_auto_20200427_0857'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='77e693', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='bcf5ec5adb434db0b85a00dfa1058930', max_length=100),
),
]
# Generated by Django 3.0.3 on 2020-04-30 04:22
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0002_auto_20200426_2241'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='b117ac', max_length=100),
),
migrations.AlterField(
model_name='comment',