diff --git a/django_lostplaces/lostplaces/templates/explorer/profile.html b/django_lostplaces/lostplaces/templates/explorer/profile.html new file mode 100644 index 0000000..4cf7948 --- /dev/null +++ b/django_lostplaces/lostplaces/templates/explorer/profile.html @@ -0,0 +1,109 @@ +{% extends 'global.html'%} +{% load static %} +{% load i18n %} + +{% load svg_icon %} + +{% block maincontent %} + +
+
+
+
+

{{explorer.user.username}}

+
+
+ + + + + + + + + + + + + +
+ {% trans 'Joined' %} + + {{explorer.user.date_joined|date:'d.m.Y'}} +
+ {% trans 'Places'%} + + {{place_count}} +
+ {% trans 'Place Assets'%} + + {{asset_count}} +
+
+
+
+
+ +
+
+

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

+ + + {% include 'partials/nav/pagination.html' %} + +
+
+ +
+

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

+
+ +
+
+ +
+

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

+ +
+ +{% endblock maincontent %} \ No newline at end of file diff --git a/django_lostplaces/lostplaces/views/explorer_views.py b/django_lostplaces/lostplaces/views/explorer_views.py new file mode 100644 index 0000000..3fee7d3 --- /dev/null +++ b/django_lostplaces/lostplaces/views/explorer_views.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from django.views import View + +from django.utils.translation import ugettext_lazy as _ + +from django.shortcuts import render, redirect, get_object_or_404 +from django.urls import reverse_lazy + +from lostplaces.common import get_all_subclasses +from lostplaces.views.base_views import IsAuthenticatedMixin +from lostplaces.models.models import Explorer +from lostplaces.models.place import Place, PlaceAsset + +class ExplorerProfileView(IsAuthenticatedMixin, View): + def get(self, request, explorer_id): + explorer = get_object_or_404(Explorer, pk=explorer_id) + place_list = Place.objects.filter(submitted_by=explorer) + place_count = place_list.count() + + context={ + 'explorer': explorer, + 'place_count': place_count, + 'place_list': place_list, + 'assets': {} + } + + asset_count = 0 + for subclass in get_all_subclasses(PlaceAsset): # kinda ugly, but PlaceAsset cannot be abstract according to django ORM + objects = subclass.objects.filter(submitted_by=explorer) + context['assets'][subclass.__name__.lower()+'s'] = objects + asset_count += objects.count() + + context['asset_count'] = asset_count + + print(context['assets']) + + return render( + request=request, + template_name='explorer/profile.html', + context=context + ) + + \ No newline at end of file