Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

docs: Model updated #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

dist: xenial
language: python
python:
- "3.6"
Expand All @@ -7,4 +7,5 @@ install:
script:
- python manage.py makemigrations questions
- python manage.py migrate
- python manage.py test
- python manage.py test

9 changes: 8 additions & 1 deletion questions/admin.py
Original file line number Diff line number Diff line change
@@ -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)
admin.site.register(Type)
admin.site.register(date)
admin.site.register(author)

47 changes: 42 additions & 5 deletions questions/models.py
Original file line number Diff line number Diff line change
@@ -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)