Commit b0ef725d authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Add model CourseCategory

parent a222d76b
# Generated by Django 2.2.17 on 2021-02-02 19:55
import autoslug.fields
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('courses', '0017_course_course_load'),
]
operations = [
migrations.CreateModel(
name='CourseCategory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=124, verbose_name='title')),
('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='name', unique=True)),
('description', models.TextField(blank=True, verbose_name='description')),
('color', models.CharField(blank=True, help_text='Title color in hex format (i.e: #1aafd0).', max_length=7, verbose_name='color')),
('parent', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='courses.CourseCategory', verbose_name='course category parent')),
],
),
migrations.AddField(
model_name='course',
name='category',
field=models.ManyToManyField(blank=True, to='courses.CourseCategory', verbose_name='category'),
),
]
......@@ -27,6 +27,18 @@ from .classroom.models import Classroom, Event
import re
class CourseCategory(models.Model):
parent = models.ForeignKey('self', models.CASCADE, verbose_name=_("course category parent"), null=True, blank=True)
name = models.CharField(_("title"), max_length=124)
slug = AutoSlugField(populate_from="name", unique=True)
description = models.TextField(_("description"), blank=True)
color = models.CharField(_("color"), max_length=7, blank=True,
help_text=_("Title color in hex format (i.e: #1aafd0)."))
def __str__(self):
return self.name
class Course(models.Model):
STATES = (
('draft', _('Draft')),
......@@ -159,6 +171,7 @@ class Course(models.Model):
null=True,
blank=True,
)
category = models.ManyToManyField(CourseCategory, verbose_name=_('category'), blank=True)
class Meta:
verbose_name = _('Course')
......
Markdown is supported
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