From 99e09c73a82bbe30287577b9418902cf977257aa Mon Sep 17 00:00:00 2001 From: adriana-rv Date: Thu, 8 Feb 2018 14:26:53 -0600 Subject: [PATCH 1/4] Add register of pdf file --- src/collective/judgment/content/files.py | 4 + .../judgment/profiles/default/types.xml | 1 + .../profiles/default/types/Pdf_File.xml | 94 +++++++++++++++++++ 3 files changed, 99 insertions(+) create mode 100644 src/collective/judgment/profiles/default/types/Pdf_File.xml diff --git a/src/collective/judgment/content/files.py b/src/collective/judgment/content/files.py index c2738ea..20593ad 100644 --- a/src/collective/judgment/content/files.py +++ b/src/collective/judgment/content/files.py @@ -40,6 +40,10 @@ class IPdfFile(model.Schema): ) +class PdfFile(File): + """Convenience subclass for ``File`` only accept pdf + """ + class CurriculumVitae(File): """Convenience subclass for ``Curriculum Vitae`` portal type """ diff --git a/src/collective/judgment/profiles/default/types.xml b/src/collective/judgment/profiles/default/types.xml index 549bc10..966357d 100644 --- a/src/collective/judgment/profiles/default/types.xml +++ b/src/collective/judgment/profiles/default/types.xml @@ -4,6 +4,7 @@ + diff --git a/src/collective/judgment/profiles/default/types/Pdf_File.xml b/src/collective/judgment/profiles/default/types/Pdf_File.xml new file mode 100644 index 0000000..0658362 --- /dev/null +++ b/src/collective/judgment/profiles/default/types/Pdf_File.xml @@ -0,0 +1,94 @@ + + + + + Pdf File + Lets you upload a file to the site. + + False + Pdf File + + + + + + True + False + + + collective.judgment.AddPromotion + collective.judgment.content.files.PdfFile + + + collective.judgment.content.files.IPdfFile + + + + + + + + + + + + + + + string:${folder_url}/++add++Pdf File + file_view + False + view + + + + + + + + + + + + + + + + + + + From 1f3b683b3649b54baf0210b31da174263c94210d Mon Sep 17 00:00:00 2001 From: adriana-rv Date: Thu, 8 Feb 2018 14:27:29 -0600 Subject: [PATCH 2/4] Add pdf file content in promotions --- src/collective/judgment/profiles/default/types/promotion.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/collective/judgment/profiles/default/types/promotion.xml b/src/collective/judgment/profiles/default/types/promotion.xml index ef5b5e4..ef1b338 100644 --- a/src/collective/judgment/profiles/default/types/promotion.xml +++ b/src/collective/judgment/profiles/default/types/promotion.xml @@ -21,6 +21,7 @@ True True + From 706bf22c6b6020522b35e8a39a72bd64b52543b4 Mon Sep 17 00:00:00 2001 From: adriana-rv Date: Thu, 8 Feb 2018 14:28:38 -0600 Subject: [PATCH 3/4] change add and edit forms for Pdf Files contents --- .../judgment/browser/addpdffiles.py | 33 +++++++++++++++++++ .../judgment/browser/configure.zcml | 22 +++++++++++++ .../judgment/browser/editpdffiles.py | 18 ++++++++++ 3 files changed, 73 insertions(+) create mode 100644 src/collective/judgment/browser/addpdffiles.py create mode 100644 src/collective/judgment/browser/editpdffiles.py diff --git a/src/collective/judgment/browser/addpdffiles.py b/src/collective/judgment/browser/addpdffiles.py new file mode 100644 index 0000000..fcca4ed --- /dev/null +++ b/src/collective/judgment/browser/addpdffiles.py @@ -0,0 +1,33 @@ +# -*- coding: utf-8 -*- +# from collective.judgment import _ +from Acquisition import aq_inner +from plone.dexterity.browser.add import DefaultAddForm +from plone.dexterity.browser.add import DefaultAddView +from plone.dexterity.interfaces import IDexterityFTI +from plone.dexterity.utils import addContentToContainer +from zope.component import getUtility + + +class PdfFileAddForm(DefaultAddForm): + portal_type = 'Pdf File' + + def add(self, object): + + fti = getUtility(IDexterityFTI, name=self.portal_type) + container = aq_inner(self.context) + new_object = addContentToContainer(container, object) + + parentfti = getUtility(IDexterityFTI, name=container.portal_type) + + if parentfti.immediate_view: + self.immediate_view = "/".join( + [container.absolute_url(), fti.immediate_view] + ) + else: + self.immediate_view = "/".join( + [container.absolute_url(), ] + ) + + +class PdfFileAddView(DefaultAddView): + form = PdfFileAddForm diff --git a/src/collective/judgment/browser/configure.zcml b/src/collective/judgment/browser/configure.zcml index 40f3b86..a675ab4 100644 --- a/src/collective/judgment/browser/configure.zcml +++ b/src/collective/judgment/browser/configure.zcml @@ -17,8 +17,30 @@ type="plone" directory="static" /> + + + + + + + Date: Thu, 8 Feb 2018 17:21:10 -0600 Subject: [PATCH 4/4] Add default method for title --- src/collective/judgment/browser/views.py | 8 ++++++-- src/collective/judgment/content/files.py | 12 +++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/collective/judgment/browser/views.py b/src/collective/judgment/browser/views.py index 6489a77..4874160 100644 --- a/src/collective/judgment/browser/views.py +++ b/src/collective/judgment/browser/views.py @@ -33,6 +33,7 @@ def order_items(self): items['report'] = None items['plan'] = None items['letter'] = None + items['pdf'] = None others = [] for item in self.context.items(): @@ -45,6 +46,8 @@ def order_items(self): items['report'] = item[1] elif itemportal == 'Reasoned Letter': items['letter'] = item[1] + elif itemportal == 'Pdf File': + items['pdf'] = item[1] else: others.append(item[1]) @@ -55,14 +58,15 @@ def iddictToType(self, key): 'cv': 'Curriculum Vitae', 'plan': 'Activities Plan', 'report': 'Activities Report', - 'letter': 'Reasoned Letter' + 'letter': 'Reasoned Letter', + 'pdf': 'Pdf File' } return iddict.get(key, '') def editurl(self, key): nametype = self.iddictToType(key) if nametype: - return '++add++' + nametype + return '++add++' + nametype + '?title=foopdf' return '' diff --git a/src/collective/judgment/content/files.py b/src/collective/judgment/content/files.py index 20593ad..3f85bc5 100644 --- a/src/collective/judgment/content/files.py +++ b/src/collective/judgment/content/files.py @@ -8,15 +8,25 @@ from collective.judgment.validators import isValidFileType from plone.autoform import directives +from zope.interface import provider +from zope.schema.interfaces import IContextAwareDefaultFactory + + + +@provider(IContextAwareDefaultFactory) +def request_title(context): + return context.REQUEST.form.get('title', '') class IPdfFile(model.Schema): """ Marker interfce and Dexterity Python Schema for Promotion """ + # directives.omitted('title') title = schema.TextLine( title=_(u'Title'), # description=u"", - required=False + required=False, + defaultFactory=request_title, ) description = schema.Text(