From 9be993d9ba7cc70e1efe6d4121946cfc966bea44 Mon Sep 17 00:00:00 2001 From: reverend Date: Sat, 19 Dec 2020 15:31:22 +0100 Subject: [PATCH 1/8] New Migrations for release --- .../migrations/0004_release_0_1_3.py | 102 ++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 django_lostplaces/lostplaces/migrations/0004_release_0_1_3.py diff --git a/django_lostplaces/lostplaces/migrations/0004_release_0_1_3.py b/django_lostplaces/lostplaces/migrations/0004_release_0_1_3.py new file mode 100644 index 0000000..e5137a7 --- /dev/null +++ b/django_lostplaces/lostplaces/migrations/0004_release_0_1_3.py @@ -0,0 +1,102 @@ +# Generated by Django 3.1.1 on 2020-12-19 13:53 + +import django.core.validators +from django.db import migrations, models +import django.db.models.deletion +import easy_thumbnails.fields +import lostplaces.models.place + + +class Migration(migrations.Migration): + + dependencies = [ + ('lostplaces', '0003_voucher'), + ] + + operations = [ + migrations.AlterField( + model_name='photoalbum', + name='label', + field=models.CharField(max_length=100, verbose_name='link text'), + ), + migrations.AlterField( + model_name='photoalbum', + name='submitted_by', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='photoalbums', to='lostplaces.explorer', verbose_name='Submitter'), + ), + migrations.AlterField( + model_name='photoalbum', + name='submitted_when', + field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='Submission date'), + ), + migrations.AlterField( + model_name='photoalbum', + name='url', + field=models.URLField(verbose_name='URL'), + ), + migrations.AlterField( + model_name='place', + name='description', + field=models.TextField(help_text="Description of the place: e.g. how to get there, where to be careful, the place's history...", verbose_name='Description'), + ), + migrations.AlterField( + model_name='place', + name='latitude', + field=models.FloatField(help_text='Latitude in decimal format: e. g. 41.40338', validators=[django.core.validators.MinValueValidator(-90), django.core.validators.MaxValueValidator(90)], verbose_name='Latitude'), + ), + migrations.AlterField( + model_name='place', + name='location', + field=models.CharField(max_length=50, verbose_name='Location'), + ), + migrations.AlterField( + model_name='place', + name='longitude', + field=models.FloatField(help_text='Longitude in decimal format: e. g. 2.17403', validators=[django.core.validators.MinValueValidator(-180), django.core.validators.MaxValueValidator(180)], verbose_name='Longitude'), + ), + migrations.AlterField( + model_name='place', + name='name', + field=models.CharField(max_length=50, verbose_name='Name'), + ), + migrations.AlterField( + model_name='place', + name='submitted_by', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='places', to='lostplaces.explorer', verbose_name='Submitter'), + ), + migrations.AlterField( + model_name='place', + name='submitted_when', + field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='Submission date'), + ), + migrations.AlterField( + model_name='placeimage', + name='description', + field=models.TextField(blank=True, verbose_name='Description'), + ), + migrations.AlterField( + model_name='placeimage', + name='filename', + field=easy_thumbnails.fields.ThumbnailerImageField(help_text='Optional: One or more images to upload', upload_to=lostplaces.models.place.generate_image_upload_path, verbose_name='Filename(s)'), + ), + migrations.AlterField( + model_name='placeimage', + name='submitted_by', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='placeimages', to='lostplaces.explorer', verbose_name='Submitter'), + ), + migrations.AlterField( + model_name='placeimage', + name='submitted_when', + field=models.DateTimeField(auto_now_add=True, null=True, verbose_name='Submission date'), + ), + migrations.AlterField( + model_name='voucher', + name='created_when', + field=models.DateTimeField(auto_now_add=True, verbose_name='Creation date'), + ), + migrations.AlterField( + model_name='voucher', + name='expires_when', + field=models.DateTimeField(verbose_name='Expiration date'), + ), + ] From 196fb02436579467527cdc5b35861549fc50ece7 Mon Sep 17 00:00:00 2001 From: reverend Date: Sat, 19 Dec 2020 15:31:29 +0100 Subject: [PATCH 2/8] Release --- django_lostplaces/setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django_lostplaces/setup.py b/django_lostplaces/setup.py index 41d13f4..b2a25da 100755 --- a/django_lostplaces/setup.py +++ b/django_lostplaces/setup.py @@ -8,7 +8,7 @@ with open('../Readme.md') as f: setup( name='django-lostplaces', - version='0.1.2 HotFix', + version='0.1.3', description='A django app to manage lost places', author='Reverend', author_email='reverend@reverend2048.de', From b7524542331529314633a68491be3cb3abe25bdf Mon Sep 17 00:00:00 2001 From: reverend Date: Fri, 2 Apr 2021 17:21:00 +0200 Subject: [PATCH 3/8] #39 Partial for Images --- .../lostplaces/templates/home_unauth.html | 2 +- .../lostplaces/templates/partials/image.html | 14 ++++++++++++++ .../templates/partials/place_teaser.html | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 django_lostplaces/lostplaces/templates/partials/image.html diff --git a/django_lostplaces/lostplaces/templates/home_unauth.html b/django_lostplaces/lostplaces/templates/home_unauth.html index bbd5cf9..6e6ed28 100644 --- a/django_lostplaces/lostplaces/templates/home_unauth.html +++ b/django_lostplaces/lostplaces/templates/home_unauth.html @@ -24,7 +24,7 @@
- + {% include 'partials/image.html' with source_url=place.placeimages.first.filename.thumbnail.url %}
diff --git a/django_lostplaces/lostplaces/templates/partials/image.html b/django_lostplaces/lostplaces/templates/partials/image.html new file mode 100644 index 0000000..2ad0240 --- /dev/null +++ b/django_lostplaces/lostplaces/templates/partials/image.html @@ -0,0 +1,14 @@ +{% if link_url %} + +{% endif %} +
+ {{alt_text}} +
+{% if link_url %}
{% endif %} \ No newline at end of file diff --git a/django_lostplaces/lostplaces/templates/partials/place_teaser.html b/django_lostplaces/lostplaces/templates/partials/place_teaser.html index 15929a5..0083943 100644 --- a/django_lostplaces/lostplaces/templates/partials/place_teaser.html +++ b/django_lostplaces/lostplaces/templates/partials/place_teaser.html @@ -3,7 +3,7 @@
{% if place.placeimages.all|length > 0 %} - + {% include 'partials/image.html' with source_url=place.placeimages.first.filename.thumbnail.url %} {% else %} {% endif %} From bae4e13137ee12a1982bf6f5072adba24c4349bf Mon Sep 17 00:00:00 2001 From: reverend Date: Fri, 2 Apr 2021 17:22:28 +0200 Subject: [PATCH 4/8] Partial for PlaceImageGrid --- .../templates/explorer/profile.html | 21 ++---------- .../templates/partials/placeImageGrid.html | 21 ++++++++++++ .../templates/place/place_detail.html | 32 +++---------------- 3 files changed, 28 insertions(+), 46 deletions(-) create mode 100644 django_lostplaces/lostplaces/templates/partials/placeImageGrid.html diff --git a/django_lostplaces/lostplaces/templates/explorer/profile.html b/django_lostplaces/lostplaces/templates/explorer/profile.html index 4cf7948..68c0072 100644 --- a/django_lostplaces/lostplaces/templates/explorer/profile.html +++ b/django_lostplaces/lostplaces/templates/explorer/profile.html @@ -63,25 +63,8 @@
-

