diff --git a/bookwyrm/context_processors.py b/bookwyrm/context_processors.py new file mode 100644 index 00000000..72839dce --- /dev/null +++ b/bookwyrm/context_processors.py @@ -0,0 +1,8 @@ +''' customize the info available in context for rendering templates ''' +from bookwyrm import models + +def site_settings(request): + ''' include the custom info about the site ''' + return { + 'site': models.SiteSettings.objects.get() + } diff --git a/bookwyrm/migrations/0016_auto_20201211_2026.py b/bookwyrm/migrations/0016_auto_20201211_2026.py new file mode 100644 index 00000000..46b6140c --- /dev/null +++ b/bookwyrm/migrations/0016_auto_20201211_2026.py @@ -0,0 +1,28 @@ +# Generated by Django 3.0.7 on 2020-12-11 20:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bookwyrm', '0015_auto_20201128_0349'), + ] + + operations = [ + migrations.AddField( + model_name='sitesettings', + name='admin_email', + field=models.EmailField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='sitesettings', + name='support_link', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name='sitesettings', + name='support_title', + field=models.CharField(blank=True, max_length=100, null=True), + ), + ] diff --git a/bookwyrm/migrations/0017_auto_20201212_0059.py b/bookwyrm/migrations/0017_auto_20201212_0059.py new file mode 100644 index 00000000..c9e3fcf4 --- /dev/null +++ b/bookwyrm/migrations/0017_auto_20201212_0059.py @@ -0,0 +1,19 @@ +# Generated by Django 3.0.7 on 2020-12-12 00:59 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('bookwyrm', '0016_auto_20201211_2026'), + ] + + operations = [ + migrations.AlterField( + model_name='readthrough', + name='book', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='bookwyrm.Edition'), + ), + ] diff --git a/bookwyrm/models/site.py b/bookwyrm/models/site.py index aa2e2a67..1577e369 100644 --- a/bookwyrm/models/site.py +++ b/bookwyrm/models/site.py @@ -17,6 +17,9 @@ class SiteSettings(models.Model): code_of_conduct = models.TextField( default="Add a code of conduct here.") allow_registration = models.BooleanField(default=True) + support_link = models.CharField(max_length=255, null=True, blank=True) + support_title = models.CharField(max_length=100, null=True, blank=True) + admin_email = models.EmailField(max_length=255, null=True, blank=True) @classmethod def get(cls): diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index ecabb8d7..3784158c 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -75,6 +75,7 @@ TEMPLATES = [ 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', + 'bookwyrm.context_processors.site_settings', ], }, }, diff --git a/bookwyrm/templates/about.html b/bookwyrm/templates/about.html index 25caf5e2..aa7426ca 100644 --- a/bookwyrm/templates/about.html +++ b/bookwyrm/templates/about.html @@ -3,13 +3,13 @@
- {% include 'snippets/about.html' with site_settings=site_settings %} + {% include 'snippets/about.html' %}

Code of Conduct

- {{ site_settings.code_of_conduct | safe }} + {{ site.code_of_conduct | safe }}
diff --git a/bookwyrm/templates/invite.html b/bookwyrm/templates/invite.html index 332a5ed2..42f564d6 100644 --- a/bookwyrm/templates/invite.html +++ b/bookwyrm/templates/invite.html @@ -15,7 +15,7 @@
- {% include 'snippets/about.html' with site_settings=site_settings %} + {% include 'snippets/about.html' %}
diff --git a/bookwyrm/templates/layout.html b/bookwyrm/templates/layout.html index 4ae70a4b..b37c9cda 100644 --- a/bookwyrm/templates/layout.html +++ b/bookwyrm/templates/layout.html @@ -2,7 +2,7 @@ - {% if title %}{{ title }} | {% endif %}BookWyrm + {% if title %}{{ title }} | {% endif %}{{ site.name }} @@ -11,12 +11,10 @@ - - + + - - @@ -123,6 +121,30 @@ {% endblock %} + + diff --git a/bookwyrm/templates/login.html b/bookwyrm/templates/login.html index 0142d390..ce5d9e41 100644 --- a/bookwyrm/templates/login.html +++ b/bookwyrm/templates/login.html @@ -36,7 +36,7 @@
- {% if site_settings.allow_registration %} + {% if site.allow_registration %}

