diff --git a/browser/concept.py b/browser/concept.py index 1091ec1..8d33228 100644 --- a/browser/concept.py +++ b/browser/concept.py @@ -395,10 +395,22 @@ class ConceptView(BaseView): fv = FilterView(self.context, self.request) rels = self.context.getResourceRelations() for r in rels: - #yield self.childViewFactory(r, self.request, contextIsSecond=True) if fv.check(r.first): yield ResourceRelationView(r, self.request, contextIsSecond=True) + @Lazy + def resourcesByType(self): + result = dict(texts=[], images=[], files=[]) + for rv in self.resources(): + r = rv.context + if r.contentType.startswith('text/'): + result['texts'].append(r) + if r.contentType.startswith('image/'): + result['images'].append(r) + else: + result['files'].append(r) + return result + def unique(self, rels): result = Jeep() for r in rels: diff --git a/browser/configure.zcml b/browser/configure.zcml index 9541ac7..315ef71 100644 --- a/browser/configure.zcml +++ b/browser/configure.zcml @@ -547,6 +547,12 @@ class="loops.browser.node.ObjectInfo" permission="zope.View" /> + + Creators: + tal:content="info/label">Meta: + + + + + + + + + + + + + + + + Information + + + Meta: @@ -48,5 +70,4 @@ - diff --git a/browser/lobo/standard.pt b/browser/lobo/standard.pt index f8a6afa..296312b 100644 --- a/browser/lobo/standard.pt +++ b/browser/lobo/standard.pt @@ -12,9 +12,9 @@ + - @@ -29,10 +29,8 @@ - - - + + @@ -51,6 +49,14 @@ + + + + @@ -74,7 +80,16 @@ style cell/style"> - + + + + + + @@ -87,15 +102,20 @@ - + + + + diff --git a/browser/lobo/standard.py b/browser/lobo/standard.py index 91cc2f4..b6e02ef 100644 --- a/browser/lobo/standard.py +++ b/browser/lobo/standard.py @@ -120,8 +120,12 @@ class ConceptView(BaseConceptView): # fetch from iterator on layout object: avoid duplicates url = self.nodeView.getUrlForTarget(r) src = ('%s/mediaasset.html?v=%s' % (url, self.parentView.imageSize)) - return dict(src=src, url=url, - cssClass=self.parentView.imageCssClass) + fullSrc = ('%s/mediaasset.html?v=%s' % (url, self.parentView.fullImageSize)) + adImg = adapted(r) + showInfo = adImg.showInfo and adImg.metaInfo + return dict(src=src, fullImageUrl=fullSrc, title=r.title, + url=url, cssClass=self.parentView.imageCssClass, + showInfo=showInfo) class Layout(Base, ConceptView): @@ -149,6 +153,7 @@ class Layout(Base, ConceptView): class BasePart(Base): imageSize = 'small' + fullImageSize = 'medium' imageCssClass = '' height = 260 gridPattern = [] @@ -240,10 +245,15 @@ class ConceptRelationView(BaseConceptRelationView, ConceptView): def img(self): self.registerDojoLightbox() # also provides access to info popup for r in self.images: + # fetch from iterator on layout object: avoid duplicates url = self.nodeView.getUrlForTarget(r) src = ('%s/mediaasset.html?v=%s' % (url, self.parentView.imageSize)) - return dict(src=src, url=url, - cssClass=self.parentView.imageCssClass) + fullSrc = ('%s/mediaasset.html?v=%s' % (url, self.parentView.fullImageSize)) + adImg = adapted(r) + showInfo = adImg.showInfo and adImg.metaInfo + return dict(src=src, fullImageUrl=fullSrc, title=r.title, + url=url, cssClass=self.parentView.imageCssClass, + showInfo=showInfo) class ResourceView(BaseResourceView): @@ -272,6 +282,10 @@ class ResourceView(BaseResourceView): self.registerDojoLightbox() # also provides access to info popup url = self.nodeView.getUrlForTarget(self.context) src = ('%s/mediaasset.html?v=%s' % (url, self.parentView.imageSize)) - return dict(src=src, url=url, - cssClass=self.parentView.imageCssClass) + fullSrc = ('%s/mediaasset.html?v=%s' % (url, self.parentView.fullImageSize)) + adImg = adapted(self.context) + showInfo = adImg.showInfo and adImg.metaInfo + return dict(src=src, fullImageUrl=fullSrc, title=self.context.title, + url=url, cssClass=self.parentView.imageCssClass, + showInfo=showInfo) diff --git a/browser/node.py b/browser/node.py index 2f35326..fc5aeb3 100644 --- a/browser/node.py +++ b/browser/node.py @@ -608,6 +608,15 @@ class ObjectInfo(NodeView): return self.request.get('dialog', 'object_info') +class MetaInfo(ObjectInfo): + + __call__ = innerHtml + + @Lazy + def macro(self): + return self.macros['meta_info'] + + class InlineEdit(NodeView): """ Provides inline editor as inner HTML""" diff --git a/interfaces.py b/interfaces.py index ebd1fab..b4ec500 100644 --- a/interfaces.py +++ b/interfaces.py @@ -296,6 +296,7 @@ class IBaseResource(ILoopsObject): metaInfo = Attribute('Optional additional information about the resource ' 'provided as text.') + showInfo = Attribute('Show object information in the standard user interface.') def getType(): """ Return a concept that provides the object's type, i.e. the diff --git a/media/interfaces.py b/media/interfaces.py index 6254977..099e3fb 100644 --- a/media/interfaces.py +++ b/media/interfaces.py @@ -39,3 +39,9 @@ class IMediaAsset(IMediaAsset, IExternalFile): missing_value=u'', required=False) + showInfo = schema.Bool( + title=_(u'Show Object Information'), + description=_(u'Show object information in the standard user interface.'), + default=False, + required=False) + diff --git a/organize/member.py b/organize/member.py index 37c5045..859120c 100644 --- a/organize/member.py +++ b/organize/member.py @@ -71,7 +71,13 @@ class MemberRegistrationManager(object): options = IOptions(personType) pfName = options(self.principalfolder_key, (self.default_principalfolder,))[0] - # step 1: create an internal principal in the loops principal folder: + self.createPrincipal(pfName, userId, password, lastName, firstName) + groups = options(self.groups_key, ()) + self.setGroupsForPrincipal(pfName, userId, groups=groups) + self.createPersonForPrincipal(self, pfName, userId, lastName, firstName=firstName, useExisting=useExisting, **kw) + + def createPrincipal(self, pfName, userId, password, lastName, + firstName=u'', groups=[], useExisting=False, **kw): pFolder = getPrincipalFolder(self.context, pfName) if IPersonBasedAuthenticator.providedBy(pFolder): pFolder.setPassword(userId, password) @@ -86,8 +92,9 @@ class MemberRegistrationManager(object): return dict(fieldName='loginName', error='duplicate_loginname') else: pFolder[userId] = principal - # step 2 (optional): assign to group(s) - groups = options(self.groups_key, ()) + + def setGroupsForPrincipal(self, pfName, userId, groups=[]): + pFolder = getPrincipalFolder(self.context, pfName) for groupInfo in groups: names = groupInfo.split(':') if len(names) == 1: @@ -101,7 +108,12 @@ class MemberRegistrationManager(object): members = list(group.principals) members.append(pFolder.prefix + userId) group.principals = members - # step 3: create a corresponding person concept: + + def createPersonForPrincipal(self, pfName, userId, lastName, firstName=u'', useExisting=False, **kw): + concepts = self.context.getConceptManager() + personType = adapted(concepts[self.person_typeName]) + pFolder = getPrincipalFolder(self.context, pfName) + title = firstName and ' '.join((firstName, lastName)) or lastName name = baseId = 'person.' + userId if useExisting and name in concepts: person = concepts[name]