Fakultas Ilmu Komputer UI

Commit c44d8469 authored by Saul Andre's avatar Saul Andre
Browse files

[RED] add new Category models and update table materi

parent 177d1067
# 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'),
),
]
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
......@@ -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):
......
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