| 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 |