Changeset 2026
- Timestamp:
- 06/10/09 15:47:12 (9 months ago)
- Location:
- branches/0.9/pylucid_project
- Files:
-
- 1 added
- 4 modified
-
apps/pylucid/models.py (modified) (2 diffs)
-
media/PyLucid/pylucid_js_tools.js (added)
-
pylucid_plugins/admin_menu/templates/admin_menu/admin_top_menu.html (modified) (2 diffs)
-
tests/test_Design.py (modified) (5 diffs)
-
tests/test_tools/pylucid_test_data.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/0.9/pylucid_project/apps/pylucid/models.py
r2022 r2026 517 517 if settings.DEBUG: 518 518 warnings.warn("EditableHtmlHeadFile cached successful into: %r" % cachepath) 519 520 def get_headfilelink(self): 521 """ Get the link url to this head file. """ 519 520 def get_absolute_url(self): 522 521 cachepath = self.get_cachepath() 523 522 if os.path.isfile(cachepath): 524 523 # The file exist in media path -> Let the webserver send this file ;) 525 url =posixpath.join(524 return posixpath.join( 526 525 settings.MEDIA_URL, settings.PYLUCID.PYLUCID_MEDIA_DIR, settings.PYLUCID.CACHE_DIR, 527 526 self.filepath … … 529 528 else: 530 529 # not cached into filesystem -> use pylucid.views.send_head_file for it 531 url = reverse('PyLucid-send_head_file', kwargs={"filepath":self.filepath}) 530 return reverse('PyLucid-send_head_file', kwargs={"filepath":self.filepath}) 531 532 533 def get_headfilelink(self): 534 """ Get the link url to this head file. """ 535 url = self.get_absolute_url() 532 536 return headfile.HeadfileLink(url) 533 537 -
branches/0.9/pylucid_project/pylucid_plugins/admin_menu/templates/admin_menu/admin_top_menu.html
r2022 r2026 9 9 <script type="text/javascript" src="{{ PyLucid_media_url }}superfish/superfish.js" onerror="JavaScript:alert('{{ PyLucid_media_url }}superfish/superfish.js');" ></script> 10 10 <script type="text/javascript" src="{{ PyLucid_media_url }}superfish/pylucid_superfish_init.js" onerror="JavaScript:alert('{{ PyLucid_media_url }}superfish/pylucid_superfish_init.js');" ></script> 11 <script type="text/javascript" src="{{ PyLucid_media_url }}pylucid_js_tools.js" onerror="JavaScript:alert('{{ PyLucid_media_url }}pylucid_js_tools.js');" ></script> 11 12 <style type="text/css"> 12 13 <!-- … … 40 41 <a href="{{ admin_menu_link }}">{% trans 'admin menu' %}</a> 41 42 <ul> 42 <li><a href="{{ admin_menu_link }} ">in popup win</a></li>43 <li><a href="{{ admin_menu_link }}?_popup=1" onclick="OpenInWindow(this); return false">in popup win</a></li> 43 44 </ul> 44 45 </li> -
branches/0.9/pylucid_project/tests/test_Design.py
r2024 r2026 16 16 17 17 CSS_LINK = '<link href="%s" rel="stylesheet" type="text/css" />' 18 JS_LINK = '<script src="%s" type="text/javascript" language="javascript" /></script>' 18 19 19 20 … … 22 23 super(DesignTest, self).__init__(*args, **kwargs) 23 24 24 self.test css1 = EditableHtmlHeadFile.objects.get(filepath=pylucid_test_data.TEST_CSS_FILEPATH1)25 self.test css2 = EditableHtmlHeadFile.objects.get(filepath=pylucid_test_data.TEST_CSS_FILEPATH2)25 self.test_css = EditableHtmlHeadFile.objects.get(filepath=pylucid_test_data.TEST_CSS_FILEPATH) 26 self.test_js = EditableHtmlHeadFile.objects.get(filepath=pylucid_test_data.TEST_JS_FILEPATH) 26 27 27 28 # fake django HttpRequest object, needed in UpdateInfoBaseModel save() method 28 29 self.fake_request = pylucid_test_data.get_fake_request(usertype="superuser") 29 30 30 def test_cached(self): 31 """ 32 Test the stylesheet link, if the css file was cached into the filesystem. 33 """ 34 # Create the cache file, if not exist 35 for headfile in (self.testcss1, self.testcss2): 36 cachepath = headfile.get_cachepath() 37 if not os.path.isfile(cachepath): 38 os.makedirs(os.path.dirname(cachepath)) # Cache dir doesn't exist? 39 headfile.save(self.fake_request) # The save method should create the cache file 40 # Check if file exist 41 self.failUnless(os.path.isfile(cachepath), "Can't create cache file???") 31 def _assert_headfiles(self, test_css_url, test_js_url): 32 """ Test get_absolute_url() and head links in reponse content """ 33 self.failUnlessEqual(self.test_css.get_absolute_url(), test_css_url) 34 self.failUnlessEqual(self.test_js.get_absolute_url(), test_js_url) 42 35 43 36 # Test urls in the page content … … 48 41 '<title>1-rootpage title', 49 42 50 # Design head file link with filesystem cache url:51 CSS_LINK % "/media/PyLucid/headfile_cache/unittest/test1.css",52 CSS_LINK % "/media/PyLucid/headfile_cache/unittest/test2.css",43 # Design head file links: 44 CSS_LINK % test_css_url, 45 JS_LINK % test_js_url, 53 46 ), 54 47 must_not_contain=( … … 56 49 ), 57 50 ) 51 52 def test_cached(self): 53 """ 54 Test the stylesheet link, if the css file was cached into the filesystem. 55 """ 56 # Create the cache file, if not exist 57 for headfile in (self.test_css, self.test_js): 58 cachepath = headfile.get_cachepath() 59 if not os.path.isfile(cachepath): 60 os.makedirs(os.path.dirname(cachepath)) # Cache dir doesn't exist? 61 headfile.save(self.fake_request) # The save method should create the cache file 62 # Check if file exist 63 self.failUnless(os.path.isfile(cachepath), "Can't create cache file???") 64 65 # Test get_absolute_url() and head links in reponse content 66 self._assert_headfiles( 67 "/media/PyLucid/headfile_cache/unittest/test.css", 68 "/media/PyLucid/headfile_cache/unittest/test.js" 69 ) 70 58 71 59 72 def test_not_cached(self): … … 62 75 """ 63 76 # remove style cache file, if exist 64 for headfile in (self.test css1, self.testcss2):77 for headfile in (self.test_css, self.test_js): 65 78 cachepath = headfile.get_cachepath() 66 79 if os.path.isfile(cachepath): 67 80 os.remove(cachepath) 68 81 self.failUnless(not os.path.isfile(cachepath), "Cache file exist???") 69 70 # Check the urls in the page content 71 response = self.client.get("/") 72 self.assertResponse(response, 73 must_contain=( 74 '1-rootpage content', # PageContent 75 '<title>1-rootpage title', 76 77 # Design head file link with PyLucid own view url: 78 CSS_LINK % "/headfile/unittest/test1.css", 79 CSS_LINK % "/headfile/unittest/test2.css", 80 ), 81 must_not_contain=( 82 "Traceback", 83 ), 82 83 # Test get_absolute_url() and head links in reponse content 84 self._assert_headfiles( 85 "/headfile/unittest/test.css", 86 "/headfile/unittest/test.js" 84 87 ) 88 85 89 86 90 -
branches/0.9/pylucid_project/tests/test_tools/pylucid_test_data.py
r2024 r2026 152 152 }, 153 153 } 154 TEST_CSS_FILEPATH 1 = "unittest/test1.css"155 TEST_ CSS_FILEPATH2 = "unittest/test2.css"154 TEST_CSS_FILEPATH = "unittest/test.css" 155 TEST_JS_FILEPATH = "unittest/test.js" 156 156 157 157 TEST_HEADFILES = { 158 TEST_CSS_FILEPATH 1: {159 "description": "CSS file 1for unittests.",158 TEST_CSS_FILEPATH: { 159 "description": "CSS file for unittests.", 160 160 "content": ".test1 { color:red; } /* "+SITEINFO_TAG+" */", 161 161 }, 162 TEST_ CSS_FILEPATH2: {163 "description": " CSS file 2for unittests.",164 "content": " .test2 { color:red; } /* "+SITEINFO_TAG+" */",162 TEST_JS_FILEPATH: { 163 "description": "JS file for unittests.", 164 "content": "alert('Unittest JS file exists on \"+SITEINFO_TAG+\" ;)');", 165 165 } 166 166 } … … 168 168 "unittest_design": { 169 169 "template_name": "site_template/normal.html", 170 "headfiles": (TEST_CSS_FILEPATH 1,TEST_CSS_FILEPATH2),170 "headfiles": (TEST_CSS_FILEPATH,TEST_JS_FILEPATH), 171 171 }, 172 172 }