2018-04-23 18:16:22 -04:00
|
|
|
from django import forms
|
2018-08-02 11:13:50 -04:00
|
|
|
from django.conf import settings
|
2018-11-07 13:07:21 -05:00
|
|
|
from django.utils.translation import gettext as _
|
2018-08-21 13:15:10 -04:00
|
|
|
from pytz import common_timezones
|
2018-08-28 12:22:20 -04:00
|
|
|
from .models import Theme, Preference
|
|
|
|
|
2018-04-23 18:16:22 -04:00
|
|
|
|
2018-11-07 13:07:21 -05:00
|
|
|
PRIVACY_CHOICES = (('public', _('Public')),
|
|
|
|
('unlisted', _('Unlisted')),
|
|
|
|
('private', _('Private')),
|
|
|
|
('direct', _('Direct')))
|
2018-04-27 14:12:29 -04:00
|
|
|
|
2018-08-21 13:15:10 -04:00
|
|
|
timezones = [ (tz, tz) for tz in common_timezones]
|
|
|
|
|
2018-04-23 18:16:22 -04:00
|
|
|
class LoginForm(forms.Form):
|
2018-11-07 13:07:21 -05:00
|
|
|
instance = forms.CharField(label=_("Instance"),
|
2018-04-23 18:16:22 -04:00
|
|
|
max_length=256)
|
2018-11-07 13:07:21 -05:00
|
|
|
email = forms.EmailField(label=_("Email"))
|
2018-04-23 18:16:22 -04:00
|
|
|
password = forms.CharField(widget=forms.PasswordInput())
|
|
|
|
|
2018-05-14 15:35:10 -04:00
|
|
|
class OAuthLoginForm(forms.Form):
|
2018-11-07 13:07:21 -05:00
|
|
|
instance = forms.CharField(label=_("Instance"),
|
2018-05-14 15:35:10 -04:00
|
|
|
max_length=256)
|
|
|
|
|
2018-08-28 12:22:20 -04:00
|
|
|
class PreferencesForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = Preference
|
2018-10-02 12:14:03 -04:00
|
|
|
fields = ['theme', 'filter_replies', 'filter_boosts', 'timezone',
|
2019-01-14 09:08:36 -05:00
|
|
|
'no_javascript', 'notifications', 'click_to_load', 'lightbox',
|
|
|
|
'filter_notifications', 'poll_frequency']
|
2018-04-27 14:12:29 -04:00
|
|
|
|
|
|
|
class PostForm(forms.Form):
|
|
|
|
"""def status_post(self, status, in_reply_to_id=None, media_ids=None,
|
2018-08-02 11:13:50 -04:00
|
|
|
sensitive=False, visibility=None, spoiler_text=None):"""
|
2018-09-04 19:19:35 -04:00
|
|
|
status = forms.CharField(label="Toot", widget=forms.Textarea)
|
2018-11-07 13:07:21 -05:00
|
|
|
visibility = forms.ChoiceField(label=_("Toot visibility"), choices=PRIVACY_CHOICES,
|
2018-05-22 08:57:45 -04:00
|
|
|
required=False)
|
2018-11-07 13:07:21 -05:00
|
|
|
spoiler_text = forms.CharField(label=_("CW or Subject"),
|
2018-04-30 08:58:10 -04:00
|
|
|
required=False)
|
2018-11-07 13:07:21 -05:00
|
|
|
media_file_1 = forms.FileField(label = _("Media 1"),
|
2018-04-30 08:58:10 -04:00
|
|
|
required=False)
|
2018-11-07 13:07:21 -05:00
|
|
|
media_text_1 = forms.CharField(label=_("Describe media 1."),
|
2018-04-30 08:58:10 -04:00
|
|
|
required=False)
|
2018-11-07 13:07:21 -05:00
|
|
|
media_file_2 = forms.FileField(label = _("Media 2"),
|
2018-04-30 08:58:10 -04:00
|
|
|
required=False)
|
2018-11-07 13:07:21 -05:00
|
|
|
media_text_2 = forms.CharField(label=_("Describe media 2."),
|
2018-04-30 08:58:10 -04:00
|
|
|
required=False)
|
2018-11-07 13:07:21 -05:00
|
|
|
media_file_3 = forms.FileField(label = _("Media 3"),
|
2018-04-30 08:58:10 -04:00
|
|
|
required=False)
|
2018-11-07 13:07:21 -05:00
|
|
|
media_text_3 = forms.CharField(label=_("Describe media 3."),
|
2018-04-30 08:58:10 -04:00
|
|
|
required=False)
|
2018-11-07 13:07:21 -05:00
|
|
|
media_file_4 = forms.FileField(label = _("Media 4"),
|
2018-04-30 08:58:10 -04:00
|
|
|
required=False)
|
2018-11-07 13:07:21 -05:00
|
|
|
media_text_4 = forms.CharField(label=_("Describe media 4."),
|
2018-04-30 08:58:10 -04:00
|
|
|
required=False)
|
2018-11-07 13:47:27 -05:00
|
|
|
media_sensitive = forms.BooleanField(label=_("Sensitive media?"), required=False)
|
2019-02-14 20:34:06 -05:00
|
|
|
|
|
|
|
class FilterForm(forms.Form):
|
|
|
|
phrase = forms.CharField(label=_("Word or phrase to filter"))
|
2019-02-15 17:10:26 -05:00
|
|
|
context_home = forms.BooleanField(label=_("In home timeline"), required=False, initial=True)
|
|
|
|
context_public = forms.BooleanField(label=_("In public timelines"), required=False, initial=True)
|
|
|
|
context_notes = forms.BooleanField(label=_("In notifications"), required=False, initial=True)
|
|
|
|
context_thread = forms.BooleanField(label=_("In thread contexts"), required=False, initial=True)
|
|
|
|
whole_word = forms.BooleanField(label=_("Whole words only"), required=False, initial=True)
|
2019-02-14 20:34:06 -05:00
|
|
|
expires_in = forms.TypedChoiceField(label=_("Expires in"),
|
|
|
|
choices=(("", "Never"),
|
|
|
|
("1800", "30 minutes"),
|
|
|
|
("3600", "1 hour"),
|
|
|
|
("21600", "6 hours"),
|
|
|
|
("43200", "12 hours"),
|
|
|
|
("86400", "1 day"),
|
|
|
|
("604800", "1 week")),
|
2019-02-15 17:19:17 -05:00
|
|
|
coerce=int, required=False)
|