From 59cfa82ce924a40b8403e3a6dc00a7da2f94c86a Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 25 Dec 2020 17:54:15 +0100 Subject: [PATCH 1/8] Resorted and -grouped urls. --- django_lostplaces/lostplaces/urls.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/django_lostplaces/lostplaces/urls.py b/django_lostplaces/lostplaces/urls.py index 29f5007..d445f81 100644 --- a/django_lostplaces/lostplaces/urls.py +++ b/django_lostplaces/lostplaces/urls.py @@ -25,25 +25,24 @@ from lostplaces.views import ( urlpatterns = [ path('', HomeView.as_view(), name='lostplaces_home'), + path('flat//', FlatView, name='flatpage'), + path('osm/', OSMMapView.as_view(), name='osm'), + + path('place/', PlaceListView.as_view(), name='place_list'), path('place//', PlaceDetailView.as_view(), name='place_detail'), path('place/create/', PlaceCreateView.as_view(), name='place_create'), - path('photo_album/create/', PhotoAlbumCreateView.as_view(), name='photo_album_create'), - path('photo_album/delete/', PhotoAlbumDeleteView.as_view(), name='photo_album_delete'), path('place/update//', PlaceUpdateView.as_view(), name='place_edit'), path('place/delete//', PlaceDeleteView.as_view(), name='place_delete'), - path('place/', PlaceListView.as_view(), name='place_list'), path('place_image/create/', PlaceImageCreateView.as_view(), name='place_image_create'), path('place_image/delete/', PlaceImageDeleteView.as_view(), name='place_image_delete'), - path('flat//', FlatView, name='flatpage'), - - # POST-only URLs for tag submission path('place/tag/', PlaceTagSubmitView.as_view(), name='place_tag_submit'), path('place/tag/delete//', PlaceTagDeleteView.as_view(), name='place_tag_delete'), - + + path('photo_album/create/', PhotoAlbumCreateView.as_view(), name='photo_album_create'), + path('photo_album/delete/', PhotoAlbumDeleteView.as_view(), name='photo_album_delete'), + path('explorer//', ExplorerProfileView.as_view(), name='explorer_profile'), path('explorer/update/', ExplorerProfileUpdateView.as_view(), name='explorer_profile_update'), - path('explorer/favorite//', PlaceFavoriteView.as_view(), name='place_favorite'), - path('explorer/unfavorite//', PlaceUnfavoriteView.as_view(), name='place_unfavorite'), - path('osm/', OSMMapView.as_view(), name='osm') + path('explorer/unfavorite//', PlaceUnfavoriteView.as_view(), name='place_unfavorite') ] From 0d1d829abe8296a602b711eceb50d4f8097ab506 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 25 Dec 2020 17:56:17 +0100 Subject: [PATCH 2/8] Regrouped views. --- django_lostplaces/lostplaces/urls.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/django_lostplaces/lostplaces/urls.py b/django_lostplaces/lostplaces/urls.py index d445f81..e50bf2d 100644 --- a/django_lostplaces/lostplaces/urls.py +++ b/django_lostplaces/lostplaces/urls.py @@ -4,6 +4,8 @@ from django.urls import path from lostplaces.views import ( HomeView, + FlatView, + OSMMapView, PlaceDetailView, PlaceListView, PlaceCreateView, @@ -13,14 +15,12 @@ from lostplaces.views import ( PlaceTagSubmitView, PlaceFavoriteView, PlaceUnfavoriteView, - PhotoAlbumCreateView, - PhotoAlbumDeleteView, PlaceImageCreateView, PlaceImageDeleteView, - FlatView, + PhotoAlbumCreateView, + PhotoAlbumDeleteView, ExplorerProfileView, - ExplorerProfileUpdateView, - OSMMapView + ExplorerProfileUpdateView ) urlpatterns = [ From a4780a22f2b916cae276d83c51ac51933a37d02c Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 25 Dec 2020 18:17:05 +0100 Subject: [PATCH 3/8] Changed urlpattern tree. --- django_lostplaces/lostplaces/urls.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/django_lostplaces/lostplaces/urls.py b/django_lostplaces/lostplaces/urls.py index e50bf2d..a7560ec 100644 --- a/django_lostplaces/lostplaces/urls.py +++ b/django_lostplaces/lostplaces/urls.py @@ -28,21 +28,22 @@ urlpatterns = [ path('flat//', FlatView, name='flatpage'), path('osm/', OSMMapView.as_view(), name='osm'), + path('explorer//', ExplorerProfileView.as_view(), name='explorer_profile'), + path('explorer/update/', ExplorerProfileUpdateView.as_view(), name='explorer_profile_update'), + path('place/', PlaceListView.as_view(), name='place_list'), path('place//', PlaceDetailView.as_view(), name='place_detail'), path('place/create/', PlaceCreateView.as_view(), name='place_create'), path('place/update//', PlaceUpdateView.as_view(), name='place_edit'), path('place/delete//', PlaceDeleteView.as_view(), name='place_delete'), + path('place/tag/create/', PlaceTagSubmitView.as_view(), name='place_tag_submit'), + path('place/tag/delete//', PlaceTagDeleteView.as_view(), name='place_tag_delete'), + path('place/fav/create//', PlaceFavoriteView.as_view(), name='place_favorite'), + path('place/fav/delete//', PlaceUnfavoriteView.as_view(), name='place_unfavorite'), + path('place_image/create/', PlaceImageCreateView.as_view(), name='place_image_create'), path('place_image/delete/', PlaceImageDeleteView.as_view(), name='place_image_delete'), - path('place/tag/', PlaceTagSubmitView.as_view(), name='place_tag_submit'), - path('place/tag/delete//', PlaceTagDeleteView.as_view(), name='place_tag_delete'), path('photo_album/create/', PhotoAlbumCreateView.as_view(), name='photo_album_create'), - path('photo_album/delete/', PhotoAlbumDeleteView.as_view(), name='photo_album_delete'), - - path('explorer//', ExplorerProfileView.as_view(), name='explorer_profile'), - path('explorer/update/', ExplorerProfileUpdateView.as_view(), name='explorer_profile_update'), - path('explorer/favorite//', PlaceFavoriteView.as_view(), name='place_favorite'), - path('explorer/unfavorite//', PlaceUnfavoriteView.as_view(), name='place_unfavorite') + path('photo_album/delete/', PhotoAlbumDeleteView.as_view(), name='photo_album_delete') ] From 9eef044af94fe4160301ee1b1326bb484ba1cb43 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 25 Dec 2020 19:19:01 +0100 Subject: [PATCH 4/8] Renamed favorite* svgs. --- .../lostplaces/static/icons/{favourite.svg => favorite.svg} | 0 .../static/icons/{favourite_filled.svg => favorite_filled.svg} | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename django_lostplaces/lostplaces/static/icons/{favourite.svg => favorite.svg} (100%) rename django_lostplaces/lostplaces/static/icons/{favourite_filled.svg => favorite_filled.svg} (99%) diff --git a/django_lostplaces/lostplaces/static/icons/favourite.svg b/django_lostplaces/lostplaces/static/icons/favorite.svg similarity index 100% rename from django_lostplaces/lostplaces/static/icons/favourite.svg rename to django_lostplaces/lostplaces/static/icons/favorite.svg diff --git a/django_lostplaces/lostplaces/static/icons/favourite_filled.svg b/django_lostplaces/lostplaces/static/icons/favorite_filled.svg similarity index 99% rename from django_lostplaces/lostplaces/static/icons/favourite_filled.svg rename to django_lostplaces/lostplaces/static/icons/favorite_filled.svg index c5cc50c..fdb73a4 100644 --- a/django_lostplaces/lostplaces/static/icons/favourite_filled.svg +++ b/django_lostplaces/lostplaces/static/icons/favorite_filled.svg @@ -13,7 +13,7 @@ viewBox="0 0 512.07 512.07" width="512" version="1.1" - sodipodi:docname="favourite_filled.svg" + sodipodi:docname="favorite_filled.svg" inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"> From 067bf36118dbbb5aaa2303ccff1bde7bbb7d9ee9 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 25 Dec 2020 19:20:44 +0100 Subject: [PATCH 5/8] SVG paths updated. --- .../lostplaces/templates/partials/icons/place_favorite.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django_lostplaces/lostplaces/templates/partials/icons/place_favorite.html b/django_lostplaces/lostplaces/templates/partials/icons/place_favorite.html index d87ef9e..15f2881 100644 --- a/django_lostplaces/lostplaces/templates/partials/icons/place_favorite.html +++ b/django_lostplaces/lostplaces/templates/partials/icons/place_favorite.html @@ -4,11 +4,11 @@ {% if request.user %} {% if place in request.user.explorer.favorite_places.all %} - + {%else%} - + {% endif %} {% endif %} \ No newline at end of file From 6b7c71ef30dd23486cc3b61cf7dbdf4a4b8943b5 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 25 Dec 2020 19:32:54 +0100 Subject: [PATCH 6/8] Addid visited_places system. (mostly copy&paste) :P --- django_lostplaces/lostplaces/models/models.py | 6 ++++++ .../templates/explorer/profile.html | 14 ++++++++++++- .../partials/icons/place_visited.html | 14 +++++++++++++ .../templates/partials/place_teaser.html | 2 +- .../templates/place/place_detail.html | 2 +- django_lostplaces/lostplaces/urls.py | 16 +++++++++------ .../lostplaces/views/place_views.py | 20 +++++++++++++++++++ 7 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 django_lostplaces/lostplaces/templates/partials/icons/place_visited.html diff --git a/django_lostplaces/lostplaces/models/models.py b/django_lostplaces/lostplaces/models/models.py index 2d39ca6..5914583 100644 --- a/django_lostplaces/lostplaces/models/models.py +++ b/django_lostplaces/lostplaces/models/models.py @@ -62,6 +62,12 @@ class Explorer(models.Model): verbose_name='Explorers favorite places', blank=True ) + visited_places = models.ManyToManyField( + Place, + related_name='explorer_visits', + verbose_name='Explorers visited places', + blank=True + ) def __str__(self): return self.user.username diff --git a/django_lostplaces/lostplaces/templates/explorer/profile.html b/django_lostplaces/lostplaces/templates/explorer/profile.html index 8bdd07d..f8779b6 100644 --- a/django_lostplaces/lostplaces/templates/explorer/profile.html +++ b/django_lostplaces/lostplaces/templates/explorer/profile.html @@ -92,9 +92,21 @@ {% endfor %} - {% include 'partials/nav/pagination.html' %} + + +
+
+

{% trans 'Visited places' %}

+
    + {% for place in explorer.visited_places.all %} +
  • + {% include 'partials/place_teaser.html' with place=place extended=True %} +
  • + {% endfor %} +
+ {% include 'partials/nav/pagination.html' %}
diff --git a/django_lostplaces/lostplaces/templates/partials/icons/place_visited.html b/django_lostplaces/lostplaces/templates/partials/icons/place_visited.html new file mode 100644 index 0000000..79232c2 --- /dev/null +++ b/django_lostplaces/lostplaces/templates/partials/icons/place_visited.html @@ -0,0 +1,14 @@ +{%load static %} +{% load i18n %} + +{% if request.user %} +{% if place in request.user.explorer.visited_places.all %} + + + +{%else%} + + + +{% endif %} +{% 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 aa1418f..7028eb1 100644 --- a/django_lostplaces/lostplaces/templates/partials/place_teaser.html +++ b/django_lostplaces/lostplaces/templates/partials/place_teaser.html @@ -31,7 +31,7 @@
  • {% include 'partials/icons/place_favorite.html' with place=place%}
  • -
  • +
  • {% include 'partials/icons/place_visited.html' with place=place%}
diff --git a/django_lostplaces/lostplaces/templates/place/place_detail.html b/django_lostplaces/lostplaces/templates/place/place_detail.html index 5db1360..dbbd06f 100644 --- a/django_lostplaces/lostplaces/templates/place/place_detail.html +++ b/django_lostplaces/lostplaces/templates/place/place_detail.html @@ -23,7 +23,7 @@
-

{{ place.name }} {% include 'partials/icons/place_favorite.html' %}

+

{{ place.name }} {% include 'partials/icons/place_favorite.html' %} {% include 'partials/icons/place_visited.html' %}

{% if place.placeimages.first.filename.hero.url %}
diff --git a/django_lostplaces/lostplaces/urls.py b/django_lostplaces/lostplaces/urls.py index a7560ec..35f6ce4 100644 --- a/django_lostplaces/lostplaces/urls.py +++ b/django_lostplaces/lostplaces/urls.py @@ -15,6 +15,8 @@ from lostplaces.views import ( PlaceTagSubmitView, PlaceFavoriteView, PlaceUnfavoriteView, + PlaceVisitCreateView, + PlaceVisitDeleteView, PlaceImageCreateView, PlaceImageDeleteView, PhotoAlbumCreateView, @@ -36,14 +38,16 @@ urlpatterns = [ path('place/create/', PlaceCreateView.as_view(), name='place_create'), path('place/update//', PlaceUpdateView.as_view(), name='place_edit'), path('place/delete//', PlaceDeleteView.as_view(), name='place_delete'), - path('place/tag/create/', PlaceTagSubmitView.as_view(), name='place_tag_submit'), - path('place/tag/delete//', PlaceTagDeleteView.as_view(), name='place_tag_delete'), + path('place/tag/create//', PlaceTagSubmitView.as_view(), name='place_tag_submit'), + path('place/tag/delete///', PlaceTagDeleteView.as_view(), name='place_tag_delete'), path('place/fav/create//', PlaceFavoriteView.as_view(), name='place_favorite'), path('place/fav/delete//', PlaceUnfavoriteView.as_view(), name='place_unfavorite'), + path('place/visit/create//', PlaceVisitCreateView.as_view(), name='place_visit_create'), + path('place/visit/delete//', PlaceVisitDeleteView.as_view(), name='place_visit_delete'), - path('place_image/create/', PlaceImageCreateView.as_view(), name='place_image_create'), - path('place_image/delete/', PlaceImageDeleteView.as_view(), name='place_image_delete'), + path('place_image/create//', PlaceImageCreateView.as_view(), name='place_image_create'), + path('place_image/delete//', PlaceImageDeleteView.as_view(), name='place_image_delete'), - path('photo_album/create/', PhotoAlbumCreateView.as_view(), name='photo_album_create'), - path('photo_album/delete/', PhotoAlbumDeleteView.as_view(), name='photo_album_delete') + path('photo_album/create//', PhotoAlbumCreateView.as_view(), name='photo_album_create'), + path('photo_album/delete//', PhotoAlbumDeleteView.as_view(), name='photo_album_delete') ] diff --git a/django_lostplaces/lostplaces/views/place_views.py b/django_lostplaces/lostplaces/views/place_views.py index 379f02e..29069db 100644 --- a/django_lostplaces/lostplaces/views/place_views.py +++ b/django_lostplaces/lostplaces/views/place_views.py @@ -147,3 +147,23 @@ class PlaceUnfavoriteView(IsAuthenticatedMixin, View): request.user.explorer.save() return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk})) + +class PlaceVisitCreateView(IsAuthenticatedMixin, View): + + def get(self, request, place_id): + place = get_object_or_404(Place, id=place_id) + if request.user is not None: + request.user.explorer.visited_places.add(place) + request.user.explorer.save() + + return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk})) + +class PlaceVisitDeleteView(IsAuthenticatedMixin, View): + + def get(self, request, place_id): + place = get_object_or_404(Place, id=place_id) + if request.user is not None: + request.user.explorer.visited_places.remove(place) + request.user.explorer.save() + + return redirect_referer_or(request, reverse('place_detail', kwargs={'pk': place.pk})) From 7f2283325cd0df445952799feffbc63ced465ffa Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 25 Dec 2020 19:35:35 +0100 Subject: [PATCH 7/8] gory migration fuckery (rename) --- .../migrations/{0004_auto_20201225_1702.py => 0004_gory_fix.py} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename django_lostplaces/lostplaces/migrations/{0004_auto_20201225_1702.py => 0004_gory_fix.py} (100%) diff --git a/django_lostplaces/lostplaces/migrations/0004_auto_20201225_1702.py b/django_lostplaces/lostplaces/migrations/0004_gory_fix.py similarity index 100% rename from django_lostplaces/lostplaces/migrations/0004_auto_20201225_1702.py rename to django_lostplaces/lostplaces/migrations/0004_gory_fix.py From a22c988e948438415d1a58cac627243ae24785f4 Mon Sep 17 00:00:00 2001 From: Commander1024 Date: Fri, 25 Dec 2020 19:36:11 +0100 Subject: [PATCH 8/8] Added visited_places attribute to Explorer. --- .../migrations/0005_add_visited_places.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 django_lostplaces/lostplaces/migrations/0005_add_visited_places.py diff --git a/django_lostplaces/lostplaces/migrations/0005_add_visited_places.py b/django_lostplaces/lostplaces/migrations/0005_add_visited_places.py new file mode 100644 index 0000000..3b4af82 --- /dev/null +++ b/django_lostplaces/lostplaces/migrations/0005_add_visited_places.py @@ -0,0 +1,18 @@ +# Generated by Django 3.1.4 on 2020-12-25 18:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('lostplaces', '0004_auto_20201225_1702'), + ] + + operations = [ + migrations.AddField( + model_name='explorer', + name='visited_places', + field=models.ManyToManyField(blank=True, related_name='explorer_visits', to='lostplaces.Place', verbose_name='Explorers visited places'), + ), + ]