{% trans 'Images submitted by' %} {{explorer.user.username}}

-
-
    - {% for place_image in assets.placeimages.all %} -
  • - - - - {% if user.explorer == place_image.submitted_by%} - - - - - - {% endif %} -
  • - {% endfor %} -
-
+ {% translate 'Images submitted by' as submitted_by %} + {% include 'partials/placeImageGrid.html' with headline=submitted_by|add:' '|add:explorer.user.username image_list=assets.placeimages.all%}
diff --git a/django_lostplaces/lostplaces/templates/partials/placeImageGrid.html b/django_lostplaces/lostplaces/templates/partials/placeImageGrid.html new file mode 100644 index 0000000..7623d04 --- /dev/null +++ b/django_lostplaces/lostplaces/templates/partials/placeImageGrid.html @@ -0,0 +1,21 @@ + {% load static %} + + {% if headline %} +

{{headline}}

+ {% endif %} +
+
    + {% for image in image_list %} +
  • + {% include 'partials/image.html' with source_url=image.filename.thumbnail.url link_url=image.filename.large.url %} + {% if user.explorer == image.submitted_by%} + + + + + + {% endif %} +
  • + {% endfor %} +
+
\ No newline at end of file diff --git a/django_lostplaces/lostplaces/templates/place/place_detail.html b/django_lostplaces/lostplaces/templates/place/place_detail.html index 6d91170..aba45ac 100644 --- a/django_lostplaces/lostplaces/templates/place/place_detail.html +++ b/django_lostplaces/lostplaces/templates/place/place_detail.html @@ -25,9 +25,9 @@

{{ place.name }}

{% if place.placeimages.first.filename.hero.url %} -
- -
+
+ {% include 'partials/image.html' with source_url=place.placeimages.first.filename.hero.url %} +
{% endif %}
@@ -90,30 +90,8 @@
-

{% trans 'Images' %}

-
-
    - {% for place_image in place.placeimages.all %} -
  • - - - - {% if user.explorer == place_image.submitted_by or user.explorer == place.submitted_by %} - - - - - - {% endif %} -
  • - {% endfor %} -
  • - - - -
  • -
