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
|
|
|
|
2019-05-17 19:07:11 +02:00
|
|
|
|
2018-04-24 00:16:22 +02:00
|
|
|
class Client(models.Model):
|
2019-05-17 19:07:11 +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")
|
2019-05-06 15:38:43 +02:00
|
|
|
version = models.CharField(default="1.0", max_length=80)
|
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
|
|
|
|
|
2019-05-17 19:07:11 +02:00
|
|
|
|
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")
|
2019-05-17 19:07:11 +02:00
|
|
|
main_css = models.CharField(
|
|
|
|
max_length=1024, blank=True, null=True, default="css/fullbrutalism.css"
|
|
|
|
)
|
2018-08-28 18:22:20 +02:00
|
|
|
tweaks_css = models.CharField(max_length=1024, blank=True, null=True)
|
|
|
|
is_brutalist = models.BooleanField(default=False)
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
2019-05-17 19:07:11 +02:00
|
|
|
|
2018-08-28 18:22:20 +02:00
|
|
|
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)
|
2019-05-17 19:07:11 +02:00
|
|
|
timezone = models.CharField(
|
|
|
|
max_length=80, blank=True, null=True, choices=timezones, default="UTC"
|
|
|
|
)
|
|
|
|
no_javascript = models.BooleanField(
|
|
|
|
default=False,
|
|
|
|
help_text=_(
|
|
|
|
"""Disable all JavaScript. Overrides all other JavaScript options."""
|
|
|
|
),
|
|
|
|
)
|
|
|
|
notifications = models.BooleanField(
|
|
|
|
default=True, help_text=_("""Display live notifications in header.""")
|
|
|
|
)
|
|
|
|
click_to_load = models.BooleanField(
|
|
|
|
default=False,
|
|
|
|
help_text=_(
|
|
|
|
"""Click to load more toots in the same page, rather than using pagination."""
|
|
|
|
),
|
|
|
|
)
|
|
|
|
lightbox = models.BooleanField(
|
|
|
|
default=False, help_text=_("""Use a JavaScript lightbox to display media.""")
|
|
|
|
)
|
|
|
|
poll_frequency = models.IntegerField(
|
|
|
|
default=300,
|
|
|
|
help_text=_(
|
|
|
|
"""Number of seconds to wait between checking notifications. Default: 300"""
|
|
|
|
),
|
|
|
|
)
|
|
|
|
filter_notifications = models.BooleanField(
|
|
|
|
default=False,
|
|
|
|
help_text=_("""Exclude boosts and favs from your notifications."""),
|
|
|
|
)
|
2019-11-06 01:23:58 +01:00
|
|
|
bundle_notifications = models.BooleanField(
|
|
|
|
default=False,
|
|
|
|
help_text=_(
|
|
|
|
"""Collapse together boosts or likes of the same toot in the notifications page."""
|
|
|
|
),
|
|
|
|
)
|
2019-05-17 19:07:11 +02:00
|
|
|
|
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)
|
2019-05-17 19:07:11 +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)
|