Implemented dajax and moved models to media rather than static

This commit is contained in:
2013-08-17 21:12:21 +10:00
parent 88fe7b7e79
commit 59bab5fc10
106 changed files with 12547 additions and 12 deletions

44
three_d_viewer/models.py Normal file
View File

@@ -0,0 +1,44 @@
from django.db import models
class CommonInfo(models.Model):
name = models.CharField(max_length=100)
active = models.BooleanField(default=True)
def __unicode__(self):
return self.name
class Meta:
abstract = True
class Category(CommonInfo):
parent = models.ForeignKey('self', blank=True, null=True,
on_delete=models.SET_NULL,
related_name='children')
class Sample(CommonInfo):
model_filename = models.CharField(max_length=1000)
description = models.CharField(max_length=2000, default='', blank=True, null=True)
parent = models.ForeignKey(Category, blank=True, null=True,
on_delete=models.SET_NULL)
class Question(models.Model):
text = models.CharField(max_length=2000)
sample = models.ForeignKey(Sample, related_name='questions')
def correct_answers(self):
return self.answers.filter(correct = True)
def __unicode__(self):
return self.text
class Answer(models.Model):
text = models.CharField(max_length=2000)
correct = models.BooleanField(default=False)
question = models.ForeignKey(Question, related_name='answers')
def __unicode__(self):
return self.text