-
+ {% translate 'Images' as t_images %} + {% include 'partials/placeImageGrid.html' with headline=t_images image_list=place.placeimages.all%}
From fb1237f11124a37dd540df605df26aca7ada2388 Mon Sep 17 00:00:00 2001 From: reverend Date: Fri, 2 Apr 2021 22:00:13 +0200 Subject: [PATCH 5/8] set variable and partial template tag --- .../templates/place/place_detail.html | 15 ++-- .../lostplaces/templatetags/lostplaces.py | 87 +++++++++++++++++++ 2 files changed, 97 insertions(+), 5 deletions(-) diff --git a/django_lostplaces/lostplaces/templates/place/place_detail.html b/django_lostplaces/lostplaces/templates/place/place_detail.html index aba45ac..20788c6 100644 --- a/django_lostplaces/lostplaces/templates/place/place_detail.html +++ b/django_lostplaces/lostplaces/templates/place/place_detail.html @@ -4,6 +4,7 @@ {% load thumbnail %} {% load svg_icon %} +{% load lostplaces %} {% block additional_head %} @@ -26,7 +27,9 @@

{{ place.name }}

{% if place.placeimages.first.filename.hero.url %}
- {% include 'partials/image.html' with source_url=place.placeimages.first.filename.hero.url %} + {% partial image %} + {% set source_url place.placeimages.first.filename.hero.url %} + {% endpartial %}
{% endif %} @@ -38,13 +41,15 @@
{% url 'place_tag_submit' place_id=place.id as tag_submit_url%} - {% include 'partials/tagging.html' with config=tagging_config %} + {% partial tagging %} + {% set config=tagging_config %} + {% endpartial %}

{% trans 'Map links' %}

- {% include 'partials/osm_map.html' with config=mapping_config%} + {% partial osm_map config=mapping_config %}
- {% translate 'Images' as t_images %} - {% include 'partials/placeImageGrid.html' with headline=t_images image_list=place.placeimages.all%} + {% translate 'Images' as headline %} + {% partial "placeImageGrid" image_list=place.placeimages.all %}
diff --git a/django_lostplaces/lostplaces/templatetags/lostplaces.py b/django_lostplaces/lostplaces/templatetags/lostplaces.py index c2a09d9..1fe3649 100644 --- a/django_lostplaces/lostplaces/templatetags/lostplaces.py +++ b/django_lostplaces/lostplaces/templatetags/lostplaces.py @@ -6,6 +6,15 @@ from django.http import request register = template.Library() +def remove_formatting(string): + for to_strip in ["'", '"', ' ']: + string = string.strip(to_strip) + + for to_remove in ['\t', '\n',]: + string = string.replace(to_remove, '') + + return string + @register.filter(name='proper_paginate') def proper_paginate(paginator, current_page, neighbors=2): if paginator.num_pages > 2*neighbors: @@ -24,3 +33,81 @@ def proper_paginate(paginator, current_page, neighbors=2): page_list = [f for f in range(start_index, end_index+1)] return page_list[:(2*neighbors + 1)] return paginator.page_range + + +class VariableNode(template.Node): + def __init__(self, name, content=None): + if content==None and '=' in name: + self.content = name.split('=')[1] + self.name = name.split('=')[0] + else: + self.content = content + self.name = name + + def render(self, context): + if type(self.content) is template.NodeList: + self.content = self.content.render(context) + + self.content = remove_formatting(self.content) + + self.content = template.Variable(self.content).resolve(context) + + context[self.name] = self.content + return '' + +class PartialNode(template.Node): + def __init__(self, name, block): + self.name = remove_formatting(name) + self.block = block + + def render(self, context): + if type(self.block) is template.NodeList: + self.block = self.block.render(context) + + self.block = remove_formatting(self.block) + + context = context.flatten() + context['block'] = self.block + t = template.loader.get_template('partials/%s.html' % self.name) + return t.render(context) + +@register.tag(name='set') +def set_block(parser, token): + split = token.split_contents() + if len(split) >= 1: + variable_name = split[1] + else: + raise template.TemplateSyntaxError('%r expects a variable name' % split[0]) + + if len(split) == 2: + content=None + if '=' not in variable_name: + content = parser.parse(('end%s'%split[0],)) + parser.delete_first_token() + return VariableNode(variable_name, content) + else: + return VariableNode(variable_name, split[2]) + +@register.tag(name='partial') +def partial(parser, token): + split = token.split_contents() + if len(split) >= 1: + partial_name = split[1] + else: + raise template.TemplateSyntaxError('%r expects a partial name' % split[0]) + + if len(split) == 2: + nodeList = parser.parse(('end%s'%split[0],)) + parser.delete_first_token() + return PartialNode(partial_name, nodeList) + else: + nodeList = template.NodeList() + for parameter in split[2:]: + if '=' in parameter: + nodeList.append( + VariableNode(name=parameter) + ) + else: + raise template.TemplateSyntaxError('%r expects kwargs, got args' % split[0]) + return PartialNode(partial_name, nodeList) + \ No newline at end of file From 52271811ad9a3ed9f334576d04a9f35b3b0be1a2 Mon Sep 17 00:00:00 2001 From: reverend Date: Fri, 2 Apr 2021 22:00:21 +0200 Subject: [PATCH 6/8] using block in partial --- django_lostplaces/lostplaces/templates/partials/image.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/django_lostplaces/lostplaces/templates/partials/image.html b/django_lostplaces/lostplaces/templates/partials/image.html index 2ad0240..f16820d 100644 --- a/django_lostplaces/lostplaces/templates/partials/image.html +++ b/django_lostplaces/lostplaces/templates/partials/image.html @@ -7,7 +7,11 @@
{{alt_text}}
From 092b91825fed3081a8f27318a3c1c2934beac259 Mon Sep 17 00:00:00 2001 From: reverend Date: Fri, 2 Apr 2021 22:06:52 +0200 Subject: [PATCH 7/8] Following new naming https://is.gd/cRmcip --- .../lostplaces/templates/403.html | 4 ++-- .../lostplaces/templates/explorer/profile.html | 10 +++++----- .../lostplaces/templates/global.html | 18 +++++++++--------- .../lostplaces/templates/home.html | 4 ++-- .../lostplaces/templates/home_unauth.html | 6 +++--- .../templates/partials/form/submit.html | 4 ++-- .../templates/partials/nav/footer.html | 8 ++++---- .../templates/partials/nav/pagination.html | 16 ++++++++-------- .../lostplaces/templates/partials/tagging.html | 4 ++-- .../lostplaces/templates/partials/welcome.html | 12 ++++++------ .../photo_album/photo_album_create.html | 8 ++++---- .../templates/place/place_create.html | 6 +++--- .../templates/place/place_delete.html | 8 ++++---- .../templates/place/place_detail.html | 10 +++++----- .../lostplaces/templates/place/place_list.html | 4 ++-- .../templates/place/place_update.html | 6 +++--- .../place_image/place_image_create.html | 2 +- .../templates/registration/login.html | 8 ++++---- .../lostplaces/templates/signup.html | 6 +++--- .../lostplaces/templatetags/lostplaces.py | 2 +- 20 files changed, 73 insertions(+), 73 deletions(-) diff --git a/django_lostplaces/lostplaces/templates/403.html b/django_lostplaces/lostplaces/templates/403.html index ef4fbb8..566a9ab 100644 --- a/django_lostplaces/lostplaces/templates/403.html +++ b/django_lostplaces/lostplaces/templates/403.html @@ -1,7 +1,7 @@ {% extends 'global.html'%} {% load i18n %} -{% block title %}{% trans 'Forbidden' %}{% endblock %} +{% block title %}{% translate 'Forbidden' %}{% endblock %} {% block additional_head %} {% if request.META.HTTP_REFERER %} @@ -11,6 +11,6 @@ {% block maincontent %} {% if request.META.HTTP_REFERER %} -

