Contact forms app.
[prawokultury.git] / migdal / views.py
index 594444d..84cd6fe 100644 (file)
@@ -45,8 +45,9 @@ def entry_list(request, type_db=None, category_slug=None):
 
 def entry(request, type_db, slug):
     lang = request.LANGUAGE_CODE
 
 def entry(request, type_db, slug):
     lang = request.LANGUAGE_CODE
-    args = {'type': type_db, 'slug_%s' % lang: slug, 'published_%s' % lang: True}
-    # TODO: preview for admins
+    args = {'type': type_db, 'slug_%s' % lang: slug}
+    if not request.user.has_perm('migdal.change_entry'):
+        args['published_%s' % lang] = True
     entry = get_object_or_404(Entry, **args)
 
     templates = ["migdal/entry/entry_detail.html"]
     entry = get_object_or_404(Entry, **args)
 
     templates = ["migdal/entry/entry_detail.html"]
@@ -80,7 +81,6 @@ class SearchPublishedView(SearchView):
         results = super(SearchPublishedView, self).get_results()
         lang_code = get_language()
         def is_published(entity):
         results = super(SearchPublishedView, self).get_results()
         lang_code = get_language()
         def is_published(entity):
-            print "is published? %s, %s" % (entity.published_pl, entity.published_en) 
             if isinstance(entity, Entry):
                 return getattr(entity, "published_%s" % lang_code) == True
             else:
             if isinstance(entity, Entry):
                 return getattr(entity, "published_%s" % lang_code) == True
             else: