link to image page from image grid; hide concepts from 'related' portlet if marked as hidden
This commit is contained in:
		
							parent
							
								
									59f2a66ef6
								
							
						
					
					
						commit
						6d0a589015
					
				
					 3 changed files with 31 additions and 6 deletions
				
			
		|  | @ -83,7 +83,7 @@ | ||||||
|                          style cell/style"> |                          style cell/style"> | ||||||
|         <metal:image use-macro="item/macros/image" /> |         <metal:image use-macro="item/macros/image" /> | ||||||
|         <div class="legend"> |         <div class="legend"> | ||||||
|           <b tal:content="cell/title" /> |           <a tal:attributes="href cell/targetUrl"><b tal:content="cell/title" /></a> | ||||||
|           <span tal:condition="cell/img/showInfo|nothing"> |           <span tal:condition="cell/img/showInfo|nothing"> | ||||||
|             <a tal:define="url string:${cell/img/url}/meta_info.html" |             <a tal:define="url string:${cell/img/url}/meta_info.html" | ||||||
|                tal:attributes="href url; |                tal:attributes="href url; | ||||||
|  |  | ||||||
|  | @ -38,6 +38,7 @@ from zope.traversing.api import getName, getParent | ||||||
| from zope.traversing.browser import absoluteURL | from zope.traversing.browser import absoluteURL | ||||||
| 
 | 
 | ||||||
| from cybertools.browser.action import actions | from cybertools.browser.action import actions | ||||||
|  | from cybertools.meta.interfaces import IOptions | ||||||
| from cybertools.typology.interfaces import IType | from cybertools.typology.interfaces import IType | ||||||
| from cybertools.xedit.browser import ExternalEditorView, fromUnicode | from cybertools.xedit.browser import ExternalEditorView, fromUnicode | ||||||
| from loops.browser.action import DialogAction, TargetAction | from loops.browser.action import DialogAction, TargetAction | ||||||
|  | @ -51,6 +52,7 @@ from loops.interfaces import IMediaAsset as legacy_IMediaAsset | ||||||
| from loops.interfaces import ITypeConcept | from loops.interfaces import ITypeConcept | ||||||
| from loops.media.interfaces import IMediaAsset | from loops.media.interfaces import IMediaAsset | ||||||
| from loops.organize.stateful.browser import statefulActions | from loops.organize.stateful.browser import statefulActions | ||||||
|  | from loops.organize.util import getRolesForPrincipal | ||||||
| from loops.versioning.browser import version_macros | from loops.versioning.browser import version_macros | ||||||
| from loops.versioning.interfaces import IVersionable | from loops.versioning.interfaces import IVersionable | ||||||
| from loops import util | from loops import util | ||||||
|  | @ -270,15 +272,38 @@ class ResourceView(BaseView): | ||||||
| 
 | 
 | ||||||
|     # relations |     # relations | ||||||
| 
 | 
 | ||||||
|     def concepts(self): |     def isHidden(self, pr): | ||||||
|         for r in self.context.getConceptRelations(): |         hideRoles = None | ||||||
|             yield ConceptRelationView(r, self.request) |         options = component.queryAdapter(adapted(pr.first), IOptions) | ||||||
|  |         if options is not None: | ||||||
|  |             hideRoles = options('hide_for', None) | ||||||
|  |         if not hideRoles: | ||||||
|  |             hideRoles = IOptions(adapted(pr.first.conceptType))('hide_for', None) | ||||||
|  |         if hideRoles is not None: | ||||||
|  |             principal = self.request.principal | ||||||
|  |             if (IUnauthenticatedPrincipal.providedBy(principal) and | ||||||
|  |                 'zope.Anonymous' in hideRoles): | ||||||
|  |                 return True | ||||||
|  |             roles = getRolesForPrincipal(principal.id, self.context) | ||||||
|  |             for r in roles: | ||||||
|  |                 if r in hideRoles: | ||||||
|  |                     return True | ||||||
|  |         return False | ||||||
|  | 
 | ||||||
|  |     #@Lazy | ||||||
|  |     def conceptsForPortlet(self): | ||||||
|  |         return [p for p in self.relatedConcepts() if not self.isHidden(p.relation)] | ||||||
| 
 | 
 | ||||||
|     def relatedConcepts(self): |     def relatedConcepts(self): | ||||||
|         for c in self.concepts(): |         for c in self.concepts(): | ||||||
|             if c.isProtected: continue |             if c.isProtected: | ||||||
|  |                 continue | ||||||
|             yield c |             yield c | ||||||
| 
 | 
 | ||||||
|  |     def concepts(self): | ||||||
|  |         for r in self.context.getConceptRelations(): | ||||||
|  |             yield ConceptRelationView(r, self.request) | ||||||
|  | 
 | ||||||
|     def clients(self): |     def clients(self): | ||||||
|         for node in self.context.getClients(): |         for node in self.context.getClients(): | ||||||
|             yield NodeView(node, self.request) |             yield NodeView(node, self.request) | ||||||
|  |  | ||||||
|  | @ -114,7 +114,7 @@ | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| <metal:actions define-macro="related"> | <metal:actions define-macro="related"> | ||||||
|           <div tal:repeat="concept macro/info/relatedConcepts"> |           <div tal:repeat="concept macro/info/conceptsForPortlet"> | ||||||
|             <a tal:attributes="href python: view.getUrlForTarget(concept); |             <a tal:attributes="href python: view.getUrlForTarget(concept); | ||||||
|                                title concept/relationInfo"> |                                title concept/relationInfo"> | ||||||
|               <span i18n:translate="" tal:content="concept/title">Concept</span> |               <span i18n:translate="" tal:content="concept/title">Concept</span> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue