View for "my images"
This commit is contained in:
parent
1df19b8a74
commit
a54ad8954c
@ -24,6 +24,11 @@
|
||||
Upload image
|
||||
</a>
|
||||
</li>
|
||||
<li class="RV-Navigation__item">
|
||||
<a href="{% url 'my_images' %}" class="RV-Navigation__link">
|
||||
My images
|
||||
</a>
|
||||
</li>
|
||||
<li class="RV-Navigation__item">
|
||||
<a href="#" class="RV-Navigation__link">
|
||||
My galleries
|
||||
|
@ -2,10 +2,12 @@ from django.urls import path
|
||||
|
||||
from .views import (
|
||||
ImageUploadView,
|
||||
PublicImageListView
|
||||
PublicImageListView,
|
||||
MyImagesListView
|
||||
)
|
||||
|
||||
urlpatterns = [
|
||||
path('', PublicImageListView.as_view(), name='home'),
|
||||
path('upload/', ImageUploadView.as_view(), name='upload_image')
|
||||
path('upload/', ImageUploadView.as_view(), name='upload_image'),
|
||||
path('my_images/', MyImagesListView.as_view(), name='my_images')
|
||||
]
|
||||
|
@ -15,7 +15,7 @@ class VisitorSessionMixin(View):
|
||||
def get_visitor(self):
|
||||
if self.request.session:
|
||||
if 'visitor_session' in self.request.session:
|
||||
if Visitor.objects.get(session_id=self.request.session['visitor_session']).exists():
|
||||
if Visitor.objects.filter(session_id=self.request.session['visitor_session']).exists():
|
||||
return Visitor.objects.get(session_id=self.request.session['visitor_session'])
|
||||
else:
|
||||
visitor = Visitor.objects.create()
|
||||
@ -72,3 +72,13 @@ class PublicImageListView(ListView):
|
||||
|
||||
def get_queryset(self):
|
||||
return Image.objects.all().filter(private=False)
|
||||
|
||||
class MyImagesListView(VisitorSessionMixin, ListView):
|
||||
model = Image
|
||||
paginated_by = 20
|
||||
context_object_name = 'images'
|
||||
template_name = 'list_images/image_list.html'
|
||||
|
||||
def get_queryset(self):
|
||||
return Image.objects.all().filter(uploaded_by=self.get_visitor())
|
||||
|
Loading…
Reference in New Issue
Block a user