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
c44d8469
Commit
c44d8469
authored
Apr 18, 2020
by
Saul Andre
Browse files
[RED] add new Category models and update table materi
parent
177d1067
Changes
3
Hide whitespace changes
Inline
Side-by-side
app/migrations/0003_auto_20200418_1452.py
0 → 100644
View file @
c44d8469
# 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'
),
),
]
app/models.py
View file @
c44d8469
from
django.db
import
models
# Create your models here.
class
Category
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
20
)
description
=
models
.
CharField
(
max_length
=
20
)
def
__str__
(
self
):
return
self
.
name
class
Materi
(
models
.
Model
):
cover
=
models
.
URLField
(
max_length
=
1000
)
title
=
models
.
CharField
(
max_length
=
50
)
author
=
models
.
CharField
(
max_length
=
30
)
\ No newline at end of file
title
=
models
.
CharField
(
max_length
=
50
,
default
=
'SOME STRING'
)
author
=
models
.
CharField
(
max_length
=
30
,
default
=
'SOME STRING'
)
uploader
=
models
.
CharField
(
max_length
=
30
,
default
=
'SOME STRING'
)
publisher
=
models
.
CharField
(
max_length
=
30
,
default
=
'SOME STRING'
)
descriptions
=
models
.
CharField
(
max_length
=
300
,
default
=
'SOME STRING'
)
categories
=
models
.
ManyToManyField
(
Category
)
\ No newline at end of file
app/tests.py
View file @
c44d8469
...
...
@@ -84,7 +84,9 @@ class DetailMateriTest(TestCase):
test
=
Category
.
objects
.
create
(
id
=
"1"
,
name
=
"medis"
,
desc
=
"kategori medis"
)
countData
=
Category
.
objects
.
all
().
count
()
self
.
assertEqual
(
1
,
countData
)
self
.
assertNotEqual
(
0
,
countData
)
self
.
assertEqual
(
test
.
__str__
(),
"medis"
)
self
.
assertNotEqual
(
test
.
__str__
(),
"saul"
)
class
TemplateLoaderTest
(
TestCase
):
def
test_template_loader_url_exist
(
self
):
...
...
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