1
0
mirror of https://gitlab.com/brutaldon/brutaldon.git synced 2024-12-04 14:46:24 -05:00

Add lightbox preference

This commit is contained in:
Jason McBrayer 2018-10-09 18:12:47 -04:00
parent 9bf48fab96
commit 7b8c5dbb59
6 changed files with 50 additions and 1 deletions

View File

@ -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']
'no_javascript', 'notifications', 'click_to_load', 'lightbox']
class PostForm(forms.Form):
"""def status_post(self, status, in_reply_to_id=None, media_ids=None,

View File

@ -0,0 +1,33 @@
# Generated by Django 2.1.2 on 2018-10-09 22:05
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('brutaldon', '0015_auto_20181001_1812'),
]
operations = [
migrations.AddField(
model_name='preference',
name='lightbox',
field=models.BooleanField(default=False, help_text='Use a JavaScript lightbox to display media.'),
),
migrations.AlterField(
model_name='preference',
name='click_to_load',
field=models.BooleanField(default=False, help_text='Click to load more toots in the same page, rather than using pagination.'),
),
migrations.AlterField(
model_name='preference',
name='no_javascript',
field=models.BooleanField(default=False, help_text='Disable all JavaScript. Overrides all other JavaScript options.'),
),
migrations.AlterField(
model_name='preference',
name='notifications',
field=models.BooleanField(default=True, help_text='Display live notifications in header.'),
),
]

View File

@ -36,6 +36,8 @@ class Preference(models.Model):
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.""")
class Account(models.Model):
username = models.EmailField(unique=True)

View File

@ -173,10 +173,13 @@
$(document).ready(function () {
menuPrepare();
});
{% if preferences.lightbox %}
Intercooler.ready(function ()
{
$(".attachments").photobox('a', { history: false });
});
{% endif %}
</script>
{% block page_scripts_inline %}
{% endblock %}

View File

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

View File

@ -400,6 +400,7 @@ def settings(request):
account.preferences.no_javascript = form.cleaned_data['no_javascript']
account.preferences.notifications = form.cleaned_data['notifications']
account.preferences.click_to_load = form.cleaned_data['click_to_load']
account.preferences.lightbox = form.cleaned_data['lightbox']
request.session['timezone'] = account.preferences.timezone
account.preferences.save()
account.save()