~dylanmccall/harvest/gsoc-client-stuff

« back to all changes in this revision

Viewing changes to harvest/filters/filters.py

  • Committer: Dylan McCall
  • Date: 2010-07-14 19:33:14 UTC
  • Revision ID: dylanmccall@gmail.com-20100714193314-s0rnb3eyzeqxjxq5
Tidier, slightly more stylish Python, with a bit of redundancy removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 
4
4
from containers import FilterContainer, FilterSystem
5
5
from django.utils.safestring import mark_safe
6
 
from copy import copy
7
6
 
8
7
class Filter(object): #abstract, extend in application
9
8
    """
158
157
        inner_html = self.render_html_inner(**kwargs)
159
158
        
160
159
        #safe because we are in full control of this content
161
 
        return mark_safe(
162
 
            u'<span class="%s" data-filter-fullname="%s">\n%s\n</span>' % \
163
 
            (self.html_class,
164
 
             self.get_full_name(),
165
 
             inner_html ))
 
160
        return mark_safe('<span class="%s" data-filter-fullname="%s">\n%s\n</span>' \
 
161
            % (self.html_class,
 
162
               self.get_full_name(),
 
163
               inner_html ) )
166
164
    
167
165
    def render_html_inner(self, **kwargs):
168
166
        """
188
186
        @return: the filter's label, rendered as html
189
187
        """
190
188
        link_url = None
191
 
        if 'toggle_href' in kwargs: link_url = kwargs['toggle_href']
 
189
        if 'toggle_href' in kwargs:
 
190
            link_url = kwargs['toggle_href']
192
191
        
193
192
        label = self.name
194
193
        if link_url:
325
324
        toggle_params = self.serialize(self.get_value_with_selection(item_id))
326
325
        item_href = self.get_system().get_url_with_parameters(toggle_params)
327
326
        
328
 
        return mark_safe(u'<a class="item-toggle" href="%s">%s</a>' % (item_href, item_id))
 
327
        return '<a class="item-toggle" href="%s">%s</a>' % (item_href, item_id)
329
328
 
330
329
 
331
330
class FilterGroup(FilterContainer, ChoiceFilter): #final