2018-08-13 07:02:14 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""
|
|
|
|
The main quest models.
|
|
|
|
"""
|
2018-08-10 08:39:51 -04:00
|
|
|
from django.db import models
|
2018-08-13 07:02:14 -04:00
|
|
|
from django.conf import settings
|
2018-08-10 08:39:51 -04:00
|
|
|
|
2018-08-13 07:02:14 -04:00
|
|
|
class Quest(models.Model):
|
|
|
|
"""
|
|
|
|
The meta quest object. Contains general information about the quest.
|
|
|
|
"""
|
|
|
|
title = models.CharField(max_length=200)
|
|
|
|
owner = models.ForeignKey(
|
|
|
|
settings.AUTH_USER_MODEL,
|
|
|
|
on_delete=models.CASCADE)
|
|
|
|
open_post_id = models.IntegerField(null=True)
|
|
|
|
|
|
|
|
|
|
|
|
class Post(models.Model):
|
|
|
|
"""
|
|
|
|
An object for arbituary posts. Contains all post data, type, etc.
|
|
|
|
"""
|
|
|
|
quest = models.ForeignKey(Quest, on_delete=models.CASCADE)
|
|
|
|
page_num = models.IntegerField(default=1)
|
|
|
|
POST_TYPES = (
|
|
|
|
('text', 'Text'),
|
|
|
|
('dice', 'Dice'),
|
|
|
|
('poll', 'Poll'))
|
|
|
|
post_type = models.CharField(max_length=4, choices=POST_TYPES)
|
|
|
|
post_text = models.TextField()
|
|
|
|
timestamp = models.DateTimeField(auto_now=True)
|
|
|
|
|
|
|
|
class PageTitle(models.Model):
|
|
|
|
"""
|
|
|
|
Represents the title of a quest page.
|
|
|
|
"""
|
|
|
|
quest = models.ForeignKey(Quest, on_delete=models.CASCADE)
|
|
|
|
page_num = models.IntegerField()
|
|
|
|
title = models.CharField(max_length=200)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.title
|