← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~andreserl/maas/maas_yui_location into lp:maas

 

Andres Rodriguez has proposed merging lp:~andreserl/maas/maas_yui_location into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~andreserl/maas/maas_yui_location/+merge/97713
-- 
https://code.launchpad.net/~andreserl/maas/maas_yui_location/+merge/97713
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~andreserl/maas/maas_yui_location into lp:maas.
=== modified file 'src/maasserver/tests/test_views.py'
--- src/maasserver/tests/test_views.py	2012-03-15 11:27:27 +0000
+++ src/maasserver/tests/test_views.py	2012-03-15 18:07:28 +0000
@@ -37,6 +37,7 @@
 from maasserver.views import (
     get_longpoll_context,
     proxy_to_longpoll,
+    get_yui_location,
     )
 
 
@@ -209,6 +210,19 @@
 
 class TestUtilities(TestCase):
 
+    def test_get_yui_location_if_static_root_is_none(self):
+        self.patch(settings, 'STATIC_ROOT', None)
+        yui_location = os.path.join(
+            os.path.dirname(os.path.dirname(__file__)),
+            'static', 'jslibs', 'yui')
+        self.assertEqual(yui_location, get_yui_location())
+
+    def test_get_yui_location(self):
+        static_root = factory.getRandomString()
+        self.patch(settings, 'STATIC_ROOT', static_root)
+        yui_location = os.path.join(static_root, 'jslibs', 'yui')
+        self.assertEqual(yui_location, get_yui_location())
+        
     def test_get_longpoll_context_empty_if_rabbitmq_publish_is_none(self):
         self.patch(settings, 'RABBITMQ_PUBLISH', None)
         self.patch(views, 'messaging', get_messaging())

=== modified file 'src/maasserver/views.py'
--- src/maasserver/views.py	2012-03-15 13:59:16 +0000
+++ src/maasserver/views.py	2012-03-15 18:07:28 +0000
@@ -304,14 +304,18 @@
         {'form': form},
         context_instance=RequestContext(request))
 
-
-YUI_LOCATION = os.path.join(
-    os.path.dirname(__file__), 'static', 'jslibs', 'yui')
-
+def get_yui_location():
+    if django_settings.STATIC_ROOT:
+        return os.path.join(
+            django_settings.STATIC_ROOT, 'jslibs', 'yui')
+    else:
+        return os.path.join(
+            os.path.dirname(__file__), 'static', 'jslibs', 'yui')
 
 def combo_view(request):
     """Handle a request for combining a set of files."""
     fnames = parse_qs(request.META.get("QUERY_STRING", ""))
+    YUI_LOCATION = get_yui_location()
 
     if fnames:
         if fnames[0].endswith('.js'):


Follow ups