Compare commits

..

No commits in common. "c71fe4cf2dc6ff39cd343bf164648050357528a8" and "a7c8848fd6ca7c68fad62af62bb444b3a5e7a49b" have entirely different histories.

10 changed files with 52 additions and 154 deletions

View File

@ -9,6 +9,8 @@ from django.contrib.auth.admin import UserAdmin
from django.utils import timezone from django.utils import timezone
from lostplaces.models import * from lostplaces.models import *
from lostplaces.forms import ExplorerCreationForm, ExplorerChangeForm
# Register your models here. # Register your models here.
class VoucherAdmin(admin.ModelAdmin): class VoucherAdmin(admin.ModelAdmin):

View File

@ -8,9 +8,9 @@ from django.db import models
from django.contrib.auth.forms import UserCreationForm, UserChangeForm from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from lostplaces.models import Place, PlaceImage, Voucher, Explorer from lostplaces.models import Place, PlaceImage, Voucher
class SignupVoucherForm(UserCreationForm): class ExplorerCreationForm(UserCreationForm):
class Meta: class Meta:
model = User model = User
fields = ('username', 'email', 'first_name', 'last_name') fields = ('username', 'email', 'first_name', 'last_name')
@ -35,23 +35,10 @@ class SignupVoucherForm(UserCreationForm):
fetched_voucher.delete() fetched_voucher.delete()
return True return True
class ExplorerUserChangeForm(UserChangeForm): class ExplorerChangeForm(UserChangeForm):
class Meta: class Meta:
model = User model = User
fields = [ 'username', 'first_name', 'last_name', 'email' ] fields = ('username', 'email', 'first_name', 'last_name')
password = None
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['username'].required = False
self.fields['username'].help_text = None
self.fields['username'].widget.attrs['disabled'] = 'disabled'
class ExplorerChangeForm(forms.ModelForm):
class Meta:
model = Explorer
fields = '__all__'
exclude = ['user', 'favorite_places']
class PlaceForm(forms.ModelForm): class PlaceForm(forms.ModelForm):
class Meta: class Meta:

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-24 16:29+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"
@ -30,7 +30,7 @@ msgstr "Ungültiger Voucher"
msgid "Expired voucher" msgid "Expired voucher"
msgstr "Abgelaufener Voucher" msgstr "Abgelaufener Voucher"
#: models/abstract_models.py:29 templates/explorer/profile.html:31 #: models/abstract_models.py:29 templates/explorer/profile.html:19
msgid "Name" msgid "Name"
msgstr "Name" msgstr "Name"
@ -75,20 +75,14 @@ msgid "link text"
msgstr "Linktext" msgstr "Linktext"
#: models/models.py:46 #: models/models.py:46
msgid "Biography / Description" #, fuzzy
msgstr "Beschreibung" #| msgid "Filename(s)"
msgid "Filename"
msgstr "Dateiname(n)"
#: models/models.py:47 #: models/models.py:47
msgid "Describe yourself, your preferences, etc. in a few sentences." msgid "Optional profile pic for display in explorer profile"
msgstr "Beschreibe Dich selbst, Deine Vorlieben, usw. in ein paar Sätzen." msgstr ""
#: models/models.py:55
msgid "Profile image"
msgstr "Profilbild"
#: models/models.py:56
msgid "Optional profile image for display in Explorer profile"
msgstr "Optionales Profilbind zur Anzeige im Explorerprofil"
#: models/place.py:21 #: models/place.py:21
msgid "Location" msgid "Location"
@ -126,49 +120,41 @@ msgstr "Du wirst in 5 Sekunden weitergeleitet"
msgid "Go Back" msgid "Go Back"
msgstr "Zurück" msgstr "Zurück"
#: templates/explorer/profile.html:41 #: templates/explorer/profile.html:27
msgid "E-mail" msgid "E-Mail"
msgstr "E-Mail" msgstr ""
#: templates/explorer/profile.html:52 #: templates/explorer/profile.html:35
msgid "Joined" msgid "Joined"
msgstr "Beigetreten" msgstr ""
#: templates/explorer/profile.html:60 #: templates/explorer/profile.html:43
#, fuzzy #, fuzzy
#| msgid "All Places" #| msgid "All Places"
msgid "Places" msgid "Places"
msgstr "Alle Places" msgstr "Alle Places"
#: templates/explorer/profile.html:68 #: templates/explorer/profile.html:51
msgid "Place assets" msgid "Place Assets"
msgstr "" msgstr ""
#: templates/explorer/profile.html:82 #: templates/explorer/profile.html:65
msgid "Favorite places" #, fuzzy
msgstr "Favoriten-Places" #| msgid "Image(s) submitted successfully"
#: templates/explorer/profile.html:98
msgid "Places submitted by" msgid "Places submitted by"
msgstr "Places hinzugefügt von" msgstr "Bild(er) erfolgreich hinzugefügt"
#: templates/explorer/profile.html:113 #: templates/explorer/profile.html:82
#, fuzzy
#| msgid "Image(s) submitted successfully"
msgid "Images submitted by" msgid "Images submitted by"
msgstr "Bilder hinzugefügt von" msgstr "Bild(er) erfolgreich hinzugefügt"
#: templates/explorer/profile.html:135 #: templates/explorer/profile.html:104
#, fuzzy
#| msgid "Photo album link submitted"
msgid "Photo albums submitted by" msgid "Photo albums submitted by"
msgstr "Fotoalben hinzugefügt von" msgstr "Fotoalbum-Link hinzugefügt"
#: templates/explorer/profile_update.html:6
#: templates/explorer/profile_update.html:12
msgid "Edit Explorer profile"
msgstr "Explorerprofil bearbeiten"
#: templates/explorer/profile_update.html:48
#: templates/place/place_update.html:42
msgid "Update"
msgstr "Aktualisieren"
#: templates/global.html:32 #: templates/global.html:32
msgid "Logout" msgid "Logout"
@ -188,7 +174,7 @@ msgid "Login"
msgstr "Anmelden" msgstr "Anmelden"
#: templates/global.html:41 templates/registration/login.html:29 #: templates/global.html:41 templates/registration/login.html:29
#: templates/signup.html:6 templates/signup.html:12 templates/signup.html:49 #: templates/signup.html:6 templates/signup.html:12 templates/signup.html:41
msgid "Sign up" msgid "Sign up"
msgstr "Registrieren" msgstr "Registrieren"
@ -258,14 +244,6 @@ msgstr "Abschicken"
msgid "Cancel" msgid "Cancel"
msgstr "Abbrechen" msgstr "Abbrechen"
#: templates/partials/icons/place_favorite.html:6
msgid "Remove from favorites"
msgstr "Aus den Favoriten entfernen"
#: templates/partials/icons/place_favorite.html:10
msgid "Save as favorite"
msgstr "In den Favoriten speichern"
#: templates/partials/nav/footer.html:64 #: templates/partials/nav/footer.html:64
msgid "Made by" msgid "Made by"
msgstr "Erstellt von" msgstr "Erstellt von"
@ -390,6 +368,10 @@ msgstr "Alle Places"
msgid "Our lost places" msgid "Our lost places"
msgstr "Unsere Lost Places" msgstr "Unsere Lost Places"
#: templates/place/place_update.html:42
msgid "Update"
msgstr "Aktualisieren"
#: templates/place_image/place_image_create.html:7 #: templates/place_image/place_image_create.html:7
msgid "Submit images to a place" msgid "Submit images to a place"
msgstr "Bilder zu einem Place hinzufügen" msgstr "Bilder zu einem Place hinzufügen"
@ -453,8 +435,3 @@ msgstr "Fotoalbum-Link gelöscht"
#: views/views.py:60 #: views/views.py:60
msgid "You are not allowed to edit this photo album link" msgid "You are not allowed to edit this photo album link"
msgstr "Du darfst diesen Fotoalbum-Link nicht bearbeiten" msgstr "Du darfst diesen Fotoalbum-Link nicht bearbeiten"
#, fuzzy
#~| msgid "Filename(s)"
#~ msgid "Filename"
#~ msgstr "Dateiname(n)"