Create an Account

{% include 'snippets/register_form.html' %} @@ -50,7 +50,7 @@
- {% include 'snippets/about.html' with site_settings=site_settings %} + {% include 'snippets/about.html' %}

More about this site diff --git a/bookwyrm/templates/notifications.html b/bookwyrm/templates/notifications.html index bc96f307..f9494c31 100644 --- a/bookwyrm/templates/notifications.html +++ b/bookwyrm/templates/notifications.html @@ -1,5 +1,6 @@ {% extends 'layout.html' %} -{% load humanize %}l +{% load humanize %} +{% load fr_display %} {% block content %}

Notifications

@@ -12,9 +13,10 @@
{% for notification in notifications %} -
-
+
+

+ {# DESCRIPTION #} {% if notification.related_user %} {% include 'snippets/avatar.html' with user=notification.related_user %} {% include 'snippets/username.html' with user=notification.related_user %} @@ -30,10 +32,8 @@ replied to your status - {% elif notification.notification_type == 'FOLLOW' %} followed you - {% elif notification.notification_type == 'FOLLOW_REQUEST' %} sent you a follow request

@@ -45,17 +45,30 @@ {% endif %} {% else %} your import completed. - {% endif %}

- -

{{ notification.created_date | naturaltime }}

+ {% if notification.related_status %} +
+ {# PREVIEW #} +
+
+ +
+ {{ notification.related_status.published_date | post_date }} + {% include 'snippets/privacy-icons.html' with item=notification.related_status %} +
+
+
+
+ {% endif %}
{% endfor %} + {% if not notifications %}

You're all caught up!

{% endif %}
- {% endblock %} diff --git a/bookwyrm/templates/password_reset.html b/bookwyrm/templates/password_reset.html index ac2ba7bd..99d114e4 100644 --- a/bookwyrm/templates/password_reset.html +++ b/bookwyrm/templates/password_reset.html @@ -34,7 +34,7 @@
- {% include 'snippets/about.html' with site_settings=site_settings %} + {% include 'snippets/about.html' %}
diff --git a/bookwyrm/templates/snippets/about.html b/bookwyrm/templates/snippets/about.html index 35b39f82..9660f521 100644 --- a/bookwyrm/templates/snippets/about.html +++ b/bookwyrm/templates/snippets/about.html @@ -1,7 +1,7 @@ -

About {{ site_settings.name }}

+

About {{ site.name }}

BookWyrm

- {{ site_settings.instance_description }} + {{ site.instance_description }}

diff --git a/bookwyrm/view_actions.py b/bookwyrm/view_actions.py index bd8baf73..1a79f2a0 100644 --- a/bookwyrm/view_actions.py +++ b/bookwyrm/view_actions.py @@ -43,7 +43,6 @@ def user_login(request): login_form.non_field_errors = 'Username or password are incorrect' register_form = forms.RegisterForm() data = { - 'site_settings': models.SiteSettings.get(), 'login_form': login_form, 'register_form': register_form } @@ -79,7 +78,6 @@ def register(request): if errors: data = { - 'site_settings': models.SiteSettings.get(), 'login_form': forms.LoginForm(), 'register_form': form } diff --git a/bookwyrm/views.py b/bookwyrm/views.py index 7c27eade..c5c40bfd 100644 --- a/bookwyrm/views.py +++ b/bookwyrm/views.py @@ -234,7 +234,6 @@ def login_page(request): # send user to the login page data = { 'title': 'Login', - 'site_settings': models.SiteSettings.get(), 'login_form': forms.LoginForm(), 'register_form': forms.RegisterForm(), } @@ -246,7 +245,6 @@ def about_page(request): ''' more information about the instance ''' data = { 'title': 'About', - 'site_settings': models.SiteSettings.get(), } return TemplateResponse(request, 'about.html', data) @@ -294,7 +292,6 @@ def invite_page(request, code): data = { 'title': 'Join', - 'site_settings': models.SiteSettings.get(), 'register_form': forms.RegisterForm(), 'invite': invite, }