Compare commits
No commits in common. "10c08a2f5e25e8565fb95b0f4a8e4bf0081d1d27" and "a139594863570be7330f7fd1645db5c4e754fc81" have entirely different histories.
10c08a2f5e
...
a139594863
@ -8,8 +8,6 @@ from django.db import models
|
||||
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
|
||||
from django.contrib.auth.models import User
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from lostplaces import widgets
|
||||
from lostplaces.models import Place, PlaceImage, Voucher, Explorer
|
||||
|
||||
class SignupVoucherForm(UserCreationForm):
|
||||
@ -70,15 +68,6 @@ class PlaceForm(forms.ModelForm):
|
||||
model = Place
|
||||
fields = '__all__'
|
||||
exclude = ['submitted_by']
|
||||
widgets = {
|
||||
'hero': widgets.SelectContent()
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
if 'instance' in kwargs:
|
||||
self.fields['hero'].queryset = PlaceImage.objects.filter(place=kwargs['instance'])
|
||||
self.fields['hero'].widget.attrs['item_template'] = 'partials/select_place_image_item.html'
|
||||
|
||||
latitude = forms.DecimalField(
|
||||
widget=forms.NumberInput(attrs={'min':-90,'max': 90,'type': 'number', 'step': 'any'})
|
||||
@ -101,21 +90,6 @@ class PlaceImageForm(forms.ModelForm):
|
||||
|
||||
self.fields['filename'].required = False
|
||||
|
||||
class PlaceSetHeroForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Place
|
||||
fields = ['hero']
|
||||
widgets = {
|
||||
'hero': widgets.SelectContent()
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields['hero'].queryset = PlaceImage.objects.filter(place=kwargs['instance'])
|
||||
self.fields['hero'].widget.attrs['item_template'] = 'partials/select_place_image_item.html'
|
||||
|
||||
|
||||
|
||||
class TagSubmitForm(forms.Form):
|
||||
tag_list = forms.CharField(
|
||||
max_length=500,
|
||||
|
@ -11,7 +11,6 @@ from lostplaces.models.abstract_models import Submittable, Taggable, Mapable
|
||||
from easy_thumbnails.fields import ThumbnailerImageField
|
||||
from easy_thumbnails.files import get_thumbnailer
|
||||
|
||||
|
||||
class Place(Submittable, Taggable, Mapable):
|
||||
"""
|
||||
Place defines a lost place (location, name, description etc.).
|
||||
@ -26,32 +25,9 @@ class Place(Submittable, Taggable, Mapable):
|
||||
verbose_name=_('Description'),
|
||||
)
|
||||
|
||||
hero = models.ForeignKey(
|
||||
'PlaceImage',
|
||||
on_delete=models.SET_NULL,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='place_heros'
|
||||
)
|
||||
|
||||
def get_hero_image(self):
|
||||
if self.hero:
|
||||
return self.hero
|
||||
elif len(self.placeimages.all()) > 0:
|
||||
return self.placeimages.first()
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('place_detail', kwargs={'pk': self.pk})
|
||||
|
||||
def get_hero_index_in_queryset(self):
|
||||
for i in range(0, len(self.placeimages.all())):
|
||||
image = self.placeimages.all()[i]
|
||||
if image == self.hero:
|
||||
return i
|
||||
return None
|
||||
|
||||
|
||||
@classmethod
|
||||
# Get center position of LP-geocoordinates.
|
||||
@ -113,7 +89,7 @@ class PlaceImage(PlaceAsset):
|
||||
upload_to=generate_place_image_filename,
|
||||
resize_source=dict(size=(2560, 2560),
|
||||
sharpen=True),
|
||||
verbose_name=_('Images'),
|
||||
verbose_name=_('Filename(s)'),
|
||||
help_text=_('Optional: One or more images to upload')
|
||||
)
|
||||
place = models.ForeignKey(
|
||||
@ -128,7 +104,7 @@ class PlaceImage(PlaceAsset):
|
||||
of this image as textual representation of this instance
|
||||
"""
|
||||
|
||||
return 'Image ' + str(self.place.name)
|
||||
return 'Image ' + str(self.pk)
|
||||
|
||||
# These two auto-delete files from filesystem when they are unneeded:
|
||||
|
||||
|
@ -858,13 +858,6 @@ body {
|
||||
.LP-Pagination .LP-Pagination__Item .LP-Link {
|
||||
padding: 8px 11px; } }
|
||||
|
||||
.LP-Select {
|
||||
display: block;
|
||||
cursor: pointer; }
|
||||
.LP-Select:checked,
|
||||
:checked + .LP-Select, .LP-Select--active {
|
||||
box-shadow: 0 0 3px 3px #C09F80; }
|
||||
|
||||
.LP-Content {
|
||||
padding: 35px; }
|
||||
|
||||
@ -1067,13 +1060,19 @@ body {
|
||||
padding: 5px;
|
||||
font-size: 25px; }
|
||||
.LP-UserInfo__Meta {
|
||||
margin-top: 10px;
|
||||
padding: 5px; }
|
||||
.LP-UserInfo__Meta * {
|
||||
font-family: "Montserrat", Helvetica, sans-serif;
|
||||
font-size: 18px; }
|
||||
.LP-UserInfo__Meta .LP-UserInfo__Key {
|
||||
padding-right: 25px;
|
||||
font-weight: bold; }
|
||||
font-weight: bold;
|
||||
white-space: nowrap; }
|
||||
.LP-UserInfo__Meta .LP-UserInfo__Value {
|
||||
white-space: nowrap; }
|
||||
.LP-UserInfo__Edit {
|
||||
margin-top: 10px; }
|
||||
|
||||
.LP-Header {
|
||||
display: flex;
|
||||
@ -1682,12 +1681,6 @@ body {
|
||||
object-position: botom; }
|
||||
.LP-ImageGrid__Item--center img {
|
||||
object-position: center; }
|
||||
.LP-ImageGrid__Item img {
|
||||
height: unset;
|
||||
width: unset; }
|
||||
.LP-ImageGrid__Item .LP-Image {
|
||||
height: 100%;
|
||||
width: 100%; }
|
||||
.LP-ImageGrid__Item--add .LP-Link {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
@ -1741,17 +1734,12 @@ body {
|
||||
.LP-ImageGrid__LightBox:target {
|
||||
visibility: visible;
|
||||
display: grid;
|
||||
justify-items: center;
|
||||
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;
|
||||
max-width: 100%;
|
||||
max-height: 100%;
|
||||
height: unset;
|
||||
width: unset; }
|
||||
grid-area: picture; }
|
||||
.LP-ImageGrid__Previous {
|
||||
grid-area: previous;
|
||||
align-self: center;
|
||||
@ -1812,6 +1800,15 @@ body {
|
||||
flex-shrink: 1;
|
||||
flex-basis: max-content; }
|
||||
|
||||
@media (max-width: 1000px) {
|
||||
.LP-UserProfile {
|
||||
flex-direction: column-reverse;
|
||||
gap: 35px; }
|
||||
.LP-UserProfile__Info {
|
||||
flex-basis: 100%; }
|
||||
.LP-UserProfile__Info .LP-UserInfo {
|
||||
max-width: unset; } }
|
||||
|
||||
.LP-MainContainer {
|
||||
margin: 0 auto;
|
||||
max-width: 1280px; }
|
||||
|
@ -26,7 +26,7 @@
|
||||
<article class="LP-PlaceTeaser">
|
||||
<div class="LP-PlaceTeaser__Image">
|
||||
{% partial 'image' %}
|
||||
{% set source_url place.placeimages.first.filename.thumbnail.url %}
|
||||
{% source_url source_url=place.placeimages.first.filename.thumbnail.url %}
|
||||
{% endpartial %}
|
||||
</div>
|
||||
<div class="LP-PlaceTeaser__Meta">
|
||||
|
@ -2,7 +2,9 @@
|
||||
|
||||
<div class="LP-Input {% if classes%}{{classes}}{% endif %} {% if field.errors %} LP-Input--error {% endif %}">
|
||||
<label for="{{field.id_for_label}}" class="LP-Input__Label">{{field.label}}</label>
|
||||
{% render_field field class+='LP-Input__Field' %}
|
||||
{% with class="LP-Input__Field "%}
|
||||
{% render_field field class=class%}
|
||||
{% endwith %}
|
||||
|
||||
<span class="LP-Input__Message">
|
||||
{% if field.errors %}
|
||||
|
@ -7,8 +7,9 @@
|
||||
<div class="LP-ImageGrid">
|
||||
<ul class="LP-ImageGrid__Container">
|
||||
{% for image in image_list %}
|
||||
<li id="thumbnail{{forloop.counter0}}" class="LP-ImageGrid__Item">
|
||||
{% include 'partials/image.html' with source_url=image.filename.thumbnail.url link_url="#image"|addstr:forloop.counter0 %}
|
||||
<li id="thumbnail{{forloop.counter}}" class="LP-ImageGrid__Item">
|
||||
{{ "#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%}
|
||||
<span class="LP-ImageGrid__DeleteItem" title="Bild löschen">
|
||||
<a href="{% url 'place_image_delete' pk=image.id %}" class="LP-Link">
|
||||
@ -16,16 +17,16 @@
|
||||
</a>
|
||||
</span>
|
||||
{% endif %}
|
||||
<div id="image{{forloop.counter0}}" class="LP-ImageGrid__LightBox">
|
||||
<div id="image{{forloop.counter}}" class="LP-ImageGrid__LightBox">
|
||||
<img class="LP-ImageGrid__FullSizeImage" src="{{image.filename.large.url}}" loading="lazy"/>
|
||||
{% if forloop.counter0 < image_list|length|add:-1 %}
|
||||
<a href="#image{{forloop.counter0|add:1}}" class="LP-ImageGrid__Next">Next</a>
|
||||
{% if forloop.counter < image_list|length %}
|
||||
<a href="#image{{forloop.counter|add:1}}" class="LP-ImageGrid__Next">Next</a>
|
||||
{% endif %}
|
||||
{% if forloop.counter0 > 0 %}
|
||||
<a href="#image{{forloop.counter0|add:-1}}" class="LP-ImageGrid__Previous">Previous</a>
|
||||
{% if forloop.counter > 1 %}
|
||||
<a href="#image{{forloop.counter|add:-1}}" class="LP-ImageGrid__Previous">Previous</a>
|
||||
{% endif %}
|
||||
<span class="LP-ImageGrid__Close LP-ImageGrid__DeleteItem" title="Schließen">
|
||||
<a href="#thumbnail{{forloop.counter0}}" class="LP-Link">
|
||||
<a href="#thumbnail{{forloop.counter}}" class="LP-Link">
|
||||
<img class="LP-Icon" src="{% static 'icons/cancel.svg' %}"/>
|
||||
</a>
|
||||
</span>
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
<article class="LP-PlaceTeaser {% if extended %} LP-PlaceTeaser--extended{% endif %}">
|
||||
<div class="LP-PlaceTeaser__Image">
|
||||
{% if place.get_hero_image %}
|
||||
{% include 'partials/image.html' with source_url=place.get_hero_image.filename.thumbnail.url link_url=place.get_absolute_url%}
|
||||
{% if place.placeimages.all|length > 0 %}
|
||||
{% include 'partials/image.html' with source_url=place.placeimages.first.filename.thumbnail.url link_url=place.get_absolute_url%}
|
||||
{% else %}
|
||||
<a href="{{place.get_absolute_url}}">
|
||||
<img class="LP-Image" src="{% static 'images/missing_image.png' %}" />
|
||||
|
@ -1,3 +0,0 @@
|
||||
{%load lostplaces %}
|
||||
|
||||
{% include 'partials/image.html' with source_url=object.filename.thumbnail.url %}
|
@ -22,15 +22,13 @@
|
||||
|
||||
{% block maincontent %}
|
||||
<article class="LP-PlaceDetail">
|
||||
|
||||
<header class="LP-PlaceDetail__Header">
|
||||
<h1 class="LP-Headline">{{ place.name }} {% include 'partials/icons/place_favorite.html' %} {% include 'partials/icons/place_visited.html' %}</h1>
|
||||
{% if place.get_hero_image %}
|
||||
{% if place.placeimages.first.filename.hero.url %}
|
||||
<div class="LP-PlaceDetail__Image">
|
||||
{% partial image %}
|
||||
{% set source_url place.get_hero_image.filename.hero.url %}
|
||||
{% set link_url %}
|
||||
{{"#image"|addstr:place.get_hero_index_in_queryset}}
|
||||
{% endset %}
|
||||
{% set source_url place.placeimages.first.filename.hero.url %}
|
||||
{% endpartial %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
@ -1,7 +1,6 @@
|
||||
{% extends 'global.html'%}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
# {% block title %}{% translate 'Edit place' %}{% endblock %}
|
||||
|
||||
@ -40,15 +39,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if object.placeimages.all|length > 0 %}
|
||||
<legend class="LP-Form__Legend">{% translate 'Set Hero Image' %}</legend>
|
||||
<div class="LP-Form__Composition">
|
||||
<div class="LP-Form__Field">
|
||||
{% render_field form.hero container_class='LP-ImageGrid__Container' item_class='LP-ImageGrid__Item LP-Select' current_selected_value=object.hero.id%}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% translate 'Update' as action %}
|
||||
<div class="LP-Form__Composition LP-Form__Composition--buttons">
|
||||
{% include 'partials/form/submit.html' with referrer=request.META.HTTP_REFERER action=action %}
|
||||
|
@ -1,23 +0,0 @@
|
||||
<ul class="{{widget.attrs.container_class}}">
|
||||
{% for group_name, group_choices, group_index in widget.optgroups %}
|
||||
{% for option in group_choices %}
|
||||
{% if option.value %}
|
||||
<li style="display: content;">
|
||||
<input
|
||||
style="display: none;"
|
||||
name="{{option.name}}"
|
||||
id="{{widget.attrs.id}}{{group_index}}"
|
||||
type="radio"
|
||||
value="{{option.value.instance.id}}"
|
||||
{% if widget.attrs.current_selected_value|stringformat:'s' == option.value.instance.id|stringformat:'s' %}checked="checked"{% endif %}
|
||||
/>
|
||||
<label class="{{widget.attrs.item_class}}" for="{{widget.attrs.id}}{{group_index}}">
|
||||
{% if widget.attrs.item_template %}
|
||||
{% include widget.attrs.item_template with object=option.value.instance %}
|
||||
{% endif %}
|
||||
</label>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
@ -1,5 +0,0 @@
|
||||
from django import forms
|
||||
|
||||
class SelectContent(forms.Select):
|
||||
template_name = 'widgets/select_content.html'
|
||||
|
Loading…
Reference in New Issue
Block a user