Skip to content

Commit

Permalink
refactor: move topic to is own app
Browse files Browse the repository at this point in the history
  • Loading branch information
rijkerd committed Jun 1, 2020
1 parent faa6734 commit ef78870
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 12 deletions.
24 changes: 12 additions & 12 deletions module/models.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
from django.db import models
from topic.models import Topic

"""
Is representation of a subject take by an individual/student on a
particular programme.
- Attached to a particalar NTA Level eg. NTA 5
example: Radio Transmission ETT-01025
"""
course_type = ('Core', 'Fundamental')


class Module(models.Model):
name = models.CharField(max_length=100, blank=False, unique=True)
description = models.CharField(max_length=200, blank=True)
code = models.CharField(max_length=30, blank=True, default='EBE 0101')
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
# type = models.CharField(
# choices=course_type, default='Fundamental', max_length=100,)

def __str__(self):
return self.name


class Topic(models.Model):
id = models.BigAutoField(
primary_key=True, unique=True)
name = models.CharField(max_length=100, blank=False, unique=True)
description = models.CharField(max_length=200, blank=True)
# files = models.ForeignKey(
# TopicFile, related_name='resources', on_delete=models.CASCADE)

def __str__(self):
return self.name


class Resource(models.Model):
topic = models.ForeignKey(
Topic, on_delete=models.CASCADE, related_name='resources')
Expand Down
Empty file added topic/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions topic/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions topic/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class TopicConfig(AppConfig):
name = 'topic'
23 changes: 23 additions & 0 deletions topic/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django.db import models

"""
Refers to an area being discussed can also be referred to as subject.
Example:
- Module: Networking - ETT 01012
- Topic : Introduction to networking
"""


class Topic(models.Model):
id = models.BigAutoField(
primary_key=True, unique=True)
name = models.CharField(max_length=100, blank=False, unique=True)
description = models.CharField(max_length=200, blank=True)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
# files = models.ForeignKey(
# TopicFile, related_name='resources', on_delete=models.CASCADE)

def __str__(self):
return self.name
3 changes: 3 additions & 0 deletions topic/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions topic/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.

0 comments on commit ef78870

Please sign in to comment.