From e799c097ccfc51df0bae32534cb989674d5cf38a Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Thu, 18 Oct 2018 16:04:28 -0400 Subject: [PATCH] Add preference for notification poll frequency --- brutaldon/forms.py | 2 +- .../0017_preference_poll_frequency.py | 18 ++++++++++++++++++ brutaldon/models.py | 2 ++ brutaldon/static/css/brutaldon-dark.css | 5 +++++ brutaldon/static/css/brutaldon.css | 4 ++++ brutaldon/templates/base.html | 2 +- brutaldon/templates/setup/settings.html | 9 +++++++++ 7 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 brutaldon/migrations/0017_preference_poll_frequency.py diff --git a/brutaldon/forms.py b/brutaldon/forms.py index 3951c5d..618171f 100644 --- a/brutaldon/forms.py +++ b/brutaldon/forms.py @@ -25,7 +25,7 @@ class PreferencesForm(forms.ModelForm): class Meta: model = Preference fields = ['theme', 'filter_replies', 'filter_boosts', 'timezone', - 'no_javascript', 'notifications', 'click_to_load', 'lightbox'] + 'no_javascript', 'notifications', 'click_to_load', 'lightbox', 'poll_frequency'] class PostForm(forms.Form): """def status_post(self, status, in_reply_to_id=None, media_ids=None, diff --git a/brutaldon/migrations/0017_preference_poll_frequency.py b/brutaldon/migrations/0017_preference_poll_frequency.py new file mode 100644 index 0000000..dac1672 --- /dev/null +++ b/brutaldon/migrations/0017_preference_poll_frequency.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.2 on 2018-10-18 19:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('brutaldon', '0016_auto_20181009_1805'), + ] + + operations = [ + migrations.AddField( + model_name='preference', + name='poll_frequency', + field=models.IntegerField(default=300, help_text='Number of seconds to wait between checking notifications. Default: 300'), + ), + ] diff --git a/brutaldon/models.py b/brutaldon/models.py index bdce33f..9e4e562 100644 --- a/brutaldon/models.py +++ b/brutaldon/models.py @@ -38,6 +38,8 @@ class Preference(models.Model): 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""") class Account(models.Model): username = models.EmailField(unique=True) diff --git a/brutaldon/static/css/brutaldon-dark.css b/brutaldon/static/css/brutaldon-dark.css index c72598b..48c97ff 100644 --- a/brutaldon/static/css/brutaldon-dark.css +++ b/brutaldon/static/css/brutaldon-dark.css @@ -208,3 +208,8 @@ emoji-link max-width: 30em; display: inline-block; } + +input#id_poll_frequency +{ + max-width: 10em; +} diff --git a/brutaldon/static/css/brutaldon.css b/brutaldon/static/css/brutaldon.css index 5ee102a..466c35d 100644 --- a/brutaldon/static/css/brutaldon.css +++ b/brutaldon/static/css/brutaldon.css @@ -179,3 +179,7 @@ emoji-link max-width: 30em; display: inline-block; } +input#id_poll_frequency +{ + max-width: 10em; +} diff --git a/brutaldon/templates/base.html b/brutaldon/templates/base.html index dabde7f..de6777f 100644 --- a/brutaldon/templates/base.html +++ b/brutaldon/templates/base.html @@ -82,7 +82,7 @@ {% if preferences.notifications and not preferences.theme.is_brutalist %} +
+ +
+ {% render_field form.poll_frequency class+="input" %} +
+

+ {{ form.poll_frequency.help_text }} +

+