Commits

tehfink  committed 0f8ff32

factored out current_site context processor into its own package

  • Participants
  • Parent commits e32c55d

Comments (0)

Files changed (1)

File cmsplugin_photologue/urls.py

 from django.conf import settings
 
 #get variables defined in photologue.urls
-from photologue.urls import gallery_args, photo_args
-
-#defines a context processor because 'sites' is not being passed to photologue template for some reason
-def current_site(request):
-    """
-    A context processor to add the "current site" to the current Context
-    """
-    from django.contrib.sites.models import Site
-    try:
-        current_site = Site.objects.get_current()
-        return {
-            'site': current_site,
-        }
-    except Site.DoesNotExist:
-        # always return a dict
-        return {'current_site':''} # an empty string
-
-#add this context_processor as a FUNCTION
-gallery_args["context_processors"] = [current_site]
-photo_args["context_processors"] = [current_site]
+from photologue.urls import gallery_args
 
 #import photologue urls
 urlpatterns = patterns('',
     url(r'^', include('photologue.urls')),
 )
 
-#add our custom call to display gallery list for the root request; this only works in
-#this position because there is no root request definition defined in photologue.urls
+#site context now added as a real context processor in settings
+
+#add our custom call to display gallery list for the root request (not defined in photologue.urls)
 urlpatterns += patterns('django.views.generic.date_based',
-   url(r'^/?$', 'archive_index', gallery_args, name='pl-gallery-archive', ),
+   url(r'^/?$', 'archive_index', gallery_args, name='pl-gallery-archive',),
 )