aboutsummaryrefslogtreecommitdiff
path: root/apps/utils/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'apps/utils/views.py')
-rw-r--r--apps/utils/views.py48
1 files changed, 31 insertions, 17 deletions
diff --git a/apps/utils/views.py b/apps/utils/views.py
index dcb16a8..595e102 100644
--- a/apps/utils/views.py
+++ b/apps/utils/views.py
@@ -1,11 +1,18 @@
from itertools import chain
import json
from django.http import Http404, HttpResponse
+from django.apps import apps
from django.views.generic import ListView
-from photos.models import LuxImage, LuxVideo
+from django.views.generic.base import View, RedirectView
+from django.utils.decorators import method_decorator
+from django.contrib.auth.decorators import login_required
+#from photos.models import LuxImage, LuxVideo
from django.shortcuts import render_to_response
from django.shortcuts import render
from django.template import RequestContext
+from taggit.models import Tag
+#from dal import autocomplete
+
class PaginatedListView(ListView):
"""
@@ -26,24 +33,16 @@ class PaginatedListView(ListView):
return super(PaginatedListView, self).dispatch(request, *args, **kwargs)
-def insert_image(request):
- """
- The view that handles the admin insert image/video feature
- """
- images = LuxImage.objects.all()[:80]
- videos = LuxVideo.objects.all()[:10]
- object_list = sorted(
- chain(images, videos),
- key=lambda instance: instance.pub_date,
- reverse=True
- )
- return render(request, 'admin/insert_images.html', {'object_list': object_list, 'textarea_id': request.GET['textarea']})
-
+@method_decorator(login_required, name='dispatch')
+class LoggedInViewWithUser(View):
-from taggit.models import Tag
+ def get_form_kwargs(self, **kwargs):
+ kwargs = super().get_form_kwargs(**kwargs)
+ kwargs.update({'user': self.request.user})
+ return kwargs
-from dal import autocomplete
+'''
class TagAutocomplete(autocomplete.Select2QuerySetView):
def get_queryset(self):
# Don't forget to filter out results depending on the visitor !
@@ -57,7 +56,6 @@ class TagAutocomplete(autocomplete.Select2QuerySetView):
return qs
-from django.apps import apps
def nav_json(request, app, model, pk):
model = apps.get_model(app_label=app, model_name=model)
@@ -67,3 +65,19 @@ def nav_json(request, app, model, pk):
data['next'] = p.get_next_admin_url
data = json.dumps(data)
return HttpResponse(data)
+
+
+def insert_image(request):
+ """
+ The view that handles the admin insert image/video feature
+ """
+ images = LuxImage.objects.all()[:80]
+ videos = LuxVideo.objects.all()[:10]
+ object_list = sorted(
+ chain(images, videos),
+ key=lambda instance: instance.pub_date,
+ reverse=True
+ )
+ return render(request, 'admin/insert_images.html', {'object_list': object_list, 'textarea_id': request.GET['textarea']})
+'''
+