{% trans 'You will be redirected in 5 seconds' %}

{% trans 'Go Back' %}

+

{% translate 'You will be redirected in 5 seconds' %}

{% translate 'Go Back' %}

{% endif %} {% endblock maincontent %} \ No newline at end of file diff --git a/django_lostplaces/lostplaces/templates/explorer/profile.html b/django_lostplaces/lostplaces/templates/explorer/profile.html index 68c0072..ef04c14 100644 --- a/django_lostplaces/lostplaces/templates/explorer/profile.html +++ b/django_lostplaces/lostplaces/templates/explorer/profile.html @@ -16,7 +16,7 @@
- {% trans 'Joined' %} + {% translate 'Joined' %} {{explorer.user.date_joined|date:'d.m.Y'}} @@ -24,7 +24,7 @@
- {% trans 'Places'%} + {% translate 'Places'%} {{place_count}} @@ -32,7 +32,7 @@
- {% trans 'Place Assets'%} + {% translate 'Place Assets'%} {{asset_count}} @@ -46,7 +46,7 @@
-

{% trans 'Places submitted by' %} {{explorer.user.username}}

+

{% translate 'Places submitted by' %} {{explorer.user.username}}

    {% for place in place_list %}
  • @@ -68,7 +68,7 @@
-

{% trans 'Photo albums submitted by' %} {{explorer.user.username}}

+

{% translate 'Photo albums submitted by' %} {{explorer.user.username}}

@@ -48,14 +48,14 @@ diff --git a/django_lostplaces/lostplaces/templates/home.html b/django_lostplaces/lostplaces/templates/home.html index 1694e93..b29a09f 100644 --- a/django_lostplaces/lostplaces/templates/home.html +++ b/django_lostplaces/lostplaces/templates/home.html @@ -7,7 +7,7 @@ {% endblock additional_head %} -# {% block title %}{% trans 'Home' %}{% endblock %} +# {% block title %}{% translate 'Home' %}{% endblock %} {% block maincontent %} @@ -17,7 +17,7 @@ {% include 'partials/osm_map.html' with config=mapping_config %}
-

{% trans 'Explore the latest places' %}

+

