added first public views - no check for access rights at the moment
This commit is contained in:
@@ -13,13 +13,15 @@ from django.utils.safestring import mark_safe
|
||||
from content.models import Question as QuestionContent
|
||||
from lib import get_current_user
|
||||
from tablequizwiki.settings import BASE_DIR
|
||||
from lib.core.db.models.mixins import AuthorAware, DateAware
|
||||
|
||||
|
||||
class Quiz(models.Model):
|
||||
class Quiz(AuthorAware, DateAware):
|
||||
name = models.CharField(max_length=250)
|
||||
author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, default=get_current_user)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
# author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, default=get_current_user)
|
||||
|
||||
# created_at = models.DateTimeField(auto_now_add=True)
|
||||
# updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
@@ -117,14 +119,12 @@ class Quiz(models.Model):
|
||||
return str(BASE_DIR) + f'/filestore/csv/quiz.{self.id}.csv'
|
||||
|
||||
|
||||
class Question(models.Model):
|
||||
class Question(DateAware):
|
||||
question = models.ForeignKey(QuestionContent, on_delete=models.RESTRICT, related_name='content_question')
|
||||
quiz = models.ForeignKey(Quiz, on_delete=models.CASCADE)
|
||||
points = models.DecimalField(max_digits=10, decimal_places=1, default=1.0)
|
||||
order = models.IntegerField(default=1)
|
||||
description = models.TextField(null=True, blank=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
return str(self.question)
|
||||
|
||||
Reference in New Issue
Block a user