~dylanmccall/harvest/gsoc-client-stuff

« back to all changes in this revision

Viewing changes to harvest/opportunities/wrappers.py

  • Committer: Dylan McCall
  • Date: 2010-07-14 23:42:34 UTC
  • Revision ID: dylanmccall@gmail.com-20100714234234-8nf5dz6crofc6xuy
More robust behaviour for expanding and collapsing packages.
Packages that are collapsed while results are being loaded (after request is sent to server) are collapsed again after they are loaded.
Packages check if they are expanded when first created again.
wrappers.py makes sure a string represents a number before trying to convert it to an int.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
    """
49
49
    
50
50
    def __init__(self, request, packages_list, opportunities_list):
51
 
        expand_list = None #list of packages to show in detail
52
 
        if 'expand_pkg' in request.GET and request.GET['expand_pkg']:
 
51
        expand_list = list() #list of packages to show in detail
 
52
        if 'expand_pkg' in request.GET:
53
53
            expand_list = request.GET['expand_pkg'].split(',')
54
 
            expand_list = [int(i) for i in expand_list]
 
54
            expand_list = [int(i) for i in expand_list if i.isdigit()]
55
55
        
56
56
        related_packages = set(opportunities_list.values_list('sourcepackage', flat=True))
57
57
        
65
65
                opps = None
66
66
                expand = False
67
67
                
68
 
                if expand_list: expand = (package.id in expand_list)
 
68
                expand = (package.id in expand_list)
69
69
                opps = opportunities_list.filter(sourcepackage=package)
70
70
                
71
71
                package_wrapper = PackageWrapper(request, package,
88
88
        """
89
89
        Returns list of packages that have been hidden from view.
90
90
        """
91
 
        return self.hidden_packages_list
 
 
b'\\ No newline at end of file'
 
91
        return self.hidden_packages_list