4 Commits

6 changed files with 63 additions and 26 deletions

View File

@@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-12-25 01:22+0100\n" "POT-Creation-Date: 2020-12-25 16:04+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Commander1024 <commander@commander1024.de>\n" "Last-Translator: Commander1024 <commander@commander1024.de>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -74,19 +74,19 @@ msgstr "Adresse (URL)"
msgid "link text" msgid "link text"
msgstr "Linktext" msgstr "Linktext"
#: models/models.py:46 #: models/models.py:47
msgid "Biography / Description" msgid "Biography"
msgstr "Beschreibung" msgstr "Beschreibung"
#: models/models.py:47 #: models/models.py:48
msgid "Describe yourself, your preferences, etc. in a few sentences." msgid "Describe yourself, your preferences, etc. in a few sentences."
msgstr "Beschreibe Dich selbst, Deine Vorlieben, usw. in ein paar Sätzen." msgstr "Beschreibe Dich selbst, Deine Vorlieben, usw. in ein paar Sätzen."
#: models/models.py:55 #: models/models.py:56
msgid "Profile image" msgid "Profile image"
msgstr "Profilbild" msgstr "Profilbild"
#: models/models.py:56 #: models/models.py:57
msgid "Optional profile image for display in Explorer profile" msgid "Optional profile image for display in Explorer profile"
msgstr "Optionales Profilbild zur Anzeige im Explorerprofil" msgstr "Optionales Profilbild zur Anzeige im Explorerprofil"
@@ -144,19 +144,25 @@ msgstr "Alle Places"
msgid "Place assets" msgid "Place assets"
msgstr "" msgstr ""
#: templates/explorer/profile.html:82 #: templates/explorer/profile.html:76
msgid "Favorite places" #, fuzzy
msgstr "Favoriten-Places" #| msgid "Edit Explorer profile"
msgid "Edit Profile"
msgstr "Explorerprofil bearbeiten"
#: templates/explorer/profile.html:98 #: templates/explorer/profile.html:87
msgid "Favorite places"
msgstr "Favoriten"
#: templates/explorer/profile.html:103
msgid "Places submitted by" msgid "Places submitted by"
msgstr "Places hinzugefügt von" msgstr "Places hinzugefügt von"
#: templates/explorer/profile.html:113 #: templates/explorer/profile.html:118
msgid "Images submitted by" msgid "Images submitted by"
msgstr "Bilder hinzugefügt von" msgstr "Bilder hinzugefügt von"
#: templates/explorer/profile.html:135 #: templates/explorer/profile.html:140
msgid "Photo albums submitted by" msgid "Photo albums submitted by"
msgstr "Fotoalben hinzugefügt von" msgstr "Fotoalben hinzugefügt von"
@@ -176,7 +182,7 @@ msgstr "Ausloggen"
#: templates/global.html:33 #: templates/global.html:33
msgid "Profile" msgid "Profile"
msgstr "" msgstr "Profil"
#: templates/global.html:35 #: templates/global.html:35
msgid "Admin" msgid "Admin"
@@ -402,6 +408,16 @@ msgstr "Noch kein Konto?"
msgid "Please login to proceed" msgid "Please login to proceed"
msgstr "Bitte log Dich ein um fortzufahren" msgstr "Bitte log Dich ein um fortzufahren"
#: views/explorer_views.py:78
#, fuzzy
#| msgid "Successfully updated place"
msgid "Successfully updated Explorer profile"
msgstr "Place erfolgreich aktualisiert"
#: views/explorer_views.py:84 views/place_views.py:105
msgid "Please fill in all required fields."
msgstr "Bitte füll alle benötigten Felder aus."
#: views/place_image_views.py:26 #: views/place_image_views.py:26
msgid "Image(s) submitted successfully" msgid "Image(s) submitted successfully"
msgstr "Bild(er) erfolgreich hinzugefügt" msgstr "Bild(er) erfolgreich hinzugefügt"
@@ -426,10 +442,6 @@ msgstr "Du darfst diesen Place nicht bearbeiten"
msgid "Successfully created place" msgid "Successfully created place"
msgstr "Place erfolgreich erstellt" msgstr "Place erfolgreich erstellt"
#: views/place_views.py:105
msgid "Please fill in all required fields."
msgstr "Bitte füll alle benötigten Felder aus."
#: views/place_views.py:112 #: views/place_views.py:112
msgid "Successfully deleted place" msgid "Successfully deleted place"
msgstr "Place erfolgreich gelöscht" msgstr "Place erfolgreich gelöscht"

View File

