Profile View
This commit is contained in:
		
							
								
								
									
										109
									
								
								django_lostplaces/lostplaces/templates/explorer/profile.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										109
									
								
								django_lostplaces/lostplaces/templates/explorer/profile.html
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,109 @@
 | 
			
		||||
{% extends 'global.html'%}
 | 
			
		||||
{% load static %}
 | 
			
		||||
{% load i18n %}
 | 
			
		||||
 | 
			
		||||
{% load svg_icon %}
 | 
			
		||||
 | 
			
		||||
{% block maincontent %}
 | 
			
		||||
 | 
			
		||||
<div class="LP-UserProfile">
 | 
			
		||||
    <div class="LP-UserProfile__Info">
 | 
			
		||||
        <div class="LP-UserInfo">
 | 
			
		||||
            <div class="LP-UserInfo__UserName">
 | 
			
		||||
                <h1 class="LP-Headline">{{explorer.user.username}}</h1>
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="LP-UserInfo__Meta">
 | 
			
		||||
                <table>
 | 
			
		||||
                    <tr>
 | 
			
		||||
                        <td class="LP-UserInfo__Key">
 | 
			
		||||
                            <span class="LP-Paragraph">{% trans 'Joined' %}</span>
 | 
			
		||||
                        </td>
 | 
			
		||||
                        <td class="LP-UserInfo__Value">
 | 
			
		||||
                            <span class="LP-Paragraph">{{explorer.user.date_joined|date:'d.m.Y'}}</span>
 | 
			
		||||
                        </td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    <tr>
 | 
			
		||||
                        <td class="LP-UserInfo__Key">
 | 
			
		||||
                            <span class="LP-Paragraph">{% trans 'Places'%}</span>
 | 
			
		||||
                        </td>
 | 
			
		||||
                        <td class="LP-UserInfo__Value">
 | 
			
		||||
                            <span class="LP-Paragraph">{{place_count}}</span>
 | 
			
		||||
                        </td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                    <tr>
 | 
			
		||||
                        <td class="LP-UserInfo__Key">
 | 
			
		||||
                            <span class="LP-Paragraph">{% trans 'Place Assets'%}</span>
 | 
			
		||||
                        </td>
 | 
			
		||||
                        <td class="LP-UserInfo__Value">
 | 
			
		||||
                            <span class="LP-Paragraph">{{asset_count}}</span>
 | 
			
		||||
                        </td>
 | 
			
		||||
                    </tr>
 | 
			
		||||
                </table>
 | 
			
		||||
            </div>
 | 
			
		||||
        </div>
 | 
			
		||||
    </div>
 | 
			
		||||
</div>
 | 
			
		||||
 | 
			
		||||
<section class="LP-Section">
 | 
			
		||||
	<div class="LP-PlaceList">
 | 
			
		||||
		<h1 class="LP-Headline">{% trans 'Places submitted by' %} {{explorer.user.username}}</h1>
 | 
			
		||||
		<ul class="LP-PlaceList__List">
 | 
			
		||||
			{% for place in place_list %}
 | 
			
		||||
			<li class="LP-PlaceList__Item">
 | 
			
		||||
				<a href="{% url 'place_detail' pk=place.pk %}" class="LP-Link">
 | 
			
		||||
					{% include 'partials/place_teaser.html' with place=place extended=True %}
 | 
			
		||||
				</a>
 | 
			
		||||
			</li>
 | 
			
		||||
			{% endfor %}
 | 
			
		||||
		</ul>
 | 
			
		||||
 | 
			
		||||
		{% include 'partials/nav/pagination.html' %}
 | 
			
		||||
 | 
			
		||||
	</div>
 | 
			
		||||
</section>
 | 
			
		||||
 | 
			
		||||
<section class="LP-Section">
 | 
			
		||||
	<h1 class="LP-Headline">{% trans 'Images submitted by' %} {{explorer.user.username}}</h1>
 | 
			
		||||
	<div class="LP-ImageGrid">
 | 
			
		||||
		<ul class="LP-ImageGrid__Container">
 | 
			
		||||
			{% for place_image in assets.placeimages.all %}
 | 
			
		||||
			<li class="LP-ImageGrid__Item">
 | 
			
		||||
				<a href="{{ place_image.filename.large.url }}" class="LP-Link">
 | 
			
		||||
					<img class="LP-Image" src="{{ place_image.filename.thumbnail.url }}">
 | 
			
		||||
				</a>
 | 
			
		||||
				{% if user.explorer == place_image.submitted_by%}
 | 
			
		||||
				<span class="LP-ImageGrid__DeleteItem" title="Bild löschen">
 | 
			
		||||
					<a href="{% url 'place_image_delete' pk=place_image.id %}" class="LP-Link">
 | 
			
		||||
						<img class="LP-Icon" src="{% static 'icons/cancel.svg' %}" />
 | 
			
		||||
					</a>
 | 
			
		||||
				</span>
 | 
			
		||||
				{% endif %}
 | 
			
		||||
			</li>
 | 
			
		||||
			{% endfor %}
 | 
			
		||||
		</ul>
 | 
			
		||||
	</div>
 | 
			
		||||
</section>
 | 
			
		||||
 | 
			
		||||
<section class=" LP-Section">
 | 
			
		||||
	<h1 class="LP-Headline">{% trans 'Photo albums submitted by' %} {{explorer.user.username}}</h1>
 | 
			
		||||
	<div class="LP-LinkList">
 | 
			
		||||
		<ul class="LP-LinkList__Container">
 | 
			
		||||
			{% for photo_album in assets.photoalbums.all %}
 | 
			
		||||
			<li class="LP-LinkList__Item">
 | 
			
		||||
				<a target="_blank" href="{{photo_album.url}}" class="LP-Link">
 | 
			
		||||
					<span class="LP-Text">{{photo_album.label}}</span>
 | 
			
		||||
				</a>
 | 
			
		||||
				{% if user.explorer == photo_album.submitted_by%}
 | 
			
		||||
				<a href="{% url 'photo_album_delete' pk=photo_album.pk%}" class="LP-Link LP-LinkList__ItemHover" title="Delete Photo Album">
 | 
			
		||||
					<div class="RV-Iconized__Container RV-Iconized__Container--small">
 | 
			
		||||
						{% icon 'trash' className="RV-Iconized__Icon" %}
 | 
			
		||||
					</div>
 | 
			
		||||
				</a>
 | 
			
		||||
				{% endif %}
 | 
			
		||||
			</li>
 | 
			
		||||
			{% endfor %}
 | 
			
		||||
		</ul>
 | 
			
		||||
	</div>
 | 
			
		||||
</section>
 | 
			
		||||
 | 
			
		||||
{% endblock maincontent %}
 | 
			
		||||
							
								
								
									
										45
									
								
								django_lostplaces/lostplaces/views/explorer_views.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								django_lostplaces/lostplaces/views/explorer_views.py
									
									
									
									
									
										Normal file
									
								
							@@ -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
 | 
			
		||||
        )
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
		Reference in New Issue
	
	Block a user