Fakultas Ilmu Komputer UI

Commit 3aff6414 authored by Saul Andre's avatar Saul Andre
Browse files

[REFACTOR] Create new fields for category and verification settings

parent 5391b6cd
# Generated by Django 3.0.3 on 2020-06-04 00:09
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('administration', '0004_auto_20200517_1713'),
]
operations = [
migrations.AddField(
model_name='verificationsetting',
name='archived_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
]
...@@ -10,6 +10,7 @@ class VerificationSetting(models.Model): ...@@ -10,6 +10,7 @@ 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="") description = models.TextField(blank=False, default="")
archived = models.BooleanField(default=False, blank=False) archived = models.BooleanField(default=False, blank=False)
archived_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
class VerificationReport(models.Model): class VerificationReport(models.Model):
......
...@@ -366,6 +366,7 @@ ...@@ -366,6 +366,7 @@
<tr> <tr>
<th scope="col">Item</th> <th scope="col">Item</th>
<th scope="col">Deskripsi</th> <th scope="col">Deskripsi</th>
<th scope="col">Admin penghapus</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -373,6 +374,7 @@ ...@@ -373,6 +374,7 @@
<tr> <tr>
<th>{{item.title}} {{item.name}}</th> <th>{{item.title}} {{item.name}}</th>
<th>{{item.description}}</th> <th>{{item.description}}</th>
<th>{{item.archived_by.name}}</th>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
......
...@@ -379,9 +379,9 @@ def delete_verification(request, *args, **kwargs): ...@@ -379,9 +379,9 @@ def delete_verification(request, *args, **kwargs):
queryObject = get_object_or_404(VerificationSetting, queryObject = get_object_or_404(VerificationSetting,
pk=kwargs["pk_verification"]) pk=kwargs["pk_verification"])
queryObject.archived = True queryObject.archived = True
queryObject.description = "Telah dihapus oleh " + \ queryObject.description = "Telah dihapus pada " + \
request.user.name + " pada tanggal " + \ str(datetime.now().strftime("%m/%d/%Y, %H:%M:%S")) + " WIB"
str(datetime.now().strftime("%m/%d/%Y, %H:%M:%S")) + "WIB" queryObject.archived_by = request.user
queryObject.save() queryObject.save()
messages.success(request, "Point verifikasi berhasil dihapus") messages.success(request, "Point verifikasi berhasil dihapus")
return HttpResponseRedirect("/administration/setting/verification/") return HttpResponseRedirect("/administration/setting/verification/")
...@@ -395,9 +395,9 @@ def delete_category(request, *args, **kwargs): ...@@ -395,9 +395,9 @@ def delete_category(request, *args, **kwargs):
queryObject = get_object_or_404(Category, queryObject = get_object_or_404(Category,
pk=kwargs["pk_category"]) pk=kwargs["pk_category"])
queryObject.archived = True queryObject.archived = True
queryObject.description = "Telah dihapus oleh " + \ queryObject.description = "Telah dihapus pada " + \
request.user.name + " pada tanggal " + \ str(datetime.now().strftime("%m/%d/%Y, %H:%M:%S")) + " WIB"
str(datetime.now().strftime("%m/%d/%Y, %H:%M:%S")) + "WIB" queryObject.archived_by = request.user
queryObject.save() queryObject.save()
messages.success(request, "Kategori " + messages.success(request, "Kategori " +
category_name + " berhasil dihapus") category_name + " berhasil dihapus")
......
# Generated by Django 3.0.3 on 2020-06-04 00:09
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('app', '0011_auto_20200603_1350'),
]
operations = [
migrations.AddField(
model_name='category',
name='archived_by',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL),
),
]
...@@ -24,6 +24,7 @@ class Category(models.Model): ...@@ -24,6 +24,7 @@ class Category(models.Model):
name = models.CharField(max_length=20) name = models.CharField(max_length=20)
description = models.TextField(blank=False, default="") description = models.TextField(blank=False, default="")
archived = models.BooleanField(default=False, blank=False) archived = models.BooleanField(default=False, blank=False)
archived_by = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
def __str__(self): def __str__(self):
return self.name return self.name
......
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