{% translate 'Explore the latest places' %}

    {% for place in place_list %}
  • diff --git a/django_lostplaces/lostplaces/templates/home_unauth.html b/django_lostplaces/lostplaces/templates/home_unauth.html index 6e6ed28..f447b6d 100644 --- a/django_lostplaces/lostplaces/templates/home_unauth.html +++ b/django_lostplaces/lostplaces/templates/home_unauth.html @@ -8,16 +8,16 @@ {% include 'partials/welcome.html' %}

    - {% blocktrans %}You can create, view and share your lost places with other members of this site. You can upload photos, place links to your web galleries and contribute your knowledge by tagging other places or commenting on them. You will find detailed information on where these locations are, how to get there and what to expect from them. This might even include detailed information on the surroundings or the history of a lost place.{% endblocktrans %} + {% blocktranslate %}You can create, view and share your lost places with other members of this site. You can upload photos, place links to your web galleries and contribute your knowledge by tagging other places or commenting on them. You will find detailed information on where these locations are, how to get there and what to expect from them. This might even include detailed information on the surroundings or the history of a lost place.{% endblocktranslate %}

    {% url 'signup' as signup_url %}

    - {% blocktrans %}Since vandalism is a growing problem these days, no sensitive information is available to the public. You have to sign up with a voucher code as an invitation to join this community. Only admins can create these codes. Usually you are given a code when we know you in real life in person and when we trust you. A request from an unknown person will most probably be denied.{% endblocktrans %} + {% blocktranslate %}Since vandalism is a growing problem these days, no sensitive information is available to the public. You have to sign up with a voucher code as an invitation to join this community. Only admins can create these codes. Usually you are given a code when we know you in real life in person and when we trust you. A request from an unknown person will most probably be denied.{% endblocktranslate %}

    -

    {% trans 'Explore the latest places' %}

    +

    {% translate 'Explore the latest places' %}

      {% for place in place_list %}
    • diff --git a/django_lostplaces/lostplaces/templates/partials/form/submit.html b/django_lostplaces/lostplaces/templates/partials/form/submit.html index 4d1572a..708a8ac 100644 --- a/django_lostplaces/lostplaces/templates/partials/form/submit.html +++ b/django_lostplaces/lostplaces/templates/partials/form/submit.html @@ -1,9 +1,9 @@ {% load i18n %}
      - +
      diff --git a/django_lostplaces/lostplaces/templates/partials/nav/footer.html b/django_lostplaces/lostplaces/templates/partials/nav/footer.html index 1e82c6e..f671679 100644 --- a/django_lostplaces/lostplaces/templates/partials/nav/footer.html +++ b/django_lostplaces/lostplaces/templates/partials/nav/footer.html @@ -61,13 +61,13 @@ diff --git a/django_lostplaces/lostplaces/templates/partials/nav/pagination.html b/django_lostplaces/lostplaces/templates/partials/nav/pagination.html index f7f4130..1c98eae 100644 --- a/django_lostplaces/lostplaces/templates/partials/nav/pagination.html +++ b/django_lostplaces/lostplaces/templates/partials/nav/pagination.html @@ -8,26 +8,26 @@
    • - {% trans 'First' %} + {% translate 'First' %}
    • - {% trans 'Previous' %} + {% translate 'Previous' %}
    • {% else %}
    • - {% trans 'First' %} + {% translate 'First' %}
    • - {% trans 'Previous' %} + {% translate 'Previous' %}
    • {% endif %} @@ -47,25 +47,25 @@ {% if page_obj.has_next %}
    • - {% trans 'Next' %} + {% translate 'Next' %}
    • - {% trans 'Last' %} + {% translate 'Last' %}
    • {% else %}
    • - {% trans 'Next' %} + {% translate 'Next' %}
    • - {% trans 'Last' %} + {% translate 'Last' %}
    • diff --git a/django_lostplaces/lostplaces/templates/partials/tagging.html b/django_lostplaces/lostplaces/templates/partials/tagging.html index 2b44cf3..66775fd 100644 --- a/django_lostplaces/lostplaces/templates/partials/tagging.html +++ b/django_lostplaces/lostplaces/templates/partials/tagging.html @@ -27,11 +27,11 @@
      - {% trans 'Add tags' %} + {% translate 'Add tags' %} {% csrf_token %}
      - +
      {% include 'partials/form/inputField.html' with field=config.submit_form.tag_list classes="LP-Input--tagging" %} diff --git a/django_lostplaces/lostplaces/templates/partials/welcome.html b/django_lostplaces/lostplaces/templates/partials/welcome.html index e4e9f31..03ad33b 100644 --- a/django_lostplaces/lostplaces/templates/partials/welcome.html +++ b/django_lostplaces/lostplaces/templates/partials/welcome.html @@ -1,21 +1,21 @@ {% load i18n %}
      -

      {% trans 'Start' %}

      +

      {% translate 'Start' %}

      -

      {% trans 'Welcome to our Urban Exploration community catalogue,' %} +

      {% translate 'Welcome to our Urban Exploration community catalogue,' %} {% if user.is_authenticated %} {{ user.username }} {% else %} - {% trans 'explorer' %} + {% translate 'explorer' %} {% endif %} !

      - {% trans 'We strictly follow our' %} - {% trans 'UrBex codex' %} - {% trans 'and expect you to do so, too.' %}' + {% translate 'We strictly follow our' %} + {% translate 'UrBex codex' %} + {% translate 'and expect you to do so, too.' %}'

      diff --git a/django_lostplaces/lostplaces/templates/photo_album/photo_album_create.html b/django_lostplaces/lostplaces/templates/photo_album/photo_album_create.html index 3406437..ac13bdb 100644 --- a/django_lostplaces/lostplaces/templates/photo_album/photo_album_create.html +++ b/django_lostplaces/lostplaces/templates/photo_album/photo_album_create.html @@ -1,19 +1,19 @@ {% extends 'global.html'%} {% load i18n %} -{% block title %}{% trans 'Submit a photo album' %}{% endblock %} +{% block title %}{% translate 'Submit a photo album' %}{% endblock %} {% block additional_menu_items %}
    • {% trans 'Edit place' %}
    • + class="LP-Link__Text">{% translate 'Edit place' %}
    • {% trans 'Delete place' %}
    • + class="LP-Link__Text">{% translate 'Delete place' %} {% endblock additional_menu_items %} {% block maincontent %}
      - {% trans 'Submit a photo album for' %} {{place.name}} + {% translate 'Submit a photo album for' %} {{place.name}} {% csrf_token %}
      diff --git a/django_lostplaces/lostplaces/templates/place/place_create.html b/django_lostplaces/lostplaces/templates/place/place_create.html index b9a9e18..1201202 100644 --- a/django_lostplaces/lostplaces/templates/place/place_create.html +++ b/django_lostplaces/lostplaces/templates/place/place_create.html @@ -2,12 +2,12 @@ {% load static %} {% load i18n %} -# {% block title %}{% trans 'Create place' %}{% endblock %} +# {% block title %}{% translate 'Create place' %}{% endblock %} {% block maincontent %}
      - {% trans 'Create place' %} + {% translate 'Create place' %} {% csrf_token %}
      @@ -39,7 +39,7 @@
      - {% trans 'Create' as action %} + {% translate 'Create' as action %}
      {% include 'partials/form/submit.html' with referrer=request.META.HTTP_REFERER action=action %}
      diff --git a/django_lostplaces/lostplaces/templates/place/place_delete.html b/django_lostplaces/lostplaces/templates/place/place_delete.html index 0517288..94b49a1 100644 --- a/django_lostplaces/lostplaces/templates/place/place_delete.html +++ b/django_lostplaces/lostplaces/templates/place/place_delete.html @@ -2,21 +2,21 @@ {% load static %} {% load i18n %} -{% block title %}{% trans 'Delete lost place' %}{% endblock %} +{% block title %}{% translate 'Delete lost place' %}{% endblock %} {% block maincontent %}
      - {% trans 'Delete place' %} + {% translate 'Delete place' %} {% csrf_token %}
      -

      {% blocktrans with place_name=place.name%}Are you sure you want to delete {{place_name}}?{% endblocktrans %}

      +

      {% blocktranslate with place_name=place.name%}Are you sure you want to delete {{place_name}}?{% endblocktranslate %}

      - {% trans 'Delete' as action %} + {% translate 'Delete' as action %}
      {% include 'partials/form/submit.html' with referer=request.META.HTTP_REFERER action=action %}
      diff --git a/django_lostplaces/lostplaces/templates/place/place_detail.html b/django_lostplaces/lostplaces/templates/place/place_detail.html index 20788c6..b814f87 100644 --- a/django_lostplaces/lostplaces/templates/place/place_detail.html +++ b/django_lostplaces/lostplaces/templates/place/place_detail.html @@ -16,8 +16,8 @@ {% block title %}{{place.name}}{% endblock %} {% block additional_menu_items %} -
    • {% trans 'Edit place' %}
    • -
    • {% trans 'Delete place' %}
    • +
    • {% translate 'Edit place' %}
    • +
    • {% translate 'Delete place' %}
    • {% endblock additional_menu_items %} {% block maincontent %} @@ -48,7 +48,7 @@
