~ubuntu-branches/ubuntu/precise/horizon/precise-updates

« back to all changes in this revision

Viewing changes to horizon/utils/html.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Adam Gandelman, Adrien Cunin
  • Date: 2012-04-04 07:21:15 UTC
  • mfrom: (1.1.12)
  • Revision ID: package-import@ubuntu.com-20120404072115-lb9v3gq3yv93ern2
Tags: 2012.1~rc2-0ubuntu1
[ Chuck Short ]
* New usptream release.
* debian/control: Use python-cherrypy3
* debian/rules: Update pythonpath in order to run tests.
* debian/patches/fix-coverage-binary-name.patch: Make the testsuite
  run.
* debian/rules: Fail build if tests fail.

[ Adam Gandelman ]
* debian/control: Add python-memcache 
* debain/dashboard.conf: Update to match current upstream documentation
  (LP: #966069)

[ Adrien Cunin ]
* Renamed Apache config file from dashboard.conf to openstack-dashboard.conf
  (LP: #965410)
  - Updated post{inst,rm} and added preinst to handle correctly the rename

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
    def get_default_classes(self):
13
13
        """
14
 
        Returns a list of default classes which should be combined with any
15
 
        other declared classes.
 
14
        Returns an iterable of default classes which should be combined with
 
15
        any other declared classes.
16
16
        """
17
17
        return []
18
18
 
19
19
    def get_default_attrs(self):
 
20
        """
 
21
        Returns a dict of default attributes which should be combined with
 
22
        other declared attributes.
 
23
        """
20
24
        return {}
21
25
 
22
 
    @property
23
 
    def attr_string(self):
 
26
    def get_final_attrs(self):
24
27
        """
25
 
        Returns a flattened string of HTML attributes based on the
26
 
        ``attrs`` dict provided to the class.
 
28
        Returns a dict containing the final attributes of this element
 
29
        which will be rendered.
27
30
        """
28
31
        final_attrs = copy.copy(self.get_default_attrs())
29
32
        final_attrs.update(self.attrs)
31
34
        default = " ".join(self.get_default_classes())
32
35
        defined = self.attrs.get('class', '')
33
36
        additional = " ".join(getattr(self, "classes", []))
34
 
        final_classes = " ".join((defined, default, additional)).strip()
 
37
        non_empty = [test for test in (defined, default, additional) if test]
 
38
        final_classes = " ".join(non_empty).strip()
35
39
        final_attrs.update({'class': final_classes})
36
 
        return flatatt(final_attrs)
 
40
        return final_attrs
 
41
 
 
42
    @property
 
43
    def attr_string(self):
 
44
        """
 
45
        Returns a flattened string of HTML attributes based on the
 
46
        ``attrs`` dict provided to the class.
 
47
        """
 
48
        return flatatt(self.get_final_attrs())
 
49
 
 
50
    @property
 
51
    def class_string(self):
 
52
        """
 
53
        Returns a list of class name of HTML Element in string
 
54
        """
 
55
        classes_str = " ".join(self.classes)
 
56
        return classes_str