176 lines
6.0 KiB
Python
176 lines
6.0 KiB
Python
from django.db import models
|
|
from django.core.files.storage import FileSystemStorage
|
|
from django.conf import settings
|
|
import os
|
|
|
|
def name_artwork(inst, name):
|
|
return '%s/artwork.%s'%(inst.abbr,name.split('.')[-1])
|
|
def name_css(inst, name):
|
|
return '%s/style.css'%inst.abbr
|
|
def name_banner(inst, name):
|
|
return '%s/banner.%s'%(inst.abbr,name.split('.')[-1])
|
|
|
|
# Create your models here.
|
|
class Show(models.Model):
|
|
show_static_storage = FileSystemStorage(location=os.path.join(os.path.dirname(settings.MEDIA_ROOT), 'uploaded_resources'), base_url='showstatic')
|
|
name = models.CharField(
|
|
max_length=40,
|
|
help_text="The full name of the show",
|
|
verbose_name="Full Name"
|
|
)
|
|
abbr = models.SlugField(
|
|
max_length=5,
|
|
unique=True,
|
|
help_text="A short abbreviation of the show, for use in urls",
|
|
verbose_name="Abbreviation"
|
|
)
|
|
description = models.TextField(
|
|
help_text="A description of the show",
|
|
verbose_name="Description"
|
|
)
|
|
release = models.DateField(
|
|
help_text="The release date of the first episode of the show",
|
|
verbose_name="Release Date"
|
|
)
|
|
artwork = models.ImageField(
|
|
storage=show_static_storage,
|
|
upload_to = name_artwork,
|
|
help_text="The artwork associated with the show. Should display the name of the show in a movie-poster esque format. Aspect ration should be about 2:3",
|
|
verbose_name="Artwork"
|
|
)
|
|
imdb = models.URLField(
|
|
help_text="The url of the IMDb page for this show",
|
|
verbose_name="IMDb Page"
|
|
)
|
|
moderated = models.BooleanField(
|
|
help_text="Whether or not this show is user-moderated",
|
|
verbose_name="User Moderated"
|
|
)
|
|
css = models.FileField(
|
|
storage=show_static_storage,
|
|
upload_to=name_css,
|
|
help_text="The CSS stylesheet applied to this show's page",
|
|
verbose_name="Custom Style"
|
|
)
|
|
banner = models.ImageField(
|
|
storage=show_static_storage,
|
|
upload_to = name_banner,
|
|
help_text="A banner used for the show's page.",
|
|
verbose_name="Artwork"
|
|
)
|
|
|
|
class User(models.Model):
|
|
auth_token=models.CharField(
|
|
max_length=16,
|
|
help_text="User's authentication token from IcyNet's auth system",
|
|
verbose_name="IcyNet Auth Token"
|
|
)
|
|
display_name=models.CharField(
|
|
max_length=20,
|
|
help_text="The name shown to other users",
|
|
verbose_name="Display Name"
|
|
)
|
|
|
|
class Admin(User):
|
|
pass
|
|
|
|
class Ban(models.Model):
|
|
user = models.OneToOneField(
|
|
User,
|
|
on_delete=models.CASCADE,
|
|
help_text="The user this ban applies to",
|
|
verbose_name="Banned User"
|
|
)
|
|
admin = models.ForeignKey(
|
|
Admin,
|
|
on_delete=models.SET_NULL,
|
|
null=True,
|
|
help_text='The admin which banned this user',
|
|
verbose_name='Banned By',
|
|
related_name='bans'
|
|
)
|
|
reason = models.CharField(
|
|
max_length=50,
|
|
blank=True,
|
|
help_text='The reason this user was banned',
|
|
verbose_name='Ban Reason'
|
|
)
|
|
expiration = models.DateField(
|
|
help_text='The date this user will become unbanned',
|
|
blank=True,
|
|
verbose_name='Expiration Date'
|
|
)
|
|
permanent = models.BooleanField(
|
|
help_text='If checked, this user will never be unbanned, even if the expiration date passes',
|
|
verbose_name='Permanent'
|
|
)
|
|
scope = models.ManyToManyField(
|
|
Show,
|
|
help_text='The shows this user is banned from interacting with',
|
|
verbose_name='Banned From',
|
|
related_name='bans'
|
|
)
|
|
site_wide = models.BooleanField(
|
|
help_text='If checked, this is a site-wide ban, and the user is automatically banned from all shows, not just those in the Banned From (scope) paramenter',
|
|
verbose_name = 'Site Wide Ban'
|
|
)
|
|
class ShowModerator(models.Model):
|
|
show = models.ForeignKey(
|
|
Show,
|
|
on_delete=models.CASCADE,
|
|
help_text='The show this user moderates',
|
|
verbose_name='Moderated Show',
|
|
related_name='moderators',
|
|
)
|
|
user = models.ForeignKey(
|
|
User,
|
|
on_delete=models.CASCADE,
|
|
help_text='The user who moderates this show',
|
|
verbose_name='Moderator',
|
|
related_name='moderated_shows'
|
|
)
|
|
appointed_by = models.ForeignKey(
|
|
User,
|
|
on_delete=models.SET_NULL,
|
|
related_name='appointed_mods',
|
|
null=True,
|
|
help_text='The user who appointed this moderator',
|
|
verbose_name='Appointed by'
|
|
)
|
|
class Report(models.Model):
|
|
reporter = models.ForeignKey(
|
|
User,
|
|
on_delete=models.SET_NULL,
|
|
null=True,
|
|
related_name='reports',
|
|
help_text='The user who created this report',
|
|
verbose_name='Reporter'
|
|
)
|
|
title = models.CharField(
|
|
max_length=50,
|
|
help_text='A brief summary of the report',
|
|
verbose_name='Title'
|
|
)
|
|
details = models.TextField(
|
|
help_text='The details of the report, preferably including why the content should be removed',
|
|
verbose_name = 'Details'
|
|
)
|
|
url = models.URLField(
|
|
max_length=100,
|
|
help_text='The URL of the content being reported',
|
|
verbose_name = 'Content URL'
|
|
)
|
|
class ShowSubmission(models.Model):
|
|
user = models.ForeignKey(
|
|
User,
|
|
on_delete=models.CASCADE,
|
|
related_name='show_submissions',
|
|
help_text='The user who submitted this show',
|
|
verbose_name='Submitter'
|
|
)
|
|
name = Show.name
|
|
details = models.TextField(
|
|
help_text='Some details about the show. Why it should be added, where information about it can be found, etc.',
|
|
verbose_name='Details'
|
|
)
|