From 26472a280e89e1c92ac8dbe1f4dbd5dcc91b88bb Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Fri, 7 Oct 2011 20:41:15 +0200 Subject: [PATCH 1/4] show lightbox for links on images that do not lead to a child concept; provide info icon for resources that have the 'showInfo' flag set --- browser/lobo/standard.pt | 42 +++++++++++++++++++++++++++++----------- browser/lobo/standard.py | 26 +++++++++++++++++++------ interfaces.py | 1 + media/interfaces.py | 6 ++++++ 4 files changed, 58 insertions(+), 17 deletions(-) diff --git a/browser/lobo/standard.pt b/browser/lobo/standard.pt index f8a6afa..38322d9 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/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) + From c2410a830ebddb161490a0f99e47f3345bec504b Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Fri, 7 Oct 2011 20:56:57 +0200 Subject: [PATCH 2/4] show lightbox for links on images that do not lead to a child concept; provide info icon for resources that have the 'showInfo' flag set --- browser/configure.zcml | 6 ++++++ browser/info.pt | 25 +++++++++++++++++++++++-- browser/lobo/standard.pt | 4 ++-- browser/node.py | 9 +++++++++ 4 files changed, 40 insertions(+), 4 deletions(-) diff --git a/browser/configure.zcml b/browser/configure.zcml index c358791..58adf33 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: + + + +
+ + + + + + + + + + + + + + @@ -48,5 +70,4 @@
+

Information

Meta:
-
diff --git a/browser/lobo/standard.pt b/browser/lobo/standard.pt index 38322d9..296312b 100644 --- a/browser/lobo/standard.pt +++ b/browser/lobo/standard.pt @@ -50,7 +50,7 @@ tal:attributes="class python:part.cssClass[0]"> - @@ -82,7 +82,7 @@
- diff --git a/browser/node.py b/browser/node.py index bf2ea68..2ac755c 100644 --- a/browser/node.py +++ b/browser/node.py @@ -607,6 +607,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""" From 39d75e67cebc4c70e857453ee9f3e74db374fcaa Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sun, 9 Oct 2011 09:57:30 +0200 Subject: [PATCH 3/4] new helper property resourcesByType, e.g. for showing images with a concept --- browser/concept.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/browser/concept.py b/browser/concept.py index 8c693cb..546a22e 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: From 40a5134648edbb2c0c2b22a2c50ff7c73b013a89 Mon Sep 17 00:00:00 2001 From: hplattner Date: Thu, 20 Oct 2011 17:56:27 +0200 Subject: [PATCH 4/4] fix: split MemberRegistration to enable only Pricipal creationi --- organize/member.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) 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]