mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-27 00:54:54 +00:00
web_admin module added, api for article created
This commit is contained in:
54
web_admin/models.py
Normal file
54
web_admin/models.py
Normal file
@ -0,0 +1,54 @@
|
||||
"""
|
||||
web_admin model file
|
||||
"""
|
||||
# django imports
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Article(models.Model):
|
||||
title = models.CharField(max_length=255)
|
||||
description = models.TextField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
is_published = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self):
|
||||
"""Return title"""
|
||||
return f'{self.id} | {self.title}'
|
||||
|
||||
|
||||
class ArticleCard(models.Model):
|
||||
article = models.ForeignKey(Article, on_delete=models.CASCADE)
|
||||
title = models.CharField(max_length=255)
|
||||
description = models.TextField()
|
||||
image = models.ImageField(upload_to='card_images/')
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
"""Return title"""
|
||||
return f'{self.id} | {self.title}'
|
||||
|
||||
|
||||
class ArticleSurvey(models.Model):
|
||||
article = models.ForeignKey(Article, on_delete=models.CASCADE)
|
||||
question = models.CharField(max_length=255)
|
||||
points = models.IntegerField()
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
"""Return title"""
|
||||
return f'{self.id} | {self.article}'
|
||||
|
||||
|
||||
class SurveyOption(models.Model):
|
||||
survey = models.ForeignKey(ArticleSurvey, on_delete=models.CASCADE)
|
||||
option = models.CharField(max_length=255)
|
||||
is_answer = models.BooleanField(default=False)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
def __str__(self):
|
||||
"""Return title"""
|
||||
return f'{self.id} | {self.survey}'
|
||||
Reference in New Issue
Block a user