@@ -11,7 +11,7 @@ import uuid
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.db.models.signals import post_save from django.db.models.signals import post_save, pre_save
from django.dispatch import receiver from django.dispatch import receiver
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
@@ -75,6 +75,25 @@ def create_user_profile(sender, instance, created, **kwargs):
def save_user_profile(sender, instance, **kwargs): def save_user_profile(sender, instance, **kwargs):
instance.explorer.save() instance.explorer.save()
@receiver(pre_save, sender=Explorer)
def auto_delete_file_on_change(sender, instance, **kwargs):
"""
Deletes old file from filesystem
when corresponding `Explorer` object is updated
with new file.
"""
if not instance.pk:
return False
try:
old_file = Explorer.objects.get(pk=instance.pk).profile_image
except Explorer.DoesNotExist:
return False
print("Deleting:", old_file)
new_file = instance.profile_image
if not old_file == new_file:
old_file.delete(save=False)
class Voucher(Expireable): class Voucher(Expireable):
""" """
Vouchers are authorization tokens to allow the registration of new users. Vouchers are authorization tokens to allow the registration of new users.

View File

@@ -72,7 +72,7 @@ class PlaceAsset(Submittable):
null=True null=True
) )
class PlaceImage (PlaceAsset): class PlaceImage(PlaceAsset):
""" """
PlaceImage defines an image file object that points to a file in uploads/. PlaceImage defines an image file object that points to a file in uploads/.
Intermediate image sizes are generated as defined in THUMBNAIL_ALIASES. Intermediate image sizes are generated as defined in THUMBNAIL_ALIASES.
@@ -104,7 +104,6 @@ class PlaceImage (PlaceAsset):
return 'Image ' + str(self.pk) return 'Image ' + str(self.pk)
# These two auto-delete files from filesystem when they are unneeded: # These two auto-delete files from filesystem when they are unneeded:
@receiver(post_delete, sender=PlaceImage) @receiver(post_delete, sender=PlaceImage)
@@ -118,7 +117,6 @@ def auto_delete_file_on_delete(sender, instance, **kwargs):
thumbmanager = get_thumbnailer(instance.filename) thumbmanager = get_thumbnailer(instance.filename)
thumbmanager.delete(save=False) thumbmanager.delete(save=False)
@receiver(pre_save, sender=PlaceImage) @receiver(pre_save, sender=PlaceImage)
def auto_delete_file_on_change(sender, instance, **kwargs): def auto_delete_file_on_change(sender, instance, **kwargs):
""" """
@@ -137,5 +135,4 @@ def auto_delete_file_on_change(sender, instance, **kwargs):
# No need to delete thumbnails, as they will be overwritten on regeneration. # No need to delete thumbnails, as they will be overwritten on regeneration.
new_file = instance.filename new_file = instance.filename
if not old_file == new_file: if not old_file == new_file:
if os.path.isfile(old_file.path): old_file.delete(save=False)
os.remove(old_file.path)

View File

@@ -71,6 +71,11 @@
<span class="LP-Paragraph">{{asset_count}}</span> <span class="LP-Paragraph">{{asset_count}}</span>
</td> </td>
</tr> </tr>
<tr>
<td>
<a href="/explorer/update/"><button class="LP-Button LP-Button">{% trans 'Edit Profile' %}</button></a>
</td>
</tr>
</table> </table>
</div> </div>
</div> </div>

View File

@@ -1,5 +1,6 @@
{% extends 'global.html'%} {% extends 'global.html'%}
{% load i18n %} {% load i18n %}
{% load thumbnail %}
{% load widget_tweaks %} {% load widget_tweaks %}
# {% block title %}{% trans 'Edit Explorer profile' %}{% endblock %} # {% block title %}{% trans 'Edit Explorer profile' %}{% endblock %}
@@ -34,9 +35,9 @@
</div> </div>
<div class="LP-Form__Composition"> <div class="LP-Form__Composition">
{% if explorer_image_url %} {% if explorer_image %}
<div class="LP-Form__Field"> <div class="LP-Form__Field">
<img class="LP-Form__Field LP-Image" src="{{ explorer_image_url }}"/> <img src="{% thumbnail explorer_image 200x200 %}"/>
</div> </div>
{% endif %} {% endif %}
<div class="LP-Form__Field"> <div class="LP-Form__Field">

View File

@@ -52,10 +52,11 @@ class ExplorerProfileUpdateView(IsAuthenticatedMixin, View):
'explorer_change_form': ExplorerChangeForm(instance=request.user.explorer) 'explorer_change_form': ExplorerChangeForm(instance=request.user.explorer)
} }
if request.user.explorer.profile_image: if request.user.explorer.profile_image:
context['explorer_image_url'] = request.user.explorer.profile_image.url context['explorer_image'] = request.user.explorer.profile_image
return render(request, 'explorer/profile_update.html', context) return render(request, 'explorer/profile_update.html', context)
def post(self, request, *args, **kwargs): def post(self, request, *args, **kwargs):
print(request.POST)
explorer_user_change_form = ExplorerUserChangeForm( explorer_user_change_form = ExplorerUserChangeForm(
request.POST, request.POST,
instance=request.user instance=request.user
@@ -70,6 +71,8 @@ class ExplorerProfileUpdateView(IsAuthenticatedMixin, View):
explorer_user_change_form.save() explorer_user_change_form.save()
explorer_change_form.save() explorer_change_form.save()
print(explorer_change_form.cleaned_data)
messages.success( messages.success(
self.request, self.request,
_('Successfully updated Explorer profile') _('Successfully updated Explorer profile')