View File

@ -53,7 +53,7 @@ class Explorer(models.Model):
resize_source=dict(size=(400, 400), resize_source=dict(size=(400, 400),
sharpen=True), sharpen=True),
verbose_name=_('Profile image'), verbose_name=_('Profile image'),
help_text=_('Optional profile image for display in Explorer profile') help_text=_('Optional profile pic for display in explorer profile')
) )
favorite_places = models.ManyToManyField( favorite_places = models.ManyToManyField(
Place, Place,

View File

@ -38,7 +38,7 @@
<tr> <tr>
{% if explorer.user.email %} {% if explorer.user.email %}
<td class="LP-UserInfo__Key"> <td class="LP-UserInfo__Key">
<span class="LP-Paragraph">{% trans 'E-mail' %}</span> <span class="LP-Paragraph">{% trans 'E-Mail' %}</span>
</td> </td>
<td class="LP-UserInfo__Value"> <td class="LP-UserInfo__Value">
<span class="LP-Paragraph"> <span class="LP-Paragraph">
@ -65,7 +65,7 @@
</tr> </tr>
<tr> <tr>
<td class="LP-UserInfo__Key"> <td class="LP-UserInfo__Key">
<span class="LP-Paragraph">{% trans 'Place assets'%}</span> <span class="LP-Paragraph">{% trans 'Place Assets'%}</span>
</td> </td>
<td class="LP-UserInfo__Value"> <td class="LP-UserInfo__Value">
<span class="LP-Paragraph">{{asset_count}}</span> <span class="LP-Paragraph">{{asset_count}}</span>

View File

@ -1,55 +0,0 @@
{% extends 'global.html'%}
{% load static %}
{% load i18n %}
{% load widget_tweaks %}
# {% block title %}{% trans 'Edit Explorer profile' %}{% endblock %}
{% block maincontent %}
<form class="LP-Form" method="POST">
<fieldset class="LP-Form__Fieldset">
<legend class="LP-Form__Legend">{% trans 'Edit Explorer profile' %}</legend>
{% csrf_token %}
<div class="LP-Form__Composition LP-Form__Composition--breakable">
<div class="LP-Form__Field">
{% include 'partials/form/inputField.html' with field=explorer_user_change_form.username %}
</div>
<div class="LP-Form__Field">
{% include 'partials/form/inputField.html' with field=explorer_user_change_form.email %}
</div>
</div>
<div class="LP-Form__Composition LP-Form__Composition--breakable">
<div class="LP-Form__Field">
{% include 'partials/form/inputField.html' with field=explorer_user_change_form.first_name %}
</div>
<div class="LP-Form__Field">
{% include 'partials/form/inputField.html' with field=explorer_user_change_form.last_name %}
</div>
</div>
<div class="LP-Form__Composition">
<div class="LP-Form__Field">
{% include 'partials/form/inputField.html' with field=explorer_change_form.bio %}
</div>
</div>
<div class="LP-Form__Composition">
{% if explorer_image_url %}
<div class="LP-Form__Field">
<img class="LP-Form__Field LP-Image" src="{{ explorer_image_url }}"/>
</div>
{% endif %}
<div class="LP-Form__Field">
{% include 'partials/form/inputField.html' with field=explorer_change_form.profile_image %}
</div>
</div>
{% trans '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 %}
</div>
</fieldset>
</form>
{% endblock maincontent %}

View File

@ -4,15 +4,15 @@ from django import forms
from django.utils import timezone from django.utils import timezone
from lostplaces.tests.forms import FormTestCase from lostplaces.tests.forms import FormTestCase
from lostplaces.forms import SignupVoucherForm from lostplaces.forms import ExplorerCreationForm
from lostplaces.models.models import Voucher from lostplaces.models.models import Voucher
class SignupVoucherFormTestCase(FormTestCase): class ExplorerCreationFormTestCase(FormTestCase):
""" """
This test case only tests for the voucher since all other aspects don't realy matter This test case only tests for the voucher since all other aspects don't realy matter
to this project and are already tested by django to this project and are already tested by django
""" """
form = SignupVoucherForm form = ExplorerCreationForm
@classmethod @classmethod
def setUpTestData(cls): def setUpTestData(cls):
@ -37,7 +37,7 @@ class SignupVoucherFormTestCase(FormTestCase):
) )
def test_validation_valid(self): def test_validation_valid(self):
form = SignupVoucherForm(self.post_data) form = ExplorerCreationForm(self.post_data)
self.assertTrue( self.assertTrue(
form.is_valid(), form.is_valid(),
msg='Expecting the %s to validate' % ( msg='Expecting the %s to validate' % (
@ -49,7 +49,7 @@ class SignupVoucherFormTestCase(FormTestCase):
self.post_data = { self.post_data = {
'voucher': 'Imanotacode123' 'voucher': 'Imanotacode123'
} }
form = SignupVoucherForm(self.post_data) form = ExplorerCreationForm(self.post_data)
self.assertFalse( self.assertFalse(
form.is_valid(), form.is_valid(),
msg='Expecting the %s to not validate' % ( msg='Expecting the %s to not validate' % (

View File

@ -18,8 +18,7 @@ from lostplaces.views import (
PlaceImageCreateView, PlaceImageCreateView,
PlaceImageDeleteView, PlaceImageDeleteView,
FlatView, FlatView,
ExplorerProfileView, ExplorerProfileView
ExplorerProfileUpdateView
) )
urlpatterns = [ urlpatterns = [
@ -40,8 +39,9 @@ urlpatterns = [
path('place/tag/delete/<int:tagged_id>/<int:tag_id>', PlaceTagDeleteView.as_view(), name='place_tag_delete'), path('place/tag/delete/<int:tagged_id>/<int:tag_id>', PlaceTagDeleteView.as_view(), name='place_tag_delete'),
path('explorer/<int:explorer_id>/', ExplorerProfileView.as_view(), name='explorer_profile'), path('explorer/<int:explorer_id>/', ExplorerProfileView.as_view(), name='explorer_profile'),
path('explorer/update/', ExplorerProfileUpdateView.as_view(), name='explorer_profile_update'),
path('explorer/favorite/<int:place_id>/', PlaceFavoriteView.as_view(), name='place_favorite'), path('explorer/favorite/<int:place_id>/', PlaceFavoriteView.as_view(), name='place_favorite'),
path('explorer/unfavorite/<int:place_id>/', PlaceUnfavoriteView.as_view(), name='place_unfavorite') path('explorer/unfavorite/<int:place_id>/', PlaceUnfavoriteView.as_view(), name='place_unfavorite')
] ]

View File

@ -12,7 +12,6 @@ from lostplaces.common import get_all_subclasses
from lostplaces.views.base_views import IsAuthenticatedMixin from lostplaces.views.base_views import IsAuthenticatedMixin
from lostplaces.models.models import Explorer from lostplaces.models.models import Explorer
from lostplaces.models.place import Place, PlaceAsset from lostplaces.models.place import Place, PlaceAsset
from lostplaces.forms import ExplorerChangeForm, ExplorerUserChangeForm
class ExplorerProfileView(IsAuthenticatedMixin, View): class ExplorerProfileView(IsAuthenticatedMixin, View):
def get(self, request, explorer_id): def get(self, request, explorer_id):
@ -40,15 +39,3 @@ class ExplorerProfileView(IsAuthenticatedMixin, View):
template_name='explorer/profile.html', template_name='explorer/profile.html',
context=context context=context
) )
class ExplorerProfileUpdateView(IsAuthenticatedMixin, View):
success_message = ''
permission_denied_message = ''
def get(self, request, *args, **kwargs):
context = {
'explorer_image_url': request.user.explorer.profile_image.url,
'explorer_user_change_form': ExplorerUserChangeForm(instance=request.user),
'explorer_change_form': ExplorerChangeForm(instance=request.user.explorer)
}
return render(request, 'explorer/profile_update.html', context)

View File

@ -11,7 +11,7 @@ from django.shortcuts import render, redirect, get_object_or_404
from django.http import HttpResponseForbidden from django.http import HttpResponseForbidden
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from lostplaces.forms import SignupVoucherForm, TagSubmitForm from lostplaces.forms import ExplorerCreationForm, TagSubmitForm
from lostplaces.models import Place, PhotoAlbum from lostplaces.models import Place, PhotoAlbum
from lostplaces.views.base_views import IsAuthenticatedMixin from lostplaces.views.base_views import IsAuthenticatedMixin
@ -23,7 +23,7 @@ from lostplaces.views.base_views import (
from taggit.models import Tag from taggit.models import Tag
class SignUpView(SuccessMessageMixin, CreateView): class SignUpView(SuccessMessageMixin, CreateView):
form_class = SignupVoucherForm form_class = ExplorerCreationForm
success_url = reverse_lazy('login') success_url = reverse_lazy('login')
template_name = 'signup.html' template_name = 'signup.html'
success_message = _('User created') success_message = _('User created')