diff --git a/campaigns/views.py b/campaigns/views.py index cdd0c92..424b52c 100644 --- a/campaigns/views.py +++ b/campaigns/views.py @@ -70,7 +70,7 @@ class CampaignDeleteView(generic.DeleteView): """ broken at the moment """ - template_name = "common/confirm_delete.html" + template_name = "common/confirm_delete.jinja" model = Campaign slug_url_kwarg = "campslug" success_url = reverse_lazy('campaigndetail') diff --git a/characters/templates/characters/detail.jinja b/characters/templates/characters/detail.jinja index 0089fab..0f3ca95 100644 --- a/characters/templates/characters/detail.jinja +++ b/characters/templates/characters/detail.jinja @@ -1,16 +1,17 @@ {% extends "tenantbase.jinja" %} +{% import "macros.jinja" as macros %} {% block content %}
{% trans %}Add Character{% endtrans %} @@ -18,14 +19,13 @@
{% if character.smaller_image %} - {# {% thumbnail character.smaller_image "150x150" crop="center" as im %}#} - {# #} - {# #} - {# #} - {# {% endthumbnail %}#} + {% set im=thumbnail(character.smaller_image, "150x150", crop="center") %} + + + {% else %}
{{ character.initials }}
@@ -47,7 +47,7 @@ {% endif %} {% if character.faction %}
{{ _("Faction") }}:
-
{{ character.faction.name }}
+
{{ character.faction.name }}
{% endif %} {{ character.description_html|safe }} diff --git a/characters/views.py b/characters/views.py index d126e06..249d43a 100644 --- a/characters/views.py +++ b/characters/views.py @@ -30,14 +30,14 @@ class CharacterDetailView(generic.DetailView): class CharacterCreateView(generic.CreateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = Character form_class = CharacterForm context_object_name = "object" class CharacterEditView(generic.UpdateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = Character form_class = CharacterForm @@ -48,6 +48,6 @@ class CharacterEditView(generic.UpdateView): class CharacterDeleteView(generic.DeleteView): - template_name = "common/confirm_delete.html" + template_name = "common/confirm_delete.jinja" model = Character success_url = reverse_lazy('characterlist') diff --git a/common/templatetags/formatters.py b/common/templatetags/formatters.py index 65c18d3..dd1b136 100644 --- a/common/templatetags/formatters.py +++ b/common/templatetags/formatters.py @@ -1,16 +1,14 @@ -from django import template from django.template.defaultfilters import safe +from django_jinja import library from utils.money import format_money as money_formatter -register = template.Library() - -@register.filter() +@library.filter() def format_money(money): return money_formatter(money) -@register.filter() +@library.filter() def format_money_html(money): return safe(money_formatter(money, html=True)) diff --git a/common/templatetags/language.py b/common/templatetags/language.py new file mode 100644 index 0000000..734f262 --- /dev/null +++ b/common/templatetags/language.py @@ -0,0 +1,14 @@ +from django.utils import translation +from django_jinja import library + +from rpg_notes.settings import LANGUAGES + + +@library.global_function() +def language_code(): + return translation.get_language() + + +@library.global_function() +def all_languages(): + return LANGUAGES diff --git a/common/templatetags/thumbnails.py b/common/templatetags/thumbnails.py index bb58a29..fa1f6b3 100644 --- a/common/templatetags/thumbnails.py +++ b/common/templatetags/thumbnails.py @@ -1,11 +1,9 @@ -from django import template -from sorl.thumbnail.templatetags.thumbnail import resolution from django_jinja import library from sorl.thumbnail import get_thumbnail +from sorl.thumbnail.templatetags.thumbnail import resolution from rpg_notes import settings -register = template.Library() @library.global_function def thumbnail(*args, **kwargs): diff --git a/common/templatetags/urls.py b/common/templatetags/urls.py index 1a87c0c..806a431 100644 --- a/common/templatetags/urls.py +++ b/common/templatetags/urls.py @@ -1,11 +1,9 @@ -from django import template +from django_jinja import library from rpg_notes.settings import DEBUG, DOMAIN -register = template.Library() - -@register.simple_tag +@library.global_function def main_url(): protocol = "http" if DEBUG else "https" return f"{protocol}://{DOMAIN}" diff --git a/common/templatetags/version.py b/common/templatetags/version.py index a35fb21..fa8fec0 100644 --- a/common/templatetags/version.py +++ b/common/templatetags/version.py @@ -1,12 +1,12 @@ +from functools import lru_cache from subprocess import run -from django import template from django.core.cache import cache - -register = template.Library() +from django_jinja import library -@register.simple_tag +@library.global_function +@lru_cache(maxsize=None) def commit_id(): commit = cache.get("commit") if not commit: diff --git a/common/views.py b/common/views.py index 6762545..5f4c0e9 100644 --- a/common/views.py +++ b/common/views.py @@ -1,6 +1,7 @@ from django.http import HttpResponse from django.shortcuts import render from django.views.generic import TemplateView +from django_jinja.views import ServerError from ipware import get_client_ip from sentry_sdk import last_event_id @@ -13,7 +14,7 @@ class PublicHomepageView(TemplateView): class LanguageSelectView(TemplateView): - template_name = "common/languageselect.html" + template_name = "common/languageselect.jinja" def print_ip(request): @@ -32,9 +33,8 @@ def debug_css_sourcemap(request): css, source_map = get_css(debug=True) return HttpResponse(source_map, content_type="application/json") - def handler500(request, *args, **argv): - return render(request, "500.html", { + return render(request, "500.jinja", { "sentry_event_id": last_event_id(), "sentry_dsn": SENTRY_DSN }, status=500) diff --git a/days/templates/days/day_detail.html b/days/templates/days/day_detail.jinja similarity index 53% rename from days/templates/days/day_detail.html rename to days/templates/days/day_detail.jinja index 27a4060..d548e75 100644 --- a/days/templates/days/day_detail.html +++ b/days/templates/days/day_detail.jinja @@ -1,6 +1,5 @@ -{% extends "tenantbase.html" %} -{% load i18n %} -{% load humanize %} +{% extends "tenantbase.jinja" %} +{% import "macros.jinja" as macros %} {% block content %}
@@ -8,34 +7,31 @@ - {% translate "Add Day" %} + {{ _("Add Day") }}
{{ day.description_html|safe }}
-
{% translate "Sessions" %}:
-
{{ day.sessions.all|join:", " }}
+
{{ _("Sessions") }}:
+
{{ day.sessions.all()|join(", ") }}
-
- {% translate "Last updated" %}: {{ day.last_modified|naturaltime }} - {% translate "by" %} {{ day.history.first.history_user }} -
+ {{ macros.last_edited(day) }}
{% endblock %} diff --git a/days/views.py b/days/views.py index 64a0557..4d9b623 100644 --- a/days/views.py +++ b/days/views.py @@ -14,7 +14,7 @@ def list_day_redirect(request, *args, **kwargs): class DayDetailView(generic.DetailView): - template_name = "days/day_detail.html" + template_name = "days/day_detail.jinja" model = IngameDay context_object_name = "day" @@ -28,14 +28,14 @@ class DayDetailView(generic.DetailView): class DayCreateView(generic.CreateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = IngameDay form_class = DayForm context_object_name = "object" class DayEditView(generic.UpdateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = IngameDay form_class = DayForm @@ -49,7 +49,7 @@ class DayEditView(generic.UpdateView): class DayDeleteView(generic.DeleteView): - template_name = "common/confirm_delete.html" + template_name = "common/confirm_delete.jinja" model = IngameDay success_url = reverse_lazy('daylist') diff --git a/factions/templates/factions/detail.html b/factions/templates/factions/detail.jinja similarity index 52% rename from factions/templates/factions/detail.html rename to factions/templates/factions/detail.jinja index 5829215..c25aae5 100644 --- a/factions/templates/factions/detail.html +++ b/factions/templates/factions/detail.jinja @@ -1,6 +1,5 @@ -{% extends "tenantbase.html" %} -{% load i18n %} -{% load humanize %} +{% extends "tenantbase.jinja" %} +{% import "macros.jinja" as macros %} {% block content %}
@@ -8,37 +7,34 @@ - {% translate "Add Faction" %} + {{ _("Add Faction") }}
-
{% translate "Members" %}:
+
{{ _("Members") }}:
- {% for char in faction.characters.all %} - {{ char.name }} + {% for char in faction.characters.all() %} + {{ char.name }} {% endfor %}
{{ faction.description_html|safe }} -
- {% translate "Last updated" %}: {{ faction.last_modified|naturaltime }} - {% translate "by" %} {{ faction.history.first.history_user }} -
+ {{ macros.last_edited(faction) }}
{% endblock %} diff --git a/factions/views.py b/factions/views.py index 6e3ecf6..a660f24 100644 --- a/factions/views.py +++ b/factions/views.py @@ -15,7 +15,7 @@ def list_faction_redirect(request, *args, **kwargs): class FactionDetailView(generic.DetailView): - template_name = "factions/detail.html" + template_name = "factions/detail.jinja" model = Faction context_object_name = "faction" @@ -26,14 +26,14 @@ class FactionDetailView(generic.DetailView): class FactionCreateView(generic.CreateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = Faction form_class = FactionForm context_object_name = "object" class FactionEditView(generic.UpdateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = Faction form_class = FactionForm @@ -44,6 +44,6 @@ class FactionEditView(generic.UpdateView): class FactionDeleteView(generic.DeleteView): - template_name = "common/confirm_delete.html" + template_name = "common/confirm_delete.jinja" model = Faction success_url = reverse_lazy('factionlist') diff --git a/locale/de/LC_MESSAGES/django.po b/locale/de/LC_MESSAGES/django.po index e2ae8b2..62a2a61 100644 --- a/locale/de/LC_MESSAGES/django.po +++ b/locale/de/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2021-10-15 19:45+0200\n" +"POT-Creation-Date: 2021-10-15 20:50+0200\n" "PO-Revision-Date: 2021-10-03 17:19+0200\n" "Last-Translator: Lukas Winkler \n" "Language-Team: \n" @@ -32,16 +32,16 @@ msgid "Add new campaign" msgstr "Neue Campagne erstellen" #: campaigns/templates/campaigns/campaign_edit.jinja:9 -#: loot/templates/loot/edit.html:29 loot/templates/loot/edit.html:32 +#: loot/templates/loot/edit.jinja:25 loot/templates/loot/edit.jinja:28 msgid "Add" msgstr "Hinzufügen" #: campaigns/templates/campaigns/campaign_overview.jinja:3 -#: campaigns/templates/campaigns/campaign_overview.jinja:8 +#: campaigns/templates/campaigns/campaign_overview.jinja:9 msgid "Campaign Overview" msgstr "Kampagnenübersicht" -#: campaigns/templates/campaigns/campaign_overview.jinja:13 +#: campaigns/templates/campaigns/campaign_overview.jinja:14 msgid "create Campaign" msgstr "Campaign erstellen" @@ -53,7 +53,7 @@ msgstr "Spitzname" msgid "Subtitle" msgstr "Untertitel" -#: characters/models.py:26 characters/templates/characters/detail.html:48 +#: characters/models.py:26 characters/templates/characters/detail.jinja:45 msgid "Player" msgstr "Spieler" @@ -61,13 +61,13 @@ msgstr "Spieler" msgid "If no player is selected, this character is considered an NPC." msgstr "Wenn kein Spieler ausgewählt ist, ist dies ein NPC." -#: characters/models.py:32 characters/templates/characters/detail.html:52 +#: characters/models.py:32 characters/templates/characters/detail.jinja:49 #: factions/models.py:15 msgid "Faction" msgstr "Fraktion" #: characters/models.py:36 locations/models.py:25 loot/models.py:24 -#: loot/templates/loot/overview.html:19 +#: loot/templates/loot/overview.jinja:17 msgid "Location" msgstr "Ort" @@ -96,30 +96,27 @@ msgstr "Charakter" msgid "Characters" msgstr "Charaktere" -#: characters/templates/characters/detail.html:20 +#: characters/templates/characters/detail.jinja:17 msgid "Add Character" msgstr "Charakter hinzufügen" -#: characters/templates/characters/detail.html:41 -#: days/templates/days/day_detail.html:25 +#: characters/templates/characters/detail.jinja:38 +#: days/templates/days/day_detail.jinja:24 #: factions/templates/factions/detail.html:25 -#: loot/templates/loot/overview.html:54 +#: locations/templates/locations/detail.jinja:22 +#: loot/templates/loot/overview.jinja:51 msgid "Edit" msgstr "Bearbeiten" -#: characters/templates/characters/detail.html:70 -#: days/templates/days/day_detail.html:36 +#: characters/templates/characters/detail.jinja:66 #: factions/templates/factions/detail.html:39 -#: locations/templates/locations/detail.html:71 -#: notes/templates/notes/detail.html:61 +#: notes/templates/notes/detail.html:61 templates/macros.jinja:28 msgid "Last updated" msgstr "Zuletzt geändert" -#: characters/templates/characters/detail.html:71 -#: days/templates/days/day_detail.html:37 +#: characters/templates/characters/detail.jinja:67 #: factions/templates/factions/detail.html:40 -#: locations/templates/locations/detail.html:72 -#: notes/templates/notes/detail.html:62 +#: notes/templates/notes/detail.html:62 templates/macros.jinja:29 msgid "by" msgstr "von" @@ -139,7 +136,7 @@ msgstr "Datum" msgid "Session" msgstr "Session" -#: days/models.py:17 days/templates/days/day_detail.html:31 +#: days/models.py:17 days/templates/days/day_detail.jinja:30 msgid "Sessions" msgstr "Sessions" @@ -155,7 +152,7 @@ msgstr "Tage" msgid "day" msgstr "Tag" -#: days/templates/days/day_detail.html:18 +#: days/templates/days/day_detail.jinja:17 msgid "Add Day" msgstr "Tag hinzufügen" @@ -172,7 +169,7 @@ msgstr "Fraktion hinzufügen" msgid "Members" msgstr "Mitglieder" -#: locations/models.py:18 locations/templates/locations/detail.html:44 +#: locations/models.py:18 locations/templates/locations/detail.jinja:41 #: notes/models.py:18 notes/templates/notes/detail.html:44 msgid "Part of" msgstr "Teil von" @@ -188,15 +185,15 @@ msgstr "Token Bild" msgid "Locations" msgstr "Orte" -#: locations/templates/locations/detail.html:18 +#: locations/templates/locations/detail.jinja:15 msgid "Add Location" msgstr "Ort hinzufügen" -#: locations/templates/locations/detail.html:48 +#: locations/templates/locations/detail.jinja:45 msgid "Contains" msgstr "" -#: loot/models.py:12 loot/templates/loot/overview.html:16 +#: loot/models.py:12 loot/templates/loot/overview.jinja:14 msgid "Quantity" msgstr "Anzahl" @@ -208,7 +205,7 @@ msgstr "Wert (Gold)" msgid "Weight (lb)" msgstr "Gewicht (lb)" -#: loot/models.py:18 loot/templates/loot/overview.html:18 +#: loot/models.py:18 loot/templates/loot/overview.jinja:16 msgid "Claimant" msgstr "Beansprucht von" @@ -216,56 +213,52 @@ msgstr "Beansprucht von" msgid "Magic Item" msgstr "Magisches Item" -#: loot/models.py:31 loot/models.py:32 loot/templates/loot/overview.html:5 -#: loot/templates/loot/overview.html:8 templates/tenantbase.html:45 +#: loot/models.py:31 loot/models.py:32 loot/templates/loot/overview.jinja:3 +#: loot/templates/loot/overview.jinja:6 templates/tenantbase.html:45 #: templates/tenantbase.jinja:42 msgid "Loot" msgstr "Loot" -#: loot/templates/loot/edit.html:8 +#: loot/templates/loot/edit.jinja:5 #, python-format msgid "Edit \"%(name)s\"" msgstr "\"%(name)s\" bearbeiten" -#: loot/templates/loot/edit.html:10 loot/templates/loot/edit.html:12 -#: loot/templates/loot/edit.html:14 loot/templates/loot/edit.html:16 +#: loot/templates/loot/edit.jinja:7 loot/templates/loot/edit.jinja:9 +#: loot/templates/loot/edit.jinja:11 loot/templates/loot/edit.jinja:13 msgid "Delete" msgstr "Löschen" -#: loot/templates/loot/edit.html:19 +#: loot/templates/loot/edit.jinja:16 msgid "Add new" msgstr "Neu erstellen" -#: loot/templates/loot/edit.html:29 loot/templates/loot/edit.html:32 +#: loot/templates/loot/edit.jinja:25 loot/templates/loot/edit.jinja:28 #: templates/common/languageselect.html:19 #: templates/registration/registration_form.html:13 #: users/templates/users/edit.html:13 msgid "Save" msgstr "Speichern" -#: loot/templates/loot/overview.html:15 +#: loot/templates/loot/overview.jinja:13 msgid "Item" msgstr "Objekt" -#: loot/templates/loot/overview.html:17 loot/templates/loot/overview.html:74 +#: loot/templates/loot/overview.jinja:15 loot/templates/loot/overview.jinja:72 msgid "Total Value" msgstr "Gesamtwert" -#: loot/templates/loot/overview.html:41 -msgid "Nobody" -msgstr "Niemand" - -#: loot/templates/loot/overview.html:58 +#: loot/templates/loot/overview.jinja:56 msgid "Value each" msgstr "Wert pro Stück" -#: loot/templates/loot/overview.html:62 +#: loot/templates/loot/overview.jinja:60 #, fuzzy #| msgid "Weight (lb)" msgid "Weight" msgstr "Gewicht (lb)" -#: loot/templates/loot/overview.html:77 +#: loot/templates/loot/overview.jinja:75 msgid "Add Loot" msgstr "Loot hinzufügen" @@ -282,11 +275,11 @@ msgstr "Notizen" msgid "Add Note" msgstr "Notiz hinzufügen" -#: rpg_notes/settings.py:194 +#: rpg_notes/settings.py:195 msgid "German" msgstr "Deutsch" -#: rpg_notes/settings.py:195 +#: rpg_notes/settings.py:196 msgid "English" msgstr "Englisch" @@ -310,10 +303,6 @@ msgstr "Abmelden" msgid "Log in" msgstr "Anmelden" -#: templates/base.jinja:42 -msgid "test" -msgstr "" - #: templates/common/homepage.jinja:8 msgid "" "An experimental, collaborative note taking app and wiki optimized for RPG " @@ -399,3 +388,6 @@ msgstr "" #: users/views.py:61 msgid "User account was updated successfully" msgstr "" + +#~ msgid "Nobody" +#~ msgstr "Niemand" diff --git a/locations/templates/locations/detail.html b/locations/templates/locations/detail.jinja similarity index 54% rename from locations/templates/locations/detail.html rename to locations/templates/locations/detail.jinja index f7d36d0..867fbfa 100644 --- a/locations/templates/locations/detail.html +++ b/locations/templates/locations/detail.jinja @@ -1,8 +1,5 @@ -{% extends "tenantbase.html" %} -{% load i18n %} -{% load thumbutils %} -{% load thumbnail %} -{% load humanize %} +{% extends "tenantbase.jinja" %} +{% import "macros.jinja" as macros %} {% block content %}

{{ location.name }} - - edit + + {{ _("Edit") }}

{% endblock %} diff --git a/locations/views.py b/locations/views.py index 5af6fa9..6d9504a 100644 --- a/locations/views.py +++ b/locations/views.py @@ -15,7 +15,7 @@ def list_location_redirect(request, *args, **kwargs): class LocationDetailView(generic.DetailView): - template_name = "locations/detail.html" + template_name = "locations/detail.jinja" model = Location context_object_name = "location" @@ -26,14 +26,14 @@ class LocationDetailView(generic.DetailView): class LocationCreateView(generic.CreateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = Location form_class = LocationForm context_object_name = "object" class LocationEditView(generic.UpdateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = Location form_class = LocationForm @@ -44,6 +44,6 @@ class LocationEditView(generic.UpdateView): class LocationDeleteView(generic.DeleteView): - template_name = "common/confirm_delete.html" + template_name = "common/confirm_delete.jinja" model = Location success_url = reverse_lazy('locationlist') diff --git a/loot/templates/loot/edit.html b/loot/templates/loot/edit.html deleted file mode 100644 index f09df2c..0000000 --- a/loot/templates/loot/edit.html +++ /dev/null @@ -1,41 +0,0 @@ -{% extends 'tenantbase.html' %} -{% load i18n %} -{% load django_bootstrap5 %} -{% load static %} - -{% block heading %} - {% if edit %} -

{% blocktrans with name=object.name %}Edit "{{ name }}"{% endblocktrans %}

- {% if request.resolver_match.view_name == "lootedit" %} - {% translate "Delete" %} - {% elif request.resolver_match.view_name == "dayedit" %} - {% translate "Delete" %} - {% elif request.resolver_match.view_name == "locationedit" %} - {% translate "Delete" %} - {% elif request.resolver_match.view_name == "characteredit" %} - {% translate "Delete" %} - {% endif %} - {% else %} -

{% translate "Add new" %}

- {% endif %} -{% endblock %} - -{% block content %} - -
- {% csrf_token %} - - {% bootstrap_form form %} - -
-{% endblock %} - -{% block extra_js %} - - - - -{% endblock %} diff --git a/loot/templates/loot/edit.jinja b/loot/templates/loot/edit.jinja new file mode 100644 index 0000000..afd2d69 --- /dev/null +++ b/loot/templates/loot/edit.jinja @@ -0,0 +1,37 @@ +{% extends 'tenantbase.jinja' %} + +{% block heading %} + {% if edit %} +

{% trans name=object.name %}Edit "{{ name }}"{% endtrans %}

+ {% if request.resolver_match.view_name == "lootedit" %} + {{ _("Delete") }} + {% elif request.resolver_match.view_name == "dayedit" %} + {{ _("Delete") }} + {% elif request.resolver_match.view_name == "locationedit" %} + {{ _("Delete") }} + {% elif request.resolver_match.view_name == "characteredit" %} + {{ _("Delete") }} + {% endif %} + {% else %} +

{{ _("Add new") }}

+ {% endif %} +{% endblock %} + +{% block content %} + +
+ {% csrf_token %} + + {{ bootstrap_form(form) }} + +
+{% endblock %} + +{% block extra_js %} + + + + +{% endblock %} diff --git a/loot/templates/loot/overview.html b/loot/templates/loot/overview.jinja similarity index 73% rename from loot/templates/loot/overview.html rename to loot/templates/loot/overview.jinja index 4c71160..1e08943 100644 --- a/loot/templates/loot/overview.html +++ b/loot/templates/loot/overview.jinja @@ -1,22 +1,20 @@ -{% extends "tenantbase.html" %} -{% load i18n %} -{% load formatters %} +{% extends "tenantbase.jinja" %} -{% block title %}{% translate "Loot" %}{% endblock %} +{% block title %}{% trans %}Loot{% endtrans %} {% endblock %} {% block heading %} -

{% translate "Loot" %}

+

{% trans %}Loot{% endtrans %}

{% endblock %} {% block content %} - - - - - + + + + + @@ -38,9 +36,8 @@ - {% trans 'Nobody' as nobody %} - - + +
{% translate "Item" %}{% translate "Quantity" %}{% translate "Total Value" %}{% translate "Claimant" %}{% translate "Location" %}{{ _("Item") }}{{ _("Quantity") }}{{ _("Total Value") }}{{ _("Claimant") }}{{ _("Location") }}
{{ l.name }} {{ l.quantity }} {{ l.value_gold|format_money_html }}{{ l.owner|default:nobody }}{{ l.location|default:"" }}{{ l.owner|default(_('Nobody')) }}{{ l.location|default("") }} @@ -51,15 +48,16 @@
-

{{ l.name }} {% translate "Edit" %}

+

{{ l.name }} {{ _("Edit") }} +

{{ l.description_html|safe }}
{% if l.value_per_unit and l.quantity > 1 %} -
{% translate "Value each" %}
+
{{ _("Value each") }}
{{ l.value_per_unit|format_money_html }}
{% endif %} {% if l.weight %} -
{% translate "Weight" %}
+
{{ _("Weight") }}
{{ l.weight }} lb
{% endif %}
@@ -71,10 +69,10 @@
-
{% translate "Total Value" %}:
+
{{ _("Total Value") }}:
{{ total_value|format_money_html }}
- {% translate "Add Loot" %} + {{ _("Add Loot") }} {% endblock %} diff --git a/loot/views.py b/loot/views.py index 6df7175..15e578c 100644 --- a/loot/views.py +++ b/loot/views.py @@ -7,7 +7,7 @@ from loot.models import Loot class LootListView(generic.ListView): - template_name = "loot/overview.html" + template_name = "loot/overview.jinja" model = Loot context_object_name = "loot" @@ -24,7 +24,7 @@ class LootListView(generic.ListView): class LootCreateView(generic.CreateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = Loot form_class = LootForm @@ -32,7 +32,7 @@ class LootCreateView(generic.CreateView): class LootEditView(generic.UpdateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = Loot form_class = LootForm context_object_name = "object" @@ -46,7 +46,7 @@ class LootEditView(generic.UpdateView): class LootDeleteView(generic.DeleteView): - template_name = "common/confirm_delete.html" + template_name = "common/confirm_delete.jinja" model = Loot success_url = reverse_lazy("lootlist") diff --git a/notes/templates/notes/detail.html b/notes/templates/notes/detail.jinja similarity index 53% rename from notes/templates/notes/detail.html rename to notes/templates/notes/detail.jinja index 03e7fd5..d8a0f78 100644 --- a/notes/templates/notes/detail.html +++ b/notes/templates/notes/detail.jinja @@ -1,8 +1,5 @@ -{% extends "tenantbase.html" %} -{% load i18n %} -{% load thumbutils %} -{% load thumbnail %} -{% load humanize %} +{% extends "tenantbase.jinja" %} +{% import "macros.jinja" as macros %} {% block content %}

{{ note.name }} - - edit + + {{ _("Edit") }}

{% endblock %} diff --git a/notes/views.py b/notes/views.py index a2853fc..2aed39f 100644 --- a/notes/views.py +++ b/notes/views.py @@ -15,7 +15,7 @@ def list_note_redirect(request, *args, **kwargs): class NoteDetailView(generic.DetailView): - template_name = "notes/detail.html" + template_name = "notes/detail.jinja" model = Note context_object_name = "note" @@ -26,14 +26,14 @@ class NoteDetailView(generic.DetailView): class NoteCreateView(generic.CreateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = Note form_class = NoteForm context_object_name = "object" class NoteEditView(generic.UpdateView): - template_name = "loot/edit.html" + template_name = "loot/edit.jinja" model = Note form_class = NoteForm @@ -44,6 +44,6 @@ class NoteEditView(generic.UpdateView): class NoteDeleteView(generic.DeleteView): - template_name = "common/confirm_delete.html" + template_name = "common/confirm_delete.jinja" model = Note success_url = reverse_lazy('notelist') diff --git a/rpg_notes/settings.py b/rpg_notes/settings.py index c052013..37f11b3 100644 --- a/rpg_notes/settings.py +++ b/rpg_notes/settings.py @@ -126,10 +126,9 @@ TEMPLATES = [ # 'jdj_tags.extensions.DjangoCompat', # ] 'context_processors': [ - 'django.template.context_processors.request', - 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', + 'django.template.context_processors.debug', 'django.contrib.messages.context_processors.messages', ], "bytecode_cache": { diff --git a/rpg_notes/urls.py b/rpg_notes/urls.py index 2821123..4a69131 100644 --- a/rpg_notes/urls.py +++ b/rpg_notes/urls.py @@ -7,7 +7,7 @@ from common import views from rpg_notes import settings urlpatterns = [ - path('', include('django.contrib.auth.urls')), + path('', include('rpg_notes.urls_auth')), path('i18n/', include('django.conf.urls.i18n')), path("language/", views.LanguageSelectView.as_view(), name="change_language"), # path("ip", views.print_ip, name="ip"), diff --git a/rpg_notes/urls_auth.py b/rpg_notes/urls_auth.py new file mode 100644 index 0000000..907f974 --- /dev/null +++ b/rpg_notes/urls_auth.py @@ -0,0 +1,25 @@ +# The views used below are normally mapped in the AdminSite instance. +# This URLs file is used to provide a reliable view deployment for test purposes. +# It is also provided as a convenience to those who want to deploy these URLs +# elsewhere. + +from django.contrib.auth import views +from django.urls import path + + +class CustomLoginView(views.LoginView): + template_name = "registration/login.jinja" + + +urlpatterns = [ + path('login/', CustomLoginView.as_view(), name='login'), + path('logout/', views.LogoutView.as_view(), name='logout'), + + path('password_change/', views.PasswordChangeView.as_view(), name='password_change'), + path('password_change/done/', views.PasswordChangeDoneView.as_view(), name='password_change_done'), + + path('password_reset/', views.PasswordResetView.as_view(), name='password_reset'), + path('password_reset/done/', views.PasswordResetDoneView.as_view(), name='password_reset_done'), + path('reset///', views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'), + path('reset/done/', views.PasswordResetCompleteView.as_view(), name='password_reset_complete'), +] diff --git a/rpg_notes/urls_public.py b/rpg_notes/urls_public.py index 265eb92..943a33b 100644 --- a/rpg_notes/urls_public.py +++ b/rpg_notes/urls_public.py @@ -2,6 +2,7 @@ import debug_toolbar from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include +from django_jinja.views import PermissionDenied from common import views from rpg_notes import settings @@ -9,7 +10,7 @@ from users import views as user_views urlpatterns = [ path('', include('users.urls')), - path('', include('django.contrib.auth.urls')), + path('', include('rpg_notes.urls_auth')), path('', views.PublicHomepageView.as_view()), path("profile/", user_views.UserEditView.as_view(), name="edit_profile"), path('admin/', admin.site.urls), diff --git a/templates/403.html b/templates/403.jinja similarity index 90% rename from templates/403.html rename to templates/403.jinja index 186c0d9..f50c14f 100644 --- a/templates/403.html +++ b/templates/403.jinja @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base.jinja" %} {% load i18n %} {% load urls %} diff --git a/templates/500.html b/templates/500.jinja similarity index 70% rename from templates/500.html rename to templates/500.jinja index 4b075d0..ad2e9e2 100644 --- a/templates/500.html +++ b/templates/500.jinja @@ -1,4 +1,4 @@ -{% extends "base.html" %} +{% extends "base.jinja" %} {% block mainpage %} diff --git a/templates/base.html b/templates/base.html deleted file mode 100644 index a70835e..0000000 --- a/templates/base.html +++ /dev/null @@ -1,68 +0,0 @@ -{% load i18n %} -{% load version %} -{% load django_bootstrap5 %} -{% load static %} - - - - - - - - {% block title %}{% endblock %} - RPGnotes - - - {% if debug %} - - {% else %} - - {% endif %} - - - -
- {% bootstrap_messages %} - {% block mainpage %}{% endblock %} -
- - - - - -{% if sentry_event_id %} - - -{% endif %} -{% block extra_js %}{% endblock %} - - diff --git a/templates/base.jinja b/templates/base.jinja index fdd41c7..9ebc79f 100644 --- a/templates/base.jinja +++ b/templates/base.jinja @@ -54,8 +54,7 @@ {% endif %} {% block extra_js %}{% endblock %} diff --git a/templates/common/confirm_delete.html b/templates/common/confirm_delete.jinja similarity index 71% rename from templates/common/confirm_delete.html rename to templates/common/confirm_delete.jinja index ca44e17..17bd0b5 100644 --- a/templates/common/confirm_delete.html +++ b/templates/common/confirm_delete.jinja @@ -1,6 +1,4 @@ -{% extends 'tenantbase.html' %} -{% load django_bootstrap5 %} -{% load static %} +{% extends 'tenantbase.jinja' %} {% block heading %}

Delete Object

@@ -11,4 +9,5 @@
{% csrf_token %}

Are you sure you want to delete "{{ object }}"?

-
{% endblock %} + +{% endblock %} diff --git a/templates/common/languageselect.html b/templates/common/languageselect.html deleted file mode 100644 index e9a0f98..0000000 --- a/templates/common/languageselect.html +++ /dev/null @@ -1,22 +0,0 @@ -{% extends "tenantbase.html" %} -{% load i18n %} - - -{% block content %} -

{% translate "Change Language" %}

-
{% csrf_token %} -
- - -
-
-{% endblock %} diff --git a/templates/common/languageselect.jinja b/templates/common/languageselect.jinja new file mode 100644 index 0000000..25b4d6e --- /dev/null +++ b/templates/common/languageselect.jinja @@ -0,0 +1,20 @@ +{% extends "tenantbase.jinja" %} + +{% block title %}{{ _("Change Language") }} - RPGnotes{% endblock %} + +{% block content %} +

{{ _("Change Language") }}

+
{% csrf_token %} +
+ + +
+
+{% endblock %} diff --git a/templates/macros.jinja b/templates/macros.jinja index e69de29..bc3becd 100644 --- a/templates/macros.jinja +++ b/templates/macros.jinja @@ -0,0 +1,31 @@ +{% macro character_pillar(character) %} + +{% endmacro %} + +{% macro last_edited(obj) %} +
+ {{ _("Last updated") }}: {{ obj.last_modified|naturaltime }} + {{ _("by") }} {{ obj.history.first().history_user }} +
+{% endmacro %} diff --git a/templates/macros/character-pillar.html b/templates/macros/character-pillar.html deleted file mode 100644 index 69bb374..0000000 --- a/templates/macros/character-pillar.html +++ /dev/null @@ -1,25 +0,0 @@ -{% load thumbutils %} -{% load thumbnail %} - diff --git a/templates/registration/activation_failed.html b/templates/registration/activation_failed.html deleted file mode 100644 index 2ff8ad3..0000000 --- a/templates/registration/activation_failed.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends 'base.html' %} -{% load i18n %} - -{% block mainpage %} -

{% translate "Activation failed" %}

-

Maybe this activation link has already been clicked before.

-{% endblock %} - diff --git a/templates/registration/activation_failed.jinja b/templates/registration/activation_failed.jinja new file mode 100644 index 0000000..b2e213a --- /dev/null +++ b/templates/registration/activation_failed.jinja @@ -0,0 +1,8 @@ +{% extends 'base.jinja' %} +{% load i18n %} + +{% block mainpage %} +

{% trans %}Activation failed{% endtrans %}

+

{% trans %}Maybe this activation link has already been clicked before.{% endtrans %}

+{% endblock %} + diff --git a/templates/registration/login.html b/templates/registration/login.html deleted file mode 100644 index b8db056..0000000 --- a/templates/registration/login.html +++ /dev/null @@ -1,28 +0,0 @@ -{% extends "base.html" %} -{% load i18n %} -{% load django_bootstrap5 %} -{% load static %} - - - -{% block mainpage %} -

{% translate "Login" %}

- - {% if next %} -
- {% blocktranslate %}You need to log in before you can access {{ next }}.{% endblocktranslate %} -
- {% endif %} - -
- {% csrf_token %} - {% bootstrap_form form %} - {% url 'admin_password_reset' as password_reset_url %} - - -
-{% endblock %} diff --git a/templates/registration/login.jinja b/templates/registration/login.jinja new file mode 100644 index 0000000..8dbb229 --- /dev/null +++ b/templates/registration/login.jinja @@ -0,0 +1,24 @@ +{% extends "base.jinja" %} + + + +{% block mainpage %} +

{{ _("Login") }}

+ + {% if next %} +
+ {% trans %}You need to log in before you can access {{ next }}.{% endtrans %} +
+ {% endif %} + +
+ {% csrf_token %} + {{ bootstrap_form(form) }} + + +
+{% endblock %} diff --git a/templates/registration/registration_closed.html b/templates/registration/registration_closed.html deleted file mode 100644 index 4fd6b41..0000000 --- a/templates/registration/registration_closed.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends 'base.html' %} -{% load i18n %} - -{% block mainpage %} -

{% translate "Registration closed" %}

-{% endblock %} - diff --git a/templates/registration/registration_closed.jinja b/templates/registration/registration_closed.jinja new file mode 100644 index 0000000..c9852a1 --- /dev/null +++ b/templates/registration/registration_closed.jinja @@ -0,0 +1,6 @@ +{% extends 'base.jinja' %} + +{% block mainpage %} +

{{ _("Registration closed") }}

+{% endblock %} + diff --git a/templates/registration/registration_complete.html b/templates/registration/registration_complete.html deleted file mode 100644 index f90748b..0000000 --- a/templates/registration/registration_complete.html +++ /dev/null @@ -1,7 +0,0 @@ -{% extends 'base.html' %} -{% load i18n %} - -{% block mainpage %} -

{% translate "Registration complete" %}

-{% endblock %} - diff --git a/templates/registration/registration_complete.jinja b/templates/registration/registration_complete.jinja new file mode 100644 index 0000000..04e59d4 --- /dev/null +++ b/templates/registration/registration_complete.jinja @@ -0,0 +1,6 @@ +{% extends 'base.jinja' %} + +{% block mainpage %} +

{{ _("Registration complete") }}

+{% endblock %} + diff --git a/templates/registration/registration_form.html b/templates/registration/registration_form.html deleted file mode 100644 index 61049ba..0000000 --- a/templates/registration/registration_form.html +++ /dev/null @@ -1,15 +0,0 @@ -{% extends 'base.html' %} -{% load i18n %} -{% load django_bootstrap5 %} -{% load static %} - - -{% block mainpage %} -

{% translate "Registration" %}

- -
- {% csrf_token %} - {% bootstrap_form form %} - -
-{% endblock %} diff --git a/templates/registration/registration_form.jinja b/templates/registration/registration_form.jinja new file mode 100644 index 0000000..86e7e3e --- /dev/null +++ b/templates/registration/registration_form.jinja @@ -0,0 +1,11 @@ +{% extends 'base.jinja' %} + +{% block mainpage %} +

{{ _("Registration") }}

+ +
+ {% csrf_token %} + {{ bootstrap_form(form) }} + +
+{% endblock %} diff --git a/templates/tenantbase.html b/templates/tenantbase.html deleted file mode 100644 index 4db2c0e..0000000 --- a/templates/tenantbase.html +++ /dev/null @@ -1,77 +0,0 @@ -{% extends "base.html" %} -{% load urls %} -{% load i18n %} -{% load version %} - -{% block title %}{{ object }}{% endblock %} - - -{% block mainpage %} - - {% block heading %}{% endblock %} - - {% block content %} - {% endblock %} -{% endblock %} diff --git a/templates/tenantbase.jinja b/templates/tenantbase.jinja index 92f708e..483b39c 100644 --- a/templates/tenantbase.jinja +++ b/templates/tenantbase.jinja @@ -55,8 +55,8 @@ {% if user.is_staff %}
  • Admin
  • {% endif %} -{#
  • {% trans %}Edit User Account{% endtrans %}
  • #} +
  • {% trans %}Edit User Account{% endtrans %}
  • diff --git a/users/templates/users/edit.html b/users/templates/users/edit.html deleted file mode 100644 index e178adc..0000000 --- a/users/templates/users/edit.html +++ /dev/null @@ -1,16 +0,0 @@ -{% extends 'base.html' %} -{% load i18n %} -{% load django_bootstrap5 %} -{% load static %} - - -{% block mainpage %} -

    {% translate "Edit User Account" %}

    - -
    - {% csrf_token %} - {% bootstrap_form form %} - -
    -{% endblock %} - diff --git a/users/templates/users/edit.jinja b/users/templates/users/edit.jinja new file mode 100644 index 0000000..8397840 --- /dev/null +++ b/users/templates/users/edit.jinja @@ -0,0 +1,13 @@ +{% extends 'base.jinja' %} + + +{% block mainpage %} +

    {{ _("Edit User Account") }}

    + +
    + {{ csrf_token }} + {{ bootstrap_form(form) }} + +
    +{% endblock %} + diff --git a/users/urls.py b/users/urls.py index c399e98..3034849 100644 --- a/users/urls.py +++ b/users/urls.py @@ -17,7 +17,7 @@ urlpatterns = [ path( "register/closed/", TemplateView.as_view( - template_name="registration/registration_closed.html" + template_name="registration/registration_closed.jinja" ), name="django_registration_disallowed", ), diff --git a/users/views.py b/users/views.py index 5ca92ad..4d2a301 100644 --- a/users/views.py +++ b/users/views.py @@ -13,7 +13,7 @@ from users.models import TenantUser class CustomRegistrationView(RegistrationView): email_body_template = "registration/activation_email_body.html" email_subject_template = "registration/activation_email_subject.html" - template_name = "registration/registration_form.html" + template_name = "registration/registration_form.jinja" form_class = CustomRegistrationForm success_url = reverse_lazy("login") @@ -40,7 +40,7 @@ class CustomRegistrationView(RegistrationView): class CustomActivationView(ActivationView): success_url = reverse_lazy("login") - template_name = "registration/activation_failed.html" + template_name = "registration/activation_failed.jinja" def activate(self, *args, **kwargs): username = self.validate_key(kwargs.get("activation_key")) @@ -54,7 +54,7 @@ class CustomActivationView(ActivationView): class UserEditView(SuccessMessageMixin, UpdateView): - template_name = "users/edit.html" + template_name = "users/edit.jinja" model = TenantUser form_class = CustomUserChangeForm success_url = "/"