Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
DIGIPUS
Commits
3aff6414
Commit
3aff6414
authored
Jun 04, 2020
by
Saul Andre
Browse files
[REFACTOR] Create new fields for category and verification settings
parent
5391b6cd
Changes
6
Hide whitespace changes
Inline
Side-by-side
administration/migrations/0005_verificationsetting_archived_by.py
0 → 100644
View file @
3aff6414
# 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
),
),
]
administration/models.py
View file @
3aff6414
...
...
@@ -10,6 +10,7 @@ class VerificationSetting(models.Model):
title
=
models
.
CharField
(
max_length
=
250
,
blank
=
False
)
description
=
models
.
TextField
(
blank
=
False
,
default
=
""
)
archived
=
models
.
BooleanField
(
default
=
False
,
blank
=
False
)
archived_by
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
SET_NULL
,
null
=
True
)
class
VerificationReport
(
models
.
Model
):
...
...
administration/templates/settings.html
View file @
3aff6414
...
...
@@ -366,6 +366,7 @@
<tr>
<th
scope=
"col"
>
Item
</th>
<th
scope=
"col"
>
Deskripsi
</th>
<th
scope=
"col"
>
Admin penghapus
</th>
</tr>
</thead>
<tbody>
...
...
@@ -373,6 +374,7 @@
<tr>
<th>
{{item.title}} {{item.name}}
</th>
<th>
{{item.description}}
</th>
<th>
{{item.archived_by.name}}
</th>
</tr>
{% endfor %}
</tbody>
...
...
administration/views.py
View file @
3aff6414
...
...
@@ -379,9 +379,9 @@ def delete_verification(request, *args, **kwargs):
queryObject
=
get_object_or_404
(
VerificationSetting
,
pk
=
kwargs
[
"pk_verification"
])
queryObject
.
archived
=
True
queryObject
.
description
=
"Telah dihapus
oleh
"
+
\
request
.
user
.
name
+
" pada tanggal "
+
\
str
(
datetime
.
now
().
strftime
(
"%m/%d/%Y, %H:%M:%S"
))
+
"WIB"
queryObject
.
description
=
"Telah dihapus
pada
"
+
\
str
(
datetime
.
now
().
strftime
(
"%m/%d/%Y, %H:%M:%S"
))
+
" WIB"
queryObject
.
archived_by
=
request
.
user
queryObject
.
save
()
messages
.
success
(
request
,
"Point verifikasi berhasil dihapus"
)
return
HttpResponseRedirect
(
"/administration/setting/verification/"
)
...
...
@@ -395,9 +395,9 @@ def delete_category(request, *args, **kwargs):
queryObject
=
get_object_or_404
(
Category
,
pk
=
kwargs
[
"pk_category"
])
queryObject
.
archived
=
True
queryObject
.
description
=
"Telah dihapus
oleh
"
+
\
request
.
user
.
name
+
" pada tanggal "
+
\
str
(
datetime
.
now
().
strftime
(
"%m/%d/%Y, %H:%M:%S"
))
+
"WIB"
queryObject
.
description
=
"Telah dihapus
pada
"
+
\
str
(
datetime
.
now
().
strftime
(
"%m/%d/%Y, %H:%M:%S"
))
+
" WIB"
queryObject
.
archived_by
=
request
.
user
queryObject
.
save
()
messages
.
success
(
request
,
"Kategori "
+
category_name
+
" berhasil dihapus"
)
...
...
app/migrations/0012_category_archived_by.py
0 → 100644
View file @
3aff6414
# 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
),
),
]
app/models.py
View file @
3aff6414
...
...
@@ -24,6 +24,7 @@ class Category(models.Model):
name
=
models
.
CharField
(
max_length
=
20
)
description
=
models
.
TextField
(
blank
=
False
,
default
=
""
)
archived
=
models
.
BooleanField
(
default
=
False
,
blank
=
False
)
archived_by
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
SET_NULL
,
null
=
True
)
def
__str__
(
self
):
return
self
.
name
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment