Changeset 42
- Timestamp:
- 27/01/06 09:14:41
- Files:
-
- trunk/OATSPSC/Extensions/Install.py (modified) (5 diffs)
- trunk/OATSPSC/Extensions/PackageWorkflow.py (modified) (1 diff)
- trunk/OATSPSC/Extensions/ReleaseWorkflow.py (modified) (3 diffs)
- trunk/OATSPSC/Extensions/WorkflowScripts.py (modified) (1 diff)
- trunk/OATSPSC/config.py (modified) (2 diffs)
- trunk/OATSPSC/content/PSCDocumentationFolder.py (modified) (4 diffs)
- trunk/OATSPSC/content/PSCFile.py (modified) (5 diffs)
- trunk/OATSPSC/content/PSCFileLink.py (modified) (2 diffs)
- trunk/OATSPSC/content/PSCImprovementProposal.py (modified) (4 diffs)
- trunk/OATSPSC/content/PSCImprovementProposalFolder.py (modified) (4 diffs)
- trunk/OATSPSC/content/PSCProject.py (modified) (7 diffs)
- trunk/OATSPSC/content/PSCRelease.py (modified) (4 diffs)
- trunk/OATSPSC/content/PSCReleaseFolder.py (modified) (5 diffs)
- trunk/OATSPSC/content/PloneSoftwareCenter.py (modified) (7 diffs)
- trunk/OATSPSC/content/schemata.py (modified) (4 diffs)
- trunk/OATSPSC/skins/plonesoftwarecenter/by-category.pt (modified) (1 diff)
- trunk/OATSPSC/skins/plonesoftwarecenter/portlet_releases.pt (modified) (2 diffs)
- trunk/OATSPSC/skins/plonesoftwarecenter/psc_file_view.pt (modified) (2 diffs)
- trunk/OATSPSC/skins/plonesoftwarecenter/psc_improvements_view.pt (modified) (2 diffs)
- trunk/OATSPSC/skins/plonesoftwarecenter/psc_project_view.pt (modified) (7 diffs)
- trunk/OATSPSC/skins/plonesoftwarecenter/psc_release_view.pt (modified) (4 diffs)
- trunk/OATSPSC/skins/plonesoftwarecenter/psc_releasefolder_view.pt (modified) (1 diff)
- trunk/OATSPSC/skins/plonesoftwarecenter/psc_roadmap.pt (modified) (2 diffs)
- trunk/OATSPSC/version.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/OATSPSC/Extensions/Install.py
r1 r42 13 13 from Products.PloneSoftwareCenter.Extensions import PackageWorkflow 14 14 from Products.PloneSoftwareCenter.Extensions import ReleaseWorkflow 15 16 # Types to be enabled in use_folder_tabs17 folderish = ('PSCProject', 'PSCRelease', 'PloneSoftwareCenter')18 15 19 16 def setWorkflowForType(self, out, tool, type, workflowName): … … 46 43 def addCatalogIndex(self, out, catalog, index, type, extra=None): 47 44 """Add the given index name, of the given type, to the catalog.""" 48 # QueueCatalog work-around49 if catalog.meta_type == 'ZCatalog Queue':50 catalog = self.unrestrictedTraverse(catalog._location)51 45 if index not in catalog.indexes(): 52 46 catalog.addIndex(index, type, extra) … … 159 153 factory = getToolByName(self, 'portal_factory') 160 154 161 addPortalFactoryType(self, out, factory, 'PSCProject') 162 addPortalFactoryType(self, out, factory, 'PSCRelease') 163 164 # Turned off, because you will get conflicts when two people create a PLIP 165 # at the same time. 166 # addPortalFactoryType(self, out, factory, 'PSCImprovementProposal') 167 addPortalFactoryType(self, out, factory, 'PSCFile') 168 addPortalFactoryType(self, out, factory, 'PSCFileLink') 155 for t in ('PSCProject', 'PSCReleaseFolder', 'PSCImprovementProposalFolder', 156 'PSCRelease', 'PSCImprovementProposal', 'PSCFile', 'PSCFileLink',): 157 addPortalFactoryType(self, out, factory, t) 169 158 170 159 def satisfyDependencies(self, out): … … 188 177 install(dep, hard=False) 189 178 190 def setupFolderTabs(self, out, reinstall):191 pp = getToolByName(self, 'portal_properties')192 sp = pp.site_properties193 use_tabs = tuple(sp.use_folder_tabs)194 sp._updateProperty('use_folder_tabs', use_tabs + folderish)195 print >> out, 'Registered %s as folderish objects.' % ','.join(folderish)196 197 179 def setupCatalog(self, out, reinstall): 198 180 catalog = getToolByName(self, 'portal_catalog') 199 181 addCatalogMetadata(self, out, catalog, 'getCategoryTitles') 200 182 addCatalogMetadata(self, out, catalog, 'UID') 201 addCatalogIndex(self, out, catalog, 'sort_title', 'FieldIndex') 202 203 183 184 def setupNavtree(self, out, reinstall): 185 portal_properties = getToolByName(self, 'portal_properties') 186 navtree_properties = getattr(portal_properties, 'navtree_properties') 187 parentMetaTypesNotToQuery = list(navtree_properties.getProperty('parentMetaTypesNotToQuery')) 188 for t in ('PloneSoftwareCenter', 'PSCReleaseFolder', 'PSCImprovementProposalFolder', 'PSCRelease'): 189 if t not in parentMetaTypesNotToQuery: 190 parentMetaTypesNotToQuery.append(t) 191 navtree_properties._updateProperty('parentMetaTypesNotToQuery', parentMetaTypesNotToQuery) 192 204 193 def cleanCatalog(self, out, reinstall): 205 194 catalog = getToolByName(self, 'portal_catalog') 206 207 195 if not reinstall: 208 196 removeCatalogMetadata(self, out, catalog, 'getCategoryTitles') 209 # Don't clean sort_title -> also used by PHC 197 198 def addFolderContentsViewTypes(self, out, reinstall): 199 portal_properties = getToolByName(self, 'portal_properties') 200 site_properties = getattr(portal_properties, 'site_properties', None) 201 if site_properties is not None: 202 useView = list(site_properties.typesUseViewActionInListings) 203 if 'PSCFile' not in useView: 204 useView.append('PSCFile') 205 site_properties._updateProperty('typesUseViewActionInListings', useView) 210 206 211 207 def install(self, reinstall=False): … … 216 212 install_subskin(self, out, config.GLOBALS) 217 213 installTypes(self, out, listTypes(config.PROJECTNAME), config.PROJECTNAME) 218 214 219 215 installFactoryTypes(self, out, reinstall) 220 216 installWorkflows(self, out, reinstall) 221 setupFolderTabs(self, out, reinstall)222 217 setupCatalog(self, out, reinstall) 223 218 addFolderContentsViewTypes(self, out, reinstall) 219 setupNavtree(self, out, reinstall) 224 220 225 221 print >> out, 'Successfully installed %s.' % config.PROJECTNAME trunk/OATSPSC/Extensions/PackageWorkflow.py
r1 r42 46 46 ## States initialization 47 47 sdef = wf.states['unapproved'] 48 sdef.setProperties(title="""Unapproved package , awaiting release""",48 sdef.setProperties(title="""Unapproved package""", 49 49 transitions=('publish', 'submit')) 50 50 sdef.setPermission(ACCESS, 0, ['Manager', 'Owner']) trunk/OATSPSC/Extensions/ReleaseWorkflow.py
r1 r42 47 47 ## States initialization 48 48 sdef = wf.states['planning'] 49 sdef.setProperties(title=""" The release is in the planning stages""",49 sdef.setProperties(title="""Planning stages""", 50 50 transitions=('begin', 'release')) 51 51 sdef.setPermission(ACCESS, 1, []) … … 54 54 55 55 sdef = wf.states['in-progress'] 56 sdef.setProperties(title="""Work on the release isin progress""",56 sdef.setProperties(title="""Work in progress""", 57 57 transitions=('re-plan', 'release')) 58 58 sdef.setPermission(ACCESS, 1, []) … … 61 61 62 62 sdef = wf.states['published'] 63 sdef.setProperties(title=""" The release has beencompleted""",63 sdef.setProperties(title="""Release completed""", 64 64 transitions=('re-plan', 'retract')) 65 65 sdef.setPermission(ACCESS, 1, []) trunk/OATSPSC/Extensions/WorkflowScripts.py
r1 r42 21 21 roles.remove('Manager') 22 22 if not roles: 23 context.manage_delLocalRoles([owner])23 obj.manage_delLocalRoles([owner]) 24 24 else: 25 context.manage_setLocalRoles(owner, roles)25 obj.manage_setLocalRoles(owner, roles) 26 26 27 27 # Make sure we get ownership back 28 28 putils = getToolByName(self, 'plone_utils') 29 putils.changeOwnershipOf(obj, owner) 29 try: 30 putils.changeOwnershipOf(obj, owner) 31 except KeyError, e: 32 log = getToolByName(self, 'plone_log') 33 log('PSC unable to re-set owner of ' + obj.absolute_url() + ': ' + str(e)) trunk/OATSPSC/config.py
r39 r42 1 1 """ 2 $Id: config.py 6933 2005-03-25 09:23:08Z optilude$2 $Id: config.py 14811 2005-12-11 00:48:12Z optilude MERGE: SJ_ACT: 2006_01_23 $ 3 3 """ 4 4 from zLOG import LOG, PROBLEM … … 23 23 IMPROVEMENTS_ID = 'roadmap' 24 24 DOCUMENTATION_ID = 'documentation' 25 TRACKER_ID = 'problems' 26 FAQ_ID = 'FAQ' 27 POLL_ID = 'Vote' 25 28 26 29 GLOBALS = globals() trunk/OATSPSC/content/PSCDocumentationFolder.py
r1 r42 1 1 """ 2 $Id: PSCDocumentationFolder.py 6934 2005-03-25 09:24:56Z optilude $2 $Id: PSCDocumentationFolder.py 15313 2005-12-27 18:41:04Z optilude $ 3 3 """ 4 4 … … 9 9 from Products.Archetypes.public import registerType 10 10 from Products.Archetypes.public import OrderedBaseFolder 11 from Products.Archetypes import transaction 11 12 12 from Products.PloneSoftwareCenter.config import PROJECTNAME 13 from Products.PloneSoftwareCenter.config import PROJECTNAME, DOCUMENTATION_ID 13 14 from Products.PloneSoftwareCenter.content.schemata import PSCDocumentationFolderSchema 14 15 … … 23 24 content_icon = 'documentation_icon.gif' 24 25 schema = PSCDocumentationFolderSchema 26 _at_rename_after_creation = True 25 27 26 28 security = ClassSecurityInfo() … … 65 67 'Please do not rename it.') 66 68 67 security.declareProtected(CMFCorePermissions.AddPortalContent, 'generateUniqueId') 69 def _renameAfterCreation(self, check_auto_id=False): 70 parent = self.aq_inner.aq_parent 71 if DOCUMENTATION_ID not in parent.objectIds(): 72 # Can't rename without a subtransaction commit when using 73 # portal_factory! 74 transaction.savepoint(optimistic=True) 75 self.setId(DOCUMENTATION_ID) 76 77 78 security.declareProtected(CMFCorePermissions.View, 'generateUniqueId') 68 79 def generateUniqueId(self, type_name): 69 80 """Override for the .py script in portal_scripts with the same name. trunk/OATSPSC/content/PSCFile.py
r1 r42 1 1 """ 2 $Id: PSCFile.py 6915 2005-03-20 01:08:38Z optilude$2 $Id: PSCFile.py 9197 2005-06-24 22:19:37Z alecm MERGE: SJ_ACT, 2006_01_23 $ 3 3 """ 4 4 … … 15 15 from Products.PloneSoftwareCenter.config import PROJECTNAME 16 16 from Products.PloneSoftwareCenter.content.schemata import PSCFileSchema 17 from Products.ATContentTypes.content.base import ATCTFileContent 17 18 18 19 def modify_fti(fti): … … 20 21 21 22 22 class PSCFile( BaseContent):23 class PSCFile(ATCTFileContent): 23 24 """Contains the downloadable file for the Release.""" 24 25 … … 40 41 }, 41 42 ) 42 43 security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'setId')44 def setId(self, value):45 """Set the id - override to fix portal_factory bug46 """47 get_transaction().commit(1)48 BaseContent.setId(self, value)49 43 50 44 security.declareProtected(CMFCorePermissions.View, 'getPlatformVocab') … … 81 75 return self.absolute_url() 82 76 83 security.declareProtected(CMFCorePermissions.View, 'index_html') 84 def index_html(self): 85 """Allows file direct access download.""" 86 field = self.getField('downloadableFile') 87 field.download(self) 88 89 registerType(PSCFile, PROJECTNAME) 77 security.declareProtected(CMFCorePermissions.ModifyPortalContent, 'setFile') 78 def setDownloadableFile(self, value, **kwargs): 79 """Set id to uploaded id 80 """ 81 self._setATCTFileContent(value, **kwargs) trunk/OATSPSC/content/PSCFileLink.py
r1 r42 1 1 """ 2 $Id: PSCFileLink.py 6852 2005-03-09 18:04:43Z dtremea$2 $Id: PSCFileLink.py 9188 2005-06-24 10:36:30Z tiran MERGE: SJ_ACT: 2006_01_23$ 3 3 """ 4 4 … … 29 29 content_icon = 'link_icon.gif' 30 30 schema = PSCFileLinkSchema 31 _at_rename_after_creation = True 31 32 32 33 security = ClassSecurityInfo() trunk/OATSPSC/content/PSCImprovementProposal.py
r1 r42 1 1 """ 2 $Id: PSCImprovementProposal.py 7945 2005-04-13 20:36:42Z optilude$2 $Id: PSCImprovementProposal.py 15313 2005-12-27 18:41:04Z optilude MERGE:SJ_ACT: 2006_01_23 $ 3 3 """ 4 4 … … 10 10 from Products.Archetypes.public import registerType 11 11 from Products.Archetypes.public import OrderedBaseFolder 12 from Products.Archetypes import transaction 12 13 13 14 from Products.PloneSoftwareCenter.config import PROJECTNAME … … 32 33 schema = PSCImprovementProposalSchema 33 34 allow_discussion = 1 35 _at_rename_after_creation = True 34 36 35 37 security = ClassSecurityInfo() … … 91 93 return self.getField('title').get(self) 92 94 93 security.declareProtected(CMFCorePermissions.AddPortalContent, 'generateUniqueId') 94 def generateUniqueId(self, type_name): 95 """We don't want the behavior of proposal folder, choosing on 96 versions. So use the standard Plone behavior. 97 """ 98 now = DateTime() 99 time = '%s.%s' % (now.strftime('%Y-%m-%d'), str(now.millis())[7:]) 100 rand = str(random())[2:6] 101 prefix = '' 102 suffix = '' 103 if type_name is not None: 104 prefix = type_name.replace(' ', '_') + '.' 105 prefix = prefix.lower() 106 return prefix + time + rand + suffix 95 def _renameAfterCreation(self, check_auto_id=False): 96 """Get sequentially numbered ids""" 97 parent = self.aq_inner.aq_parent 98 maxId = 0 99 for id in parent.objectIds(): 100 try: 101 intId = int(id) 102 maxId = max(maxId, intId) 103 except (TypeError, ValueError): 104 pass 105 newId = str(maxId + 1) 106 # Can't rename without a subtransaction commit when using 107 # portal_factory! 108 transaction.savepoint(optimistic=True) 109 self.setId(newId) 107 110 108 111 trunk/OATSPSC/content/PSCImprovementProposalFolder.py
r1 r42 1 1 """ 2 $Id: PSCImprovementProposalFolder.py 7945 2005-04-13 20:36:42Z optilude$2 $Id: PSCImprovementProposalFolder.py 15313 2005-12-27 18:41:04Z optilude MERGE: SJ_ACT: 2006_01_23 $ 3 3 """ 4 4 … … 9 9 from Products.Archetypes.public import registerType 10 10 from Products.Archetypes.public import BaseBTreeFolder 11 from Products.Archetypes import transaction 11 12 12 from Products.PloneSoftwareCenter.config import PROJECTNAME 13 from Products.PloneSoftwareCenter.config import PROJECTNAME, IMPROVEMENTS_ID 13 14 from Products.PloneSoftwareCenter.content.schemata import PSCImprovementProposalFolderSchema 14 15 … … 28 29 filter_content_types = 1 29 30 allowed_content_types = ('PSCImprovementProposal',) 31 _at_rename_after_creation = True 30 32 31 33 security = ClassSecurityInfo() … … 59 61 ) 60 62 61 security.declareProtected(CMFCorePermissions.AddPortalContent, 62 'generateUniqueId') 63 def generateUniqueId(self, type_name): 64 """Generate a unique id, by finding the smallest unused number 65 among the object in the container. 66 67 This is used when creating objects with createObject.py, to ensure 68 that items in this container gets sequentially numbered ids. 69 """ 70 ids = self.objectIds() 71 max = 1 72 for id in ids: 73 try: 74 val = int(id) 75 if val >= max: 76 max = val + 1 77 except ValueError: 78 continue 79 return str(max) 63 def _renameAfterCreation(self, check_auto_id=False): 64 parent = self.aq_inner.aq_parent 65 if IMPROVEMENTS_ID not in parent.objectIds(): 66 # Can't rename without a subtransaction commit when using 67 # portal_factory! 68 transaction.savepoint(optimistic=True) 69 self.setId(IMPROVEMENTS_ID) 80 70 81 71 security.declareProtected(CMFCorePermissions.View, 'getStateTitle') trunk/OATSPSC/content/PSCProject.py
r39 r42 1 1 """ 2 $Id: PSCProject.py 8226 2005-04-26 18:37:25Z optilude$2 $Id: PSCProject.py 15313 2005-12-27 18:41:04Z optilude MERGE: SJ_ACT: 2006_01_23 $ 3 3 """ 4 4 … … 21 21 folder_modify_fti(fti, allowed=('PSCReleaseFolder', 22 22 'PSCImprovementProposalFolder', 23 'PSCDocumentationFolder', 24 'ForumNB', 23 #'PSCDocumentationFolder', 25 24 'PlonePopoll', 26 'FAQ', 25 'FAQTheme', 26 'PoiPscTracker', 27 27 #'Collector', 28 28 ), … … 35 35 36 36 __implements__ = (OrderedBaseFolder.__implements__,) 37 37 38 38 archetype_name = 'OATS' 39 39 immediate_view = default_view = 'psc_project_view' 40 40 content_icon = 'product_icon.gif' 41 41 schema = PSCProjectSchema 42 allow_discussion = 1 43 _at_rename_after_creation = True 42 44 43 45 security = ClassSecurityInfo() … … 79 81 #SETUP the default content of the Project Folder 80 82 81 self.invokeFactory(id='Poll', type_name='PlonePopoll', title=self.title_or_id()+' Poll') 83 #self.invokeFactory(id='Poll', type_name='PlonePopoll', title=self.title_or_id()+' Poll') 84 self.invokeFactory(id='Poll', type_name='PlonePopoll', title=config.POLL_ID) 82 85 poll = getattr(self, 'Poll') 83 poll.setPollOptions(question='How would you rate '+self.title_or_id()+' ?', choices=['1', '2', '3', '4', '5'], choices_number=1, check_multi=1) 86 poll.allow_discussion = 0 87 #poll.setPollOptions(question='How would you rate '+self.title_or_id()+' ?', choices=['1', '2', '3', '4', '5'], choices_number=1, check_multi=1) 88 poll.setPollOptions(question='How would you rate this project?', choices=['1', '2', '3', '4', '5'], choices_number=1, check_multi=1) 84 89 poll.enable() 85 90 poll.setVisible() 86 91 87 self.invokeFactory(id='Forum', type_name='ForumNB', title=self.title_or_id()+' Forum') 88 forum = getattr(self, 'Forum') 89 forum.setTitle(self.title_or_id()+' Forum') 90 forum.setDescription('Discuss issues related to '+self.title_or_id()+'.') 92 #self.invokeFactory(id='FAQ', type_name='FAQTheme', title=self.title_or_id()+' FAQ', description='Frequently asked questions on '+self.title_or_id()+'.') 93 self.invokeFactory(id='FAQ', type_name='FAQTheme', title=config.FAQ_ID, description='Frequently asked questions.') 91 94 92 # if not self.objectIds('PSCImprovementProposalFolder'): 93 # self.invokeFactory('PSCImprovementProposalFolder', 94 # config.IMPROVEMENTS_ID) 95 #self.invokeFactory(id='PoiPscTracker', type_name='PoiPscTracker', title=self.title_or_id()+' Bug Tracker', description=self.title_or_id()+' Bug Tracker') 96 #self.invokeFactory(id='PoiPscTracker', type_name='PoiPscTracker', title=config.TRACKER_ID, description='Bug Tracker') 97 98 #if not self.objectIds('PSCImprovementProposalFolder'): 99 #self.invokeFactory('PSCImprovementProposalFolder', 100 #config.IMPROVEMENTS_ID) 95 101 96 97 security.declareProtected(CMFCorePermissions.View, 'sort_title')98 def sort_title(self):99 """Get the sort-order title. Used in a catalog index to sort the100 title of the item with human ordering.101 """102 return self.title_or_id().strip().lower()103 102 104 103 security.declareProtected(CMFCorePermissions.ModifyPortalContent, … … 251 250 if o.portal_type not in ignore] 252 251 253 254 security.declareProtected(CMFCorePermissions.View, 'getAdditionalUserContainedResources')255 def getAdditionalUserContainedResources(self, ignore=('PSCReleaseFolder',256 'PSCImprovementProposalFolder','PSCRelease', 'PSCImprovementProposal',)):257 """258 Get any contained resources (objects) not of the types in the list of259 ignored types passed in. This essentially allows access to contained260 help-center items, collectors etc.261 """262 return [o for o in self.folderlistingFolderContents() \263 if o.portal_type not in ignore]264 265 266 252 security.declareProtected(CMFCorePermissions.View, 'getNotAddableTypes') 267 253 def getNotAddableTypes(self): … … 269 255 """ 270 256 ignored = [] 271 if config.RELEASES_ID in self.objectIds(): 257 objectIds = self.objectIds() 258 if config.RELEASES_ID in objectIds: 272 259 ignored.append('PSCReleaseFolder') 273 if config.IMPROVEMENTS_ID in self.objectIds():260 if config.IMPROVEMENTS_ID in objectIds: 274 261 ignored.append('PSCImprovementProposalFolder') 275 262 if not self.haveHelpCenter() or \ 276 config.DOCUMENTATION_ID in self.objectIds():263 config.DOCUMENTATION_ID in objectIds: 277 264 ignored.append('PSCDocumentationFolder') 265 if config.TRACKER_ID in objectIds: 266 ignored.append('PoiPscTracker') 278 267 return ignored 279 280 security.declareProtected(CMFCorePermissions.AddPortalContent, 'generateUniqueId')281 def generateUniqueId(self, type_name):282 """Override for the .py script in portal_scripts with the same name.283 Gives some default names for contained content types:284 285 PSCImprovementProposalFolder: 'improvement'286 PSCReleaseFolder: 'release'287 HelpCenterFAQFolder: 'faq'288 HelpCenterHowToFolder: 'how-to'289 HelpCenterTutorialFolder: 'tutorial'290 HelpCenterErrorReferenceFolder: 'error'291 HelpCenterLinkFolder: 'link'292 HelpCenterGlossary: 'glossary'293 HelpCenterInstructionalVideoFolder: 'video'294 #Collector: 'collector'295 296 for all other types, falls back on the aq parent.297 """298 299 consideredTypes = {300 'PSCImprovementProposalFolder': config.IMPROVEMENTS_ID,301 'PSCReleaseFolder': config.RELEASES_ID,302 'PSCDocumentationFolder' : config.DOCUMENTATION_ID,303 #'Collector': 'collector'304 }305 306 # Use aq parent if we don't know what to do with the type307 if type_name not in consideredTypes:308 return self.aq_inner.aq_parent.generateUniqueId(type_name)309 else:310 return self._ensureUniqueId(consideredTypes[type_name])311 312 security.declarePrivate('_ensureUniqueId')313 def _ensureUniqueId(self, id):314 """Test the given id. If it's not unique, append .<n> where n is a315 number to make it unique.316 """317 if id in self.objectIds():318 idx = 0319 while '%s.%d' % (id, idx) in self.objectIds():320 idx += 1321 return '%s.%d' % (id, idx)322 else:323 return id324 268 325 269 security.declareProtected(CMFCorePermissions.View, 'getProjectURL') … … 343 287 return self.getVersionsVocab() 344 288 345 ##security.declareProtected(CMFCorePermissions.View, 'getCurrentVersions')346 ##def getCurrentVersions(self):347 ##"""To ensure PloneHelpCenter integration works, return the versions348 ##which are supported, by looking at the versions found in the releases349 ##and subtracting the ones listed in unsupportedVersions.350 ##"""351 ##allVersions = self.getVersionsVocab()352 ##unsupported = self.getUnsupportedVersions()353 ##return [v for v in allVersions if v not in unsupported]354 ##289 security.declareProtected(CMFCorePermissions.View, 'getCurrentVersions') 290 def getCurrentVersions(self): 291 """To ensure PloneHelpCenter integration works, return the versions 292 which are supported, by looking at the versions found in the releases 293 and subtracting the ones listed in unsupportedVersions. 294 """ 295 allVersions = self.getVersionsVocab() 296 unsupported = self.getUnsupportedVersions() 297 return [v for v in allVersions if v not in unsupported] 298 355 299 security.declareProtected(CMFCorePermissions.View, 'haveHelpCenter') 356 300 def haveHelpCenter(self): trunk/OATSPSC/content/PSCRelease.py
r24 r42 1 1 """ 2 $Id: PSCRelease.py 7945 2005-04-13 20:36:42Z optilude$2 $Id: PSCRelease.py 15313 2005-12-27 18:41:04Z optilude MERGE: SJ_ACT: 2006_01_23 $ 3 3 """ 4 4 … … 36 36 content_icon = 'download_icon.gif' 37 37 schema = PSCReleaseSchema 38 _at_rename_after_creation = False 38 39 39 40 security = ClassSecurityInfo() … … 66 67 self.getField('repository').set(self, value) 67 68 68 ##security.declareProtected(CMFCorePermissions.View, 'isOutdated')69 ##def isOutdated(self):70 ##"""Return true if this release is no longer supported."""71 ##currentVersions = self.getCurrentVersions()72 ##if currentVersions and self.getId() not in currentVersions:73 ##return True74 ##else:75 ##return False76 ##69 security.declareProtected(CMFCorePermissions.View, 'isOutdated') 70 def isOutdated(self): 71 """Return true if this release is no longer supported.""" 72 currentVersions = self.getCurrentVersions() 73 if currentVersions and self.getId() not in currentVersions: 74 return True 75 else: 76 return False 77 77 78 security.declareProtected(CMFCorePermissions.View, 'isPreferredMaturity') 78 79 def isPreferredMaturity(self): … … 159 160 items = [i for i in items if wftool.getInfoFor(i, 'review_state') == review_state] 160 161 items.sort(lambda x, y: cmp(int(x.getId()), int(y.getId()))) 161 return items 162 163 security.declareProtected(CMFCorePermissions.AddPortalContent, 'generateUniqueId') 164 def generateUniqueId(self, type_name): 165 """We don't want the behavior of release folder, choosing on 166 versions. So use the standard Plone behavior. 167 """ 168 now = DateTime() 169 time = '%s.%s' % (now.strftime('%Y-%m-%d'), str(now.millis())[7:]) 170 rand = str(random())[2:6] 171 prefix = '' 172 suffix = '' 173 if type_name is not None: 174 prefix = type_name.replace(' ', '_') + '.' 175 prefix = prefix.lower() 176 return prefix + time + rand + suffix 177 162 return items 178 163 179 164 registerType(PSCRelease, PROJECTNAME) trunk/OATSPSC/content/PSCReleaseFolder.py
r39 r42 1 1 """ 2 $Id: PSCReleaseFolder.py 6948 2005-03-27 23:58:10Z optilude$2 $Id: PSCReleaseFolder.py 15313 2005-12-27 18:41:04Z optilude MERGE: SJ_ACT: 2006_01_23 $ 3 3 """ 4 4 … … 9 9 from Products.Archetypes.public import registerType 10 10 from Products.Archetypes.public import OrderedBaseFolder 11 from Products.Archetypes import transaction 11 12 12 from Products.PloneSoftwareCenter.config import PROJECTNAME 13 from Products.PloneSoftwareCenter.config import PROJECTNAME, RELEASES_ID 13 14 from Products.PloneSoftwareCenter.content.schemata import PSCReleaseFolderSchema 14 15 … … 29 30 filter_content_types = 1 30 31 allowed_content_types = ('PSCRelease',) 32 _at_rename_after_creation = True 31 33 32 34 actions = ( … … 58 60 'Please do not rename it.') 59 61 60 security.declareProtected(CMFCorePermissions.AddPortalContent, 'generateUniqueId') 62 def _renameAfterCreation(self, check_auto_id=False): 63 parent = self.aq_inner.aq_parent 64 if RELEASES_ID not in parent.objectIds(): 65 # Can't rename without a subtransaction commit when using 66 # portal_factory! 67 transaction.savepoint(optimistic=True) 68 self.setId(RELEASES_ID) 69 70 security.declareProtected(CMFCorePermissions.View, 'generateUniqueId') 61 71 def generateUniqueId(self, type_name): 62 72 """Override for the .py script in portal_scripts with the same name. … … 64 74 Gives some default names for contained content types. 65 75 """ 76 77 if type_name != 'PSCRelease': 78 return self.aq_parent.generateUniqueId(type_name) 66 79 67 80 # Generate a fake version number, to signify that the user needs to trunk/OATSPSC/content/PloneSoftwareCenter.py
r33 r42 1 1 """ 2 $Id: PloneSoftwareCenter.py 6929 2005-03-24 22:07:44Z optilude$2 $Id: PloneSoftwareCenter.py 15311 2005-12-27 17:43:06Z optilude MERGE:SJ_ACT: 2006_01_23 $ 3 3 """ 4 4 … … 31 31 allowed_content_types = ('PSCProject',) 32 32 schema = PloneSoftwareCenterSchema 33 _at_rename_after_creation = True 33 34 34 35 security = ClassSecurityInfo() … … 75 76 security.declarePrivate('_getContained') 76 77 def _getContained(self, states, category, CatType, oats_status, portal_type, limit=None, 77 sort_on='effective', sort_order=' reverse'):78 sort_on='effective', sort_order='ascending'): 78 79 """Get contained objects of type portal_type 79 80 that are in states and have category.""" … … 118 119 else: 119 120 oats_status=None 120 return self._getContained(states, None, None, oats_status, 'PSCProject', limit) 121 return self._getContained(states, None, None, oats_status, 'PSCProject', limit, sort_on='sortable_title', sort_order='ascending') 122 123 security.declareProtected(CMFCorePermissions.View, 'getRecommended') 124 def getRecommended(self, Forge, states=[], limit=None): 125 """Get catalog brain of packages.""" 126 """ Need to implement Recommended as a Vocab.""" 127 if Forge=='Forge': 128 oats_status='OATSProject' 129 else: 130 oats_status=None 131 return self._getContained(states, None, None, oats_status, 'PSCProject', limit, sort_on='sortable_title', sort_order='ascending') 121 132 122 133 security.declareProtected(CMFCorePermissions.View, 'getPackagesByCategory') … … 128 139 else: 129 140 oats_status=None 130 return self._getContained(states, category, CatType, oats_status, 'PSCProject', limit, 131 sort_on='sort_title') 141 return self._getContained(states, category, CatType, oats_status, 'PSCProject', limit, sort_on='sortable_title', sort_order='ascending') 132 142 133 143 security.declareProtected(CMFCorePermissions.View, 'getReleases') 134 144 def getReleases(self, states=[], limit=None): 135 145 """Get catalog brain of releases.""" 136 return self._getContained(states, None, None, None, 'PSCRelease', limit )146 return self._getContained(states, None, None, None, 'PSCRelease', limit, sort_on='sortable_title', sort_order='ascending') 137 147 138 148 security.declareProtected(CMFCorePermissions.View, 'getReleasesByCategory') … … 143 153 else: 144 154 oats_status=None 145 return self._getContained(states, category, CatType, oats_status, 'PSC Release', limit)155 return self._getContained(states, category, CatType, oats_status, 'PSCelease', limit, sort_on='sortable_title', sort_order='ascending') 146 156 147 157 security.declareProtected(CMFCorePermissions.View, 'getCategoriesToList') … … 221 231 return self.getField('availableMaturities').getAsDisplayList(self) 222 232 223 ##security.declareProtected(CMFCorePermissions.View,224 ##'getAvailableVersionsAsDisplayList')225 ##def getAvailableVersionsAsDisplayList(self):226 ##return DisplayList([(item, item) for item in self.getAvailableVersions()])233 security.declareProtected(CMFCorePermissions.View, 234 'getAvailableVersionsAsDisplayList') 235 def getAvailableVersionsAsDisplayList(self): 236 return DisplayList([(item, item) for item in self.getAvailableVersions()]) 227 237 228 238 trunk/OATSPSC/content/schemata.py
r39 r42 1 1 """ 2 $Id: schemata.py 8128 2005-04-22 19:54:24Z limi$2 $Id: schemata.py 14904 2005-12-14 02:54:11Z dtremea MERGE: SJ_ACT: 2006_01_23 $ 3 3 """ 4 4 … … 37 37 prefix=EXTERNAL_STORAGE_PATH, 38 38 archive=False, 39 rename= True,39 rename=False, 40 40 ) 41 41 else: … … 582 582 validators=('isURL',), 583 583 widget=StringWidget( 584 visible = {'edit':'hidden', 'view':'invisible'}, 584 585 label="URL of version control repository", 585 586 label_msgid="label_package_repository", … … 847 848 TextField( 848 849 name='changelog', 850 required=0, 849 851 searchable=1, 850 852 default_content_type='text/plain', trunk/OATSPSC/skins/plonesoftwarecenter/by-category.pt
r32 r42 66 66 <tal:nopackages condition="not:nocall:packages"> 67 67 <div class="discreet" i18n:translate="no_packages_found"> 68 No p ackages found68 No projects found in this category. 69 69 </div> 70 70 </tal:nopackages> trunk/OATSPSC/skins/plonesoftwarecenter/portlet_releases.pt
r1 r42 15 15 sort_limit=5, 16 16 review_state='published')[:5]; 17 psc python:context.portal_catalog(17 psc python:context.portal_catalog( 18 18 portal_type='PloneSoftwareCenter', 19 19 sort_on='Date', … … 21 21 sort_limit=1)[:1]"> 22 22 23 <divclass="portlet" id="portlet-releases">23 <dl class="portlet" id="portlet-releases"> 24 24 25 <h5 i18n:translate="box_latest_releases">Latest releases</h5> 25 <dt class="portletHeader"> 26 <tal:syndicate condition="syntool/isSiteSyndicationAllowed"> 27 <a class="feedButton" href="" tal:attributes="href string:$here_url/search_rss?portal_type=PSCRelease&sort_on=Date&sort_order=reverse&review_state=published"> 28 <img i18n:attributes="title title_rss_feed; alt label_rss_feed;" 29 tal:attributes="src string:$portal_url/rss.gif" 30 src="rss.gif" 31 alt="RSS Feed" 32 title="RSS feed of the latest releases" /> 33 </a> 34 </tal:syndicate> 35 <a href="" 36 tal:omit-tag="not: nocall:psc" 37 tal:attributes="href python:psc[0].getURL()" 38 i18n:translate="box_latest_releases"> 39 Latest releases 40 </a> 41 </dt> 26 42 27 <div class="portletBody"> 43 <tal:releases tal:repeat="obj results"> 44 <dd tal:define="oddrow repeat/obj/odd" 45 tal:attributes="class python:test(oddrow, 'portletItem even', 'portletItem odd')"> 28 46 29 <tal:block tal:repeat="obj results"> 30 31 <div tal:define="oddrow repeat/obj/odd" 32 tal:attributes="class python:test(oddrow, 'portletContent even', 'portletContent odd')"> 33 34 <a href="" 35 tal:attributes="href obj/getURL; 36 title obj/Description"> 37 <tal:block replace="structure here/product_icon.gif"/> 38 <span tal:replace="python:test(obj.Title, obj.Title, obj.getId)"> 39 Product 40 </span> 41 </a> 42 43 <div class="discreet" 44 tal:define="categories obj/getCategoryTitles" 45 tal:condition="categories" 46 tal:content="python: ', '.join(categories)"> 47 Category 48 </div> 49 50 <div class="portletDetails" 51 tal:content="python:here.toPortalTime(obj.Date)"> 52 July 7, 08:11 53 </div> 54 </div> 55  