-

{% trans 'Map links' %}

+

{% translate 'Map links' %}

{% partial osm_map config=mapping_config %}
-

{% trans 'Photo albums' %}

+

{% translate 'Photo albums' %}

diff --git a/django_lostplaces/lostplaces/templates/place/place_list.html b/django_lostplaces/lostplaces/templates/place/place_list.html index 058bee1..c5d2071 100644 --- a/django_lostplaces/lostplaces/templates/place/place_list.html +++ b/django_lostplaces/lostplaces/templates/place/place_list.html @@ -7,13 +7,13 @@ {% endblock additional_head %} -{% block title %}{% trans 'All Places' %}{% endblock %} +{% block title %}{% translate 'All Places' %}{% endblock %} {% block maincontent %} {% include 'partials/osm_map.html' with config=mapping_config %}
-

{% trans 'Our lost places' %}

+

{% translate 'Our lost places' %}

    {% for place in place_list %}
  • diff --git a/django_lostplaces/lostplaces/templates/place/place_update.html b/django_lostplaces/lostplaces/templates/place/place_update.html index 5a508a9..0299b50 100644 --- a/django_lostplaces/lostplaces/templates/place/place_update.html +++ b/django_lostplaces/lostplaces/templates/place/place_update.html @@ -2,12 +2,12 @@ {% load static %} {% load i18n %} -# {% block title %}{% trans 'Edit place' %}{% endblock %} +# {% block title %}{% translate 'Edit place' %}{% endblock %} {% block maincontent %}
    - {% trans 'Edit place' %} + {% translate 'Edit place' %} {% csrf_token %}
    @@ -39,7 +39,7 @@
    - {% trans 'Update' as action %} + {% translate 'Update' as action %}
    {% include 'partials/form/submit.html' with referrer=request.META.HTTP_REFERER action=action %}
    diff --git a/django_lostplaces/lostplaces/templates/place_image/place_image_create.html b/django_lostplaces/lostplaces/templates/place_image/place_image_create.html index 455d9ef..3a0ad87 100644 --- a/django_lostplaces/lostplaces/templates/place_image/place_image_create.html +++ b/django_lostplaces/lostplaces/templates/place_image/place_image_create.html @@ -4,7 +4,7 @@ {% block maincontent %}
    - {% trans 'Submit images to a place' %} + {% translate 'Submit images to a place' %} {% csrf_token %}
    diff --git a/django_lostplaces/lostplaces/templates/registration/login.html b/django_lostplaces/lostplaces/templates/registration/login.html index a9a0a66..33db2ab 100644 --- a/django_lostplaces/lostplaces/templates/registration/login.html +++ b/django_lostplaces/lostplaces/templates/registration/login.html @@ -1,13 +1,13 @@ {% extends 'global.html'%} {% load static %} {% load i18n %} -# {% block title %}{% trans 'Login' %}{% endblock %} +# {% block title %}{% translate 'Login' %}{% endblock %} {% block maincontent %}
    - {% trans 'Login' %} + {% translate 'Login' %} {% csrf_token %}
    @@ -20,12 +20,12 @@
    - +
    -

    {% trans 'No account, yet?' %} {% trans 'Sign up' %}

    +

    {% translate 'No account, yet?' %} {% translate 'Sign up' %}

    {% endblock maincontent %} \ No newline at end of file diff --git a/django_lostplaces/lostplaces/templates/signup.html b/django_lostplaces/lostplaces/templates/signup.html index c3a3949..5ecae2b 100644 --- a/django_lostplaces/lostplaces/templates/signup.html +++ b/django_lostplaces/lostplaces/templates/signup.html @@ -3,13 +3,13 @@ {% load i18n %} {% load widget_tweaks %} -# {% block title %}{% trans 'Sign up' %}{% endblock %} +# {% block title %}{% translate 'Sign up' %}{% endblock %} {% block maincontent %}
    - {% trans 'Sign up' %} + {% translate 'Sign up' %} {% csrf_token %}
    @@ -38,7 +38,7 @@
    - +
    diff --git a/django_lostplaces/lostplaces/templatetags/lostplaces.py b/django_lostplaces/lostplaces/templatetags/lostplaces.py index 1fe3649..7c05677 100644 --- a/django_lostplaces/lostplaces/templatetags/lostplaces.py +++ b/django_lostplaces/lostplaces/templatetags/lostplaces.py @@ -45,7 +45,7 @@ class VariableNode(template.Node): self.name = name def render(self, context): - if type(self.content) is template.NodeList: + if type(self.content) is not str: self.content = self.content.render(context) self.content = remove_formatting(self.content) From ceeae9e8c993693c09fb8eb53b64724f895efb41 Mon Sep 17 00:00:00 2001 From: reverend Date: Sat, 3 Apr 2021 23:03:44 +0200 Subject: [PATCH 8/8] rudimentary implementation of a lightbox --- django_lostplaces/lostplaces/static/main.css | 73 ++++++++++++++++++- .../templates/partials/placeImageGrid.html | 20 ++++- .../lostplaces/templatetags/lostplaces.py | 3 + 3 files changed, 92 insertions(+), 4 deletions(-) diff --git a/django_lostplaces/lostplaces/static/main.css b/django_lostplaces/lostplaces/static/main.css index 8d6ab35..63c0fcf 100644 --- a/django_lostplaces/lostplaces/static/main.css +++ b/django_lostplaces/lostplaces/static/main.css @@ -611,6 +611,12 @@ body { font-weight: bold; cursor: pointer; white-space: nowrap; } + .LP-Button--fullWidth { + text-align: center; } + .LP-Button.LP-Link { + display: block; } + .LP-Button.LP-Link:hover { + color: #f9f9f9; } .LP-Button:active { background-color: #76323F; color: #f9f9f9; } @@ -717,6 +723,10 @@ body { margin: 0; padding: 0; } +.LP-Figure { + padding: 0; + margin: 0; } + .LP-Logo { max-width: 100%; max-height: 100%; @@ -923,7 +933,8 @@ body { justify-content: space-between; align-items: flex-start; gap: unset; } - .LP-PlaceTeaser--extended .LP-PlaceTeaser__Meta .LP-Headline, .LP-PlaceTeaser--extended .LP-PlaceTeaser__Meta .LP-Paragraph { + .LP-PlaceTeaser--extended .LP-PlaceTeaser__Meta .LP-Headline, + .LP-PlaceTeaser--extended .LP-PlaceTeaser__Meta .LP-Paragraph { font-size: unset; } .LP-PlaceTeaser--extended .LP-PlaceTeaser__Meta .LP-PlaceTeaser__Info .LP-Headline { font-size: 28px; } @@ -941,7 +952,12 @@ body { overflow: hidden; order: unset; } .LP-PlaceTeaser--extended .LP-PlaceTeaser__Description .LP-Paragraph { - font-size: unset; } + font-size: unset; + display: -webkit-box; + -webkit-box-orient: vertical; + -webkit-line-clamp: 2; + overflow: hidden; + text-overflow: ellipsis; } .LP-PlaceTeaser--extended .LP-PlaceTeaser__Image { height: 165px; width: 280px; @@ -1692,9 +1708,62 @@ body { top: 7.8125px; } .LP-ImageGrid__Item > .LP-Link:hover + .LP-ImageGrid__DeleteItem, .LP-ImageGrid__DeleteItem:hover { visibility: visible; } + .LP-ImageGrid__LightBox { + visibility: hidden; + display: none; + position: fixed; + pointer-events: none; + flex-direction: row; + justify-content: center; + align-items: center; + background-color: rgba(86, 86, 86, 0.9); + padding: 2rem; + padding-bottom: 0; + width: 100vw; + height: 100vh; + z-index: 30; + top: 0; + left: 0; + box-sizing: border-box; } + .LP-ImageGrid__LightBox:target { + visibility: visible; + display: grid; + grid-template-areas: 'picture picture' 'previous next'; + grid-template-rows: 1fr 4rem; + grid-template-columns: 1fr 1fr; + pointer-events: initial; } + .LP-ImageGrid__FullSizeImage { + grid-area: picture; } + .LP-ImageGrid__Previous { + grid-area: previous; + align-self: center; + justify-self: end; } + .LP-ImageGrid__Next { + grid-area: next; + align-self: center; + justify-self: start; } + .LP-ImageGrid__Previous, .LP-ImageGrid__Next { + padding: 25px; + color: #D7CEC7; + text-decoration: none; + font-family: "Montserrat", Helvetica, sans-serif; + font-weight: bold; + font-size: 20px; } + .LP-ImageGrid__Close { + position: fixed; + right: 1rem; + top: 1rem; + left: unset; + visibility: visible; + opacity: 1; } .LP-Map { margin-bottom: 25px; } + .LP-Map--wide { + height: 300px; } + .LP-Map--full { + height: 100%; + width: 100%; } .LP-Map .ol-attribution { font-family: "Montserrat", Helvetica, sans-serif; color: #565656; } diff --git a/django_lostplaces/lostplaces/templates/partials/placeImageGrid.html b/django_lostplaces/lostplaces/templates/partials/placeImageGrid.html index 7623d04..bcd46aa 100644 --- a/django_lostplaces/lostplaces/templates/partials/placeImageGrid.html +++ b/django_lostplaces/lostplaces/templates/partials/placeImageGrid.html @@ -1,4 +1,5 @@ {% load static %} + {% load lostplaces %} {% if headline %}

    {{headline}}

    @@ -6,8 +7,9 @@
      {% for image in image_list %} -
    • - {% include 'partials/image.html' with source_url=image.filename.thumbnail.url link_url=image.filename.large.url %} +
    • + {{ "#image"|add:forloop.counter }} + {% include 'partials/image.html' with source_url=image.filename.thumbnail.url link_url="#image"|addstr:forloop.counter %} {% if user.explorer == image.submitted_by%} @@ -15,6 +17,20 @@ {% endif %} +
      + + {% if forloop.counter < image_list|length %} + Next + {% endif %} + {% if forloop.counter > 1 %} + Previous + {% endif %} + + + + + +
    • {% endfor %}
    diff --git a/django_lostplaces/lostplaces/templatetags/lostplaces.py b/django_lostplaces/lostplaces/templatetags/lostplaces.py index 7c05677..19fad77 100644 --- a/django_lostplaces/lostplaces/templatetags/lostplaces.py +++ b/django_lostplaces/lostplaces/templatetags/lostplaces.py @@ -34,6 +34,9 @@ def proper_paginate(paginator, current_page, neighbors=2): return page_list[:(2*neighbors + 1)] return paginator.page_range +@register.filter +def addstr(value, parameter): + return str(value) + str(parameter) class VariableNode(template.Node): def __init__(self, name, content=None):