Show
Ignore:
Timestamp:
12/23/09 06:06:58 (2 years ago)
Author:
dray
Message:

freeversity changes, initial work toward deprecating OpenOCW

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • enpraxis.educommons/trunk/enpraxis/educommons/portlet/simplenavportlet.py

    r506 r632  
    5858                    'getExcludeFromNav':False, 
    5959                    'sort_on':'getObjPositionInCourse'} 
    60  
    6160            brains = self.context.portal_catalog.searchResults(path) 
    6261 
     62        elif self.isDivisionObject(): 
     63            parent = self.getDivisionParent() 
     64            path = {'path':{'query':'/'.join(parent.getPhysicalPath())+'/'}, 
     65                    'getExcludeFromNav':False, 
     66                    'portal_type':'Division', 
     67                    'sort_on':'sortable_title'}             
     68            brains = self.context.portal_catalog.searchResults(path) 
     69                                                                    
    6370        else: 
    64             brains = self.context.portal_catalog.searchResults(Type='Division', 
    65                                                                sort_on='sortable_title') 
     71            brains = self.context.portal_catalog.searchResults(Type='School', 
     72                                                               sort_on='sortable_title')                                                                    
     73            if len(brains) == 0: 
     74                brains = self.context.portal_catalog.searchResults(Type='Division', 
     75                                                                   sort_on='sortable_title')                                                                    
     76                                                     
     77 
    6678        return [obj for obj in brains if not getattr(obj.aq_explicit, 'exclude_from_nav', True)] 
    6779 
     
    7082        return 'Course' == self.ecparent.Type() 
    7183 
     84    def isDivisionObject(self): 
     85        """ Check if this object is in a Division. """ 
     86        return 'Division' == self.ecparent.Type() 
     87 
     88    def getDivisionParent(self): 
     89        """ Check if parent is Division of Portal. """ 
     90        if self.aq_parent.aq_inner.aq_parent.portal_type == 'School': 
     91            return self.aq_parent.aq_inner.aq_parent         
     92        else: 
     93            return self.context.portal_url.getPortalObject() 
     94 
    7295    def isSelected(self, item): 
    73         """ Check if the navigaion item is the one being displayed. """ 
     96        """ Check if the navigation item is the one being displayed. """ 
    7497        if '/'.join(item.getPath().split('/')[1:]) == self.context.virtual_url_path(): 
    7598            return 'portletItem portletItemSelected' 
     
    82105        if self.isCourseObject(): 
    83106            return ts.translate(ecprops.course_descriptor) 
     107        elif self.isDivisionObject(): 
     108            return ecprops.division_descriptor             
    84109        else: 
    85             return ecprops.division_descriptor 
     110            brains = self.context.portal_catalog.searchResults(Type='School', 
     111                                                               sort_on='sortable_title')                                                                    
     112            if len(brains) == 0: 
     113                return ecprops.division_descriptor             
     114            return ecprops.school_descriptor 
    86115             
    87116    def get_view_url(self, item):