2018-04-24 00:16:22 +02:00
|
|
|
from django.db import models
|
|
|
|
from django.conf import settings
|
2018-11-04 16:42:18 +01:00
|
|
|
from django.utils.translation import gettext as _
|
2018-08-28 18:22:20 +02:00
|
|
|
from pytz import common_timezones
|
|
|
|
|
|
|
|
timezones = [(tz, tz) for tz in common_timezones]
|
2018-04-24 00:16:22 +02:00
|
|
|
|
|
|
|
class Client(models.Model):
|
2018-08-28 18:22:20 +02:00
|
|
|
name = models.CharField(default = "brutaldon", max_length=80)
|
2018-04-24 18:55:44 +02:00
|
|
|
api_base_id = models.URLField(default="https://mastodon.social")
|
2018-08-28 18:22:20 +02:00
|
|
|
client_id = models.CharField(null=True, blank=True, max_length=2048)
|
|
|
|
client_secret = models.CharField(null=True, blank=True, max_length=2048)
|
2018-04-24 00:16:22 +02:00
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name + ": " + self.api_base_id
|
|
|
|
|
2018-08-28 18:22:20 +02:00
|
|
|
class Theme(models.Model):
|
|
|
|
name = models.CharField(max_length=80, unique=True)
|
|
|
|
prefix = models.CharField(max_length=40, null=True, default="default")
|
|
|
|
main_css = models.CharField(max_length=1024, blank=True, null=True,
|
|
|
|
default="css/fullbrutalism.css")
|
|
|
|
tweaks_css = models.CharField(max_length=1024, blank=True, null=True)
|
|
|
|
is_brutalist = models.BooleanField(default=False)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
class Preference(models.Model):
|
|
|
|
theme = models.ForeignKey(Theme, models.CASCADE, null=False, default=1)
|
|
|
|
filter_replies = models.BooleanField(default=False)
|
|
|
|
filter_boosts = models.BooleanField(default=False)
|
|
|
|
timezone = models.CharField(max_length=80, blank=True, null=True,
|
|
|
|
choices=timezones, default='UTC')
|
2018-10-09 20:45:10 +02:00
|
|
|
no_javascript = models.BooleanField(default=False,
|
2018-11-04 16:42:18 +01:00
|
|
|
help_text=_("""Disable all JavaScript. Overrides all other JavaScript options."""))
|
2018-10-09 20:45:10 +02:00
|
|
|
notifications = models.BooleanField(default=True,
|
2018-11-04 16:42:18 +01:00
|
|
|
help_text=_("""Display live notifications in header."""))
|
2018-10-09 20:45:10 +02:00
|
|
|
click_to_load = models.BooleanField(default=False,
|
2018-11-04 16:42:18 +01:00
|
|
|
help_text=_("""Click to load more toots in the same page, rather than using pagination."""))
|
2018-10-10 00:12:47 +02:00
|
|
|
lightbox = models.BooleanField(default=False,
|
2018-11-04 16:42:18 +01:00
|
|
|
help_text=_("""Use a JavaScript lightbox to display media."""))
|
2018-10-18 22:04:28 +02:00
|
|
|
poll_frequency = models.IntegerField(default=300,
|
2018-11-04 16:42:18 +01:00
|
|
|
help_text=_("""Number of seconds to wait between checking notifications. Default: 300"""))
|
2019-01-14 15:08:36 +01:00
|
|
|
filter_notifications = models.BooleanField(default=False,
|
|
|
|
help_text=_("""Exclude boosts and favs from your notifications."""))
|
2018-08-28 18:22:20 +02:00
|
|
|
|
2018-04-24 00:16:22 +02:00
|
|
|
class Account(models.Model):
|
2018-08-28 18:22:20 +02:00
|
|
|
username = models.EmailField(unique=True)
|
|
|
|
email = models.EmailField(null=True, blank=True)
|
2018-04-24 00:16:22 +02:00
|
|
|
django_user = models.ForeignKey(settings.AUTH_USER_MODEL, models.CASCADE, null=True)
|
2018-08-28 18:22:20 +02:00
|
|
|
access_token = models.CharField(null=True, blank=True, max_length=2048)
|
2018-04-24 18:55:44 +02:00
|
|
|
client= models.ForeignKey(Client, models.SET_NULL, null=True)
|
2018-08-28 18:22:20 +02:00
|
|
|
preferences = models.ForeignKey(Preference, models.SET_NULL, null=True)
|
2019-01-28 04:16:15 +01:00
|
|
|
note_seen = models.CharField(null=True, blank=True, max_length=128)
|
2018-08-28 18:22:20 +02:00
|
|
|
|