added first public views - no check for access rights at the moment

This commit is contained in:
Holger Sielaff
2024-07-12 17:22:17 +02:00
parent 7d53df6ea5
commit 3640ab759d
22 changed files with 386 additions and 69 deletions

View File

@@ -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)