Add preference for notification poll frequency

This commit is contained in:
Jason McBrayer 2018-10-18 16:04:28 -04:00
parent 221a13c593
commit e799c097cc
7 changed files with 40 additions and 2 deletions

View File

@ -25,7 +25,7 @@ class PreferencesForm(forms.ModelForm):
class Meta: class Meta:
model = Preference model = Preference
fields = ['theme', 'filter_replies', 'filter_boosts', 'timezone', 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): class PostForm(forms.Form):
"""def status_post(self, status, in_reply_to_id=None, media_ids=None, """def status_post(self, status, in_reply_to_id=None, media_ids=None,

View File

@ -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'),
),
]

View File

@ -38,6 +38,8 @@ class Preference(models.Model):
help_text="""Click to load more toots in the same page, rather than using pagination.""") help_text="""Click to load more toots in the same page, rather than using pagination.""")
lightbox = models.BooleanField(default=False, lightbox = models.BooleanField(default=False,
help_text="""Use a JavaScript lightbox to display media.""") 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): class Account(models.Model):
username = models.EmailField(unique=True) username = models.EmailField(unique=True)

View File

@ -208,3 +208,8 @@ emoji-link
max-width: 30em; max-width: 30em;
display: inline-block; display: inline-block;
} }
input#id_poll_frequency
{
max-width: 10em;
}

View File

@ -179,3 +179,7 @@ emoji-link
max-width: 30em; max-width: 30em;
display: inline-block; display: inline-block;
} }
input#id_poll_frequency
{
max-width: 10em;
}

View File

@ -82,7 +82,7 @@
<span class="fa fa-bell-o"></span> <span class="fa fa-bell-o"></span>
{% if preferences.notifications and not preferences.theme.is_brutalist %} {% if preferences.notifications and not preferences.theme.is_brutalist %}
<span ic-src="{% url 'notes_count' %}" <span ic-src="{% url 'notes_count' %}"
ic-poll="60s" ic-poll="{{ preferences.poll_frequency }}s"
ic-target="this"> ic-target="this">
<span <span
{% if notifications and notifications != '0' %} {% if notifications and notifications != '0' %}

View File

@ -85,6 +85,15 @@
</p> </p>
</div> </div>
<div class="field">
<label class="label" for="poll_frequency">{{ form.poll_frequency.label }}</label>
<div class="control">
{% render_field form.poll_frequency class+="input" %}
</div>
<p class="notification is-info preferences-help">
{{ form.poll_frequency.help_text }}
</p>
</div>
<div class="field"> <div class="field">
<input type="submit" name="submit" <input type="submit" name="submit"
value="Save" class="button is-primary" > value="Save" class="button is-primary" >