Changeset 799

Show
Ignore:
Timestamp:
10/19/11 13:19:56 (7 months ago)
Author:
brent
Message:

Fixed order changing on object edit.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 4.0/enpraxis.educommons/trunk/enpraxis/educommons/eventHandlers.py

    r798 r799  
    5353    if object.Type() != 'Course': 
    5454        if ICourseOrderable.providedBy(object) and not object.isTemporary(): 
    55             if not object.getExcludeFromNav(): 
     55            if object.getExcludeFromNav(): 
     56                order = ICourseOrder(object) 
     57                if order.position: 
     58                    order.position = 0 
     59                    object.reindexObject() 
     60            else: 
    5661                # assign new position 
    5762                order = ICourseOrder(object) 
    58                 ecutil = getUtility(IECUtility) 
    59                 parent = ecutil.FindECParent(object) 
    60                 if parent: 
    61                     path = {'path':{'query':'/'.join(parent.getPhysicalPath())+'/',}, 
    62                             'getExcludeFromNav':False,} 
    63                     brains = object.portal_catalog.searchResults(path, sort_on='getObjPositionInCourse') 
    64                     lastobj = brains[-1].getObject() 
    65                     if lastobj.getId() == parent.id + '.zip': 
    66                         # If the last object is the course zip file, trade places 
    67                         lo = ICourseOrder(lastobj) 
    68                         order.position = lo.position 
    69                         lo.position = lo.position + 1 
    70                         lastobj.reindexObject() 
    71                     else: 
    72                         order.position = ICourseOrder(lastobj).position + 1 
     63                if not order.position: 
     64                    # If it is not already assigned 
     65                    ecutil = getUtility(IECUtility) 
     66                    parent = ecutil.FindECParent(object) 
     67                    if parent: 
     68                        path = {'path':{'query':'/'.join(parent.getPhysicalPath())+'/',}, 
     69                                'getExcludeFromNav':False,} 
     70                        brains = object.portal_catalog.searchResults(path, sort_on='getObjPositionInCourse') 
     71                        lastobj = brains[-1].getObject() 
     72                        if lastobj.getId() == parent.id + '.zip': 
     73                            # If the last object is the course zip file, trade places 
     74                            lo = ICourseOrder(lastobj) 
     75                            order.position = lo.position 
     76                            lo.position = lo.position + 1 
     77                            lastobj.reindexObject() 
     78                        else: 
     79                            order.position = ICourseOrder(lastobj).position + 1 
    7380                    object.reindexObject() 
    7481