diff --git a/.travis.yml b/.travis.yml index 96f7843..e8d90c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ - +dist: xenial language: python python: - "3.6" @@ -7,4 +7,5 @@ install: script: - python manage.py makemigrations questions - python manage.py migrate - - python manage.py test \ No newline at end of file + - python manage.py test + diff --git a/questions/admin.py b/questions/admin.py index 6723db8..cb98c31 100644 --- a/questions/admin.py +++ b/questions/admin.py @@ -1,5 +1,12 @@ from django.contrib import admin from .models import * +admin.site.register(Question) +admin.site.register(min_mark) +admin.site.register(max_mark) +admin.site.register(difficulty) admin.site.register(Topic) -admin.site.register(Type) \ No newline at end of file +admin.site.register(Type) +admin.site.register(date) +admin.site.register(author) + diff --git a/questions/models.py b/questions/models.py index b40f349..d5e98c2 100644 --- a/questions/models.py +++ b/questions/models.py @@ -1,22 +1,59 @@ from django.db import models +from ckeditor.fields import RichTextField +from django.core.validators import MinValueValidator +from django.template.defaultfilters import truncatechars +from enum import Enum +from django.contrib.auth.models import User + +class stat(Enum): + ve= 'Very easy' + e= 'Easy' + mod= 'Moderate' + hard= 'Hard' + Exp= 'Expert' + +class Question(models.Model): + name= RichTextField() + @property + def short_description(self): + return truncatechars(self.description, 100) + + +class min_mark(models.Model): + marks= models.IntegerField(validators=[MinValueValidator(10)]) + +class max_mark(models.Model): + marks= models.IntegerField() + +class difficulty(models.Model): + level= models.CharField(max_length= 10, choices=[(tag, tag.value) for tag in stat]) + class Topic(models.Model): name = models.CharField(max_length=50) - parent = models.ForeignKey('self', on_delete=models.CASCADE, null=True, blank=True) + parent = models.ManyToManyField(Question) def __str__(self): - return self.name + return self.name class Type(models.Model): name = models.CharField(max_length=50) - + parent= models.ForeignKey(Question, related_name='type', null=True, blank=True, on_delete= models.CASCADE) class Meta: verbose_name = "Type" verbose_name_plural = "Types" - + def __str__(self): - return self.name + return self.name + + + +class date(models.Model): + date= models.DateField(auto_now_add=True) + +class author(models.Model): + designed_by= models.ForeignKey(User, related_name='+', on_delete= models.CASCADE)