Changeset 2026

Show
Ignore:
Timestamp:
06/10/09 15:47:12 (9 months ago)
Author:
JensDiemer
Message:

* make: EditableHtmlHeadFile?.get_absolute_url()
*

Location:
branches/0.9/pylucid_project
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • branches/0.9/pylucid_project/apps/pylucid/models.py

    r2022 r2026  
    517517            if settings.DEBUG: 
    518518                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): 
    522521        cachepath = self.get_cachepath() 
    523522        if os.path.isfile(cachepath): 
    524523            # The file exist in media path -> Let the webserver send this file ;) 
    525             url = posixpath.join( 
     524            return posixpath.join( 
    526525                settings.MEDIA_URL, settings.PYLUCID.PYLUCID_MEDIA_DIR, settings.PYLUCID.CACHE_DIR, 
    527526                self.filepath 
     
    529528        else: 
    530529            # 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() 
    532536        return headfile.HeadfileLink(url) 
    533537 
  • branches/0.9/pylucid_project/pylucid_plugins/admin_menu/templates/admin_menu/admin_top_menu.html

    r2022 r2026  
    99<script type="text/javascript" src="{{ PyLucid_media_url }}superfish/superfish.js" onerror="JavaScript:alert('{{ PyLucid_media_url }}superfish/superfish.js');" ></script> 
    1010<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> 
    1112<style type="text/css"> 
    1213<!-- 
     
    4041        <a href="{{ admin_menu_link }}">{% trans 'admin menu' %}</a> 
    4142        <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> 
    4344        </ul> 
    4445    </li> 
  • branches/0.9/pylucid_project/tests/test_Design.py

    r2024 r2026  
    1616 
    1717CSS_LINK = '<link href="%s" rel="stylesheet" type="text/css" />' 
     18JS_LINK = '<script src="%s" type="text/javascript" language="javascript" /></script>' 
    1819 
    1920 
     
    2223        super(DesignTest, self).__init__(*args, **kwargs) 
    2324         
    24         self.testcss1 = EditableHtmlHeadFile.objects.get(filepath=pylucid_test_data.TEST_CSS_FILEPATH1) 
    25         self.testcss2 = 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) 
    2627         
    2728        # fake django HttpRequest object, needed in UpdateInfoBaseModel save() method 
    2829        self.fake_request = pylucid_test_data.get_fake_request(usertype="superuser") 
    2930 
    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) 
    4235             
    4336        # Test urls in the page content 
     
    4841                '<title>1-rootpage title', 
    4942                 
    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, 
    5346            ), 
    5447            must_not_contain=( 
     
    5649            ), 
    5750        ) 
     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 
    5871 
    5972    def test_not_cached(self): 
     
    6275        """ 
    6376        # remove style cache file, if exist 
    64         for headfile in (self.testcss1, self.testcss2): 
     77        for headfile in (self.test_css, self.test_js): 
    6578            cachepath = headfile.get_cachepath() 
    6679            if os.path.isfile(cachepath): 
    6780                os.remove(cachepath) 
    6881            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" 
    8487        ) 
     88 
    8589 
    8690 
  • branches/0.9/pylucid_project/tests/test_tools/pylucid_test_data.py

    r2024 r2026  
    152152    }, 
    153153} 
    154 TEST_CSS_FILEPATH1 = "unittest/test1.css" 
    155 TEST_CSS_FILEPATH2 = "unittest/test2.css" 
     154TEST_CSS_FILEPATH = "unittest/test.css" 
     155TEST_JS_FILEPATH = "unittest/test.js" 
    156156 
    157157TEST_HEADFILES = { 
    158     TEST_CSS_FILEPATH1: { 
    159         "description": "CSS file 1 for unittests.", 
     158    TEST_CSS_FILEPATH: { 
     159        "description": "CSS file for unittests.", 
    160160        "content": ".test1 { color:red; } /* "+SITEINFO_TAG+" */", 
    161161    }, 
    162     TEST_CSS_FILEPATH2: { 
    163         "description": "CSS file 2 for 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+\" ;)');", 
    165165    } 
    166166} 
     
    168168    "unittest_design": { 
    169169        "template_name": "site_template/normal.html", 
    170         "headfiles": (TEST_CSS_FILEPATH1,TEST_CSS_FILEPATH2), 
     170        "headfiles": (TEST_CSS_FILEPATH,TEST_JS_FILEPATH), 
    171171    }, 
    172172}