Skip to content

Commit

Permalink
[fc] Repository: plone.schemaeditor
Browse files Browse the repository at this point in the history
Branch: refs/heads/master
Date: 2019-08-06T13:12:45+02:00
Author: Manuel Reinhardt (reinhardt) <reinhardt@syslab.com>
Commit: plone/plone.schemaeditor@64ea355

Added "Delete fieldset" functionality. Refs #69

Files changed:
A news/69.feature
A plone/schemaeditor/browser/schema/delete_fieldset.py
M plone/schemaeditor/browser/schema/configure.zcml
M plone/schemaeditor/browser/schema/schema_listing.pt
M plone/schemaeditor/tests/editing.rst
Repository: plone.schemaeditor

Branch: refs/heads/master
Date: 2019-08-14T00:08:38+02:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: plone/plone.schemaeditor@e8e6fd4

Merge pull request #70 from plone/69-delete-fieldset

Added "Delete fieldset" functionality

Files changed:
A news/69.feature
A plone/schemaeditor/browser/schema/delete_fieldset.py
M plone/schemaeditor/browser/schema/configure.zcml
M plone/schemaeditor/browser/schema/schema_listing.pt
M plone/schemaeditor/tests/editing.rst
  • Loading branch information
jensens committed Aug 13, 2019
1 parent d323c37 commit 7c2eaa8
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions last_commit.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,39 @@ Repository: plone.schemaeditor


Branch: refs/heads/master
Date: 2019-08-06T14:56:25+02:00
Date: 2019-08-06T13:12:45+02:00
Author: Manuel Reinhardt (reinhardt) <reinhardt@syslab.com>
Commit: https://github.com/plone/plone.schemaeditor/commit/86121730c21306d5d9be8f5ad1a68b1a274564ce
Commit: https://github.com/plone/plone.schemaeditor/commit/64ea355fdb20c696cda912fde4a19236b70348ed

Ignore validation errors for "required" when saving defaults.
Also added a "Done" button that leaves the field edit view.
Refs #71
Added "Delete fieldset" functionality. Refs #69

Files changed:
A news/71.bugfix
M plone/schemaeditor/browser/schema/listing.py
A news/69.feature
A plone/schemaeditor/browser/schema/delete_fieldset.py
M plone/schemaeditor/browser/schema/configure.zcml
M plone/schemaeditor/browser/schema/schema_listing.pt
M plone/schemaeditor/tests/editing.rst

b'diff --git a/news/71.bugfix b/news/71.bugfix\nnew file mode 100644\nindex 0000000..7a629b8\n--- /dev/null\n+++ b/news/71.bugfix\n@@ -0,0 +1 @@\n+Don\'t show an error when a "required" field doesn\'t have a default. Also added a "Done" button.\ndiff --git a/plone/schemaeditor/browser/schema/listing.py b/plone/schemaeditor/browser/schema/listing.py\nindex ac05e85..55e2cc1 100644\n--- a/plone/schemaeditor/browser/schema/listing.py\n+++ b/plone/schemaeditor/browser/schema/listing.py\n@@ -104,11 +104,19 @@ def delete_url(self, field):\n url = addTokenToUrl(url, self.request)\n return url\n \n+ @button.buttonAndHandler(\n+ _(u\'Done\'),\n+ )\n+ def handleDone(self, action):\n+ return self.request.RESPONSE.redirect(self.context.absolute_url())\n+\n @button.buttonAndHandler(\n _(u\'Save Defaults\'),\n condition=lambda form: getattr(form.context, \'showSaveDefaults\', True)\n )\n def handleSaveDefaults(self, action):\n+ for group in self.groups:\n+ group.ignoreRequiredOnExtract = self.ignoreRequiredOnExtract\n data, errors = self.extractData()\n if errors:\n self.status = self.formErrorsMessage\n'
b'diff --git a/news/69.feature b/news/69.feature\nnew file mode 100644\nindex 0000000..87548a8\n--- /dev/null\n+++ b/news/69.feature\n@@ -0,0 +1 @@\n+Deleting fieldsets is now possible through the UI.\ndiff --git a/plone/schemaeditor/browser/schema/configure.zcml b/plone/schemaeditor/browser/schema/configure.zcml\nindex 35e3c9a..f52b028 100644\n--- a/plone/schemaeditor/browser/schema/configure.zcml\n+++ b/plone/schemaeditor/browser/schema/configure.zcml\n@@ -24,6 +24,13 @@\n permission="plone.schemaeditor.ManageSchemata"\n />\n \n+ <browser:page\n+ name="delete-fieldset"\n+ for="plone.schemaeditor.interfaces.ISchemaContext"\n+ class=".delete_fieldset.DeleteFieldset"\n+ permission="plone.schemaeditor.ManageSchemata"\n+ />\n+\n <browser:resource\n name="schemaeditor.js"\n file="schemaeditor.js"\ndiff --git a/plone/schemaeditor/browser/schema/delete_fieldset.py b/plone/schemaeditor/browser/schema/delete_fieldset.py\nnew file mode 100644\nindex 0000000..6f50cb9\n--- /dev/null\n+++ b/plone/schemaeditor/browser/schema/delete_fieldset.py\n@@ -0,0 +1,43 @@\n+from plone.schemaeditor import _\n+from plone.schemaeditor.utils import SchemaModifiedEvent\n+from plone.supermodel.interfaces import FIELDSETS_KEY\n+from Products.Five import BrowserView\n+from Products.statusmessages.interfaces import IStatusMessage\n+from zope.container.contained import notifyContainerModified\n+from zope.event import notify\n+\n+\n+class DeleteFieldset(BrowserView):\n+\n+ def __call__(self):\n+ fieldset_name = self.request.form.get(\'name\')\n+ schema = self.context.schema\n+ fieldsets = schema.queryTaggedValue(FIELDSETS_KEY, [])\n+\n+ new_fieldsets = []\n+ for fieldset in fieldsets:\n+ if fieldset.__name__ == fieldset_name:\n+ if fieldset.fields:\n+ IStatusMessage(self.request).addStatusMessage(\n+ _(u\'Only empty fieldsets can be deleted\'),\n+ type=\'error\')\n+ return self.request.RESPONSE.redirect(self.nextURL)\n+ continue\n+ else:\n+ new_fieldsets.append(fieldset)\n+ if len(fieldsets) == len(new_fieldsets):\n+ IStatusMessage(self.request).addStatusMessage(\n+ _(u\'Fieldset not found\'), type=\'error\')\n+ return self.request.RESPONSE.redirect(self.nextURL)\n+\n+ schema.setTaggedValue(FIELDSETS_KEY, new_fieldsets)\n+\n+ notifyContainerModified(schema)\n+ notify(SchemaModifiedEvent(self.context))\n+ IStatusMessage(self.request).addStatusMessage(\n+ _(u\'Fieldset deleted successfully.\'), type=\'info\')\n+ return self.request.RESPONSE.redirect(self.nextURL)\n+\n+ @property\n+ def nextURL(self):\n+ return self.request.get(\'HTTP_REFERER\')\ndiff --git a/plone/schemaeditor/browser/schema/schema_listing.pt b/plone/schemaeditor/browser/schema/schema_listing.pt\nindex 9d80231..a433394 100644\n--- a/plone/schemaeditor/browser/schema/schema_listing.pt\n+++ b/plone/schemaeditor/browser/schema/schema_listing.pt\n@@ -82,6 +82,11 @@\n <legend tal:define="group_name python:group.label or view.default_fieldset_label"\n tal:content="group_name">Fieldset name</legend>\n \n+ <a id="delete-fieldset-${fieldset_name}" tal:condition="python:context.enableFieldsets and group.__name__ != view.__name__"\n+ href="${context/absolute_url}/@@delete-fieldset?name=${python:group.__name__}&_authenticator=${context/@@authenticator/token}"\n+ i18n:translate="delete_fieldset_hellip">Delete fieldset\n+ </a>\n+\n <tal:block tal:define="errors group/widgets/errors"\n tal:condition="errors"\n tal:repeat="error errors">\ndiff --git a/plone/schemaeditor/tests/editing.rst b/plone/schemaeditor/tests/editing.rst\nindex b9849a9..94ed777 100644\n--- a/plone/schemaeditor/tests/editing.rst\n+++ b/plone/schemaeditor/tests/editing.rst\n@@ -342,6 +342,37 @@ Now the actual IDummySchema schema should have the new fieldset ::\n [<Fieldset \'alpha\'...of fieldA>, <Fieldset \'extra_info\'...of >]\n \n \n+Deleting a fieldset\n+-------------------\n+\n+We can also delete a fieldset, but only if it\'s empty. Say we\'ve moved a field to the new fieldset ::\n+\n+ >>> browser.open(\'http://nohost/@@schemaeditor/field3/@@changefieldset?fieldset_index=2\')\n+ [event: ContainerModifiedEvent on InterfaceClass]\n+ [event: SchemaModifiedEvent on DummySchemaContext]\n+\n+If we try deleting the fieldset now, it won\'t work ::\n+\n+ >>> browser.open(portal_url + \'/@@schemaeditor\')\n+ >>> browser.getLink(id=\'delete-fieldset-2\').click()\n+ >>> IDummySchema.getTaggedValue(FIELDSETS_KEY)\n+ [<Fieldset \'alpha\'...of fieldA>, <Fieldset \'extra_info\'...of field3>]\n+\n+If we move the field out so that the fieldset is empty then we can delete the fieldset ::\n+\n+ >>> browser.open(\'http://nohost/@@schemaeditor/field3/@@changefieldset?fieldset_index=0\')\n+ [event: ContainerModifiedEvent on InterfaceClass]\n+ [event: SchemaModifiedEvent on DummySchemaContext]\n+ >>> browser.open(portal_url + \'/@@schemaeditor\')\n+ >>> browser.getLink(id=\'delete-fieldset-2\').click()\n+ [event: ContainerModifiedEvent on InterfaceClass]\n+ [event: SchemaModifiedEvent on DummySchemaContext]\n+\n+This removes the fieldset from the IDummySchema schema ::\n+\n+ >>> IDummySchema.getTaggedValue(FIELDSETS_KEY)\n+ [<Fieldset \'alpha\'...of fieldA>]\n+\n Miscellaneous field types\n -------------------------\n \n'

Repository: plone.schemaeditor


Branch: refs/heads/master
Date: 2019-08-14T00:08:16+02:00
Date: 2019-08-14T00:08:38+02:00
Author: Jens W. Klein (jensens) <jk@kleinundpartner.at>
Commit: https://github.com/plone/plone.schemaeditor/commit/a7d737b5bc80ab4f11ba1c70abbb128d90f7ff2b
Commit: https://github.com/plone/plone.schemaeditor/commit/e8e6fd4a82de7232886f8ff321aff7f31416081d

Merge pull request #72 from plone/71-save-defaults
Merge pull request #70 from plone/69-delete-fieldset

Ignore validation errors for "required" when saving defaults
Added "Delete fieldset" functionality

Files changed:
A news/71.bugfix
M plone/schemaeditor/browser/schema/listing.py
A news/69.feature
A plone/schemaeditor/browser/schema/delete_fieldset.py
M plone/schemaeditor/browser/schema/configure.zcml
M plone/schemaeditor/browser/schema/schema_listing.pt
M plone/schemaeditor/tests/editing.rst

b'diff --git a/news/71.bugfix b/news/71.bugfix\nnew file mode 100644\nindex 0000000..7a629b8\n--- /dev/null\n+++ b/news/71.bugfix\n@@ -0,0 +1 @@\n+Don\'t show an error when a "required" field doesn\'t have a default. Also added a "Done" button.\ndiff --git a/plone/schemaeditor/browser/schema/listing.py b/plone/schemaeditor/browser/schema/listing.py\nindex ac05e85..55e2cc1 100644\n--- a/plone/schemaeditor/browser/schema/listing.py\n+++ b/plone/schemaeditor/browser/schema/listing.py\n@@ -104,11 +104,19 @@ def delete_url(self, field):\n url = addTokenToUrl(url, self.request)\n return url\n \n+ @button.buttonAndHandler(\n+ _(u\'Done\'),\n+ )\n+ def handleDone(self, action):\n+ return self.request.RESPONSE.redirect(self.context.absolute_url())\n+\n @button.buttonAndHandler(\n _(u\'Save Defaults\'),\n condition=lambda form: getattr(form.context, \'showSaveDefaults\', True)\n )\n def handleSaveDefaults(self, action):\n+ for group in self.groups:\n+ group.ignoreRequiredOnExtract = self.ignoreRequiredOnExtract\n data, errors = self.extractData()\n if errors:\n self.status = self.formErrorsMessage\n'
b'diff --git a/news/69.feature b/news/69.feature\nnew file mode 100644\nindex 0000000..87548a8\n--- /dev/null\n+++ b/news/69.feature\n@@ -0,0 +1 @@\n+Deleting fieldsets is now possible through the UI.\ndiff --git a/plone/schemaeditor/browser/schema/configure.zcml b/plone/schemaeditor/browser/schema/configure.zcml\nindex 35e3c9a..f52b028 100644\n--- a/plone/schemaeditor/browser/schema/configure.zcml\n+++ b/plone/schemaeditor/browser/schema/configure.zcml\n@@ -24,6 +24,13 @@\n permission="plone.schemaeditor.ManageSchemata"\n />\n \n+ <browser:page\n+ name="delete-fieldset"\n+ for="plone.schemaeditor.interfaces.ISchemaContext"\n+ class=".delete_fieldset.DeleteFieldset"\n+ permission="plone.schemaeditor.ManageSchemata"\n+ />\n+\n <browser:resource\n name="schemaeditor.js"\n file="schemaeditor.js"\ndiff --git a/plone/schemaeditor/browser/schema/delete_fieldset.py b/plone/schemaeditor/browser/schema/delete_fieldset.py\nnew file mode 100644\nindex 0000000..6f50cb9\n--- /dev/null\n+++ b/plone/schemaeditor/browser/schema/delete_fieldset.py\n@@ -0,0 +1,43 @@\n+from plone.schemaeditor import _\n+from plone.schemaeditor.utils import SchemaModifiedEvent\n+from plone.supermodel.interfaces import FIELDSETS_KEY\n+from Products.Five import BrowserView\n+from Products.statusmessages.interfaces import IStatusMessage\n+from zope.container.contained import notifyContainerModified\n+from zope.event import notify\n+\n+\n+class DeleteFieldset(BrowserView):\n+\n+ def __call__(self):\n+ fieldset_name = self.request.form.get(\'name\')\n+ schema = self.context.schema\n+ fieldsets = schema.queryTaggedValue(FIELDSETS_KEY, [])\n+\n+ new_fieldsets = []\n+ for fieldset in fieldsets:\n+ if fieldset.__name__ == fieldset_name:\n+ if fieldset.fields:\n+ IStatusMessage(self.request).addStatusMessage(\n+ _(u\'Only empty fieldsets can be deleted\'),\n+ type=\'error\')\n+ return self.request.RESPONSE.redirect(self.nextURL)\n+ continue\n+ else:\n+ new_fieldsets.append(fieldset)\n+ if len(fieldsets) == len(new_fieldsets):\n+ IStatusMessage(self.request).addStatusMessage(\n+ _(u\'Fieldset not found\'), type=\'error\')\n+ return self.request.RESPONSE.redirect(self.nextURL)\n+\n+ schema.setTaggedValue(FIELDSETS_KEY, new_fieldsets)\n+\n+ notifyContainerModified(schema)\n+ notify(SchemaModifiedEvent(self.context))\n+ IStatusMessage(self.request).addStatusMessage(\n+ _(u\'Fieldset deleted successfully.\'), type=\'info\')\n+ return self.request.RESPONSE.redirect(self.nextURL)\n+\n+ @property\n+ def nextURL(self):\n+ return self.request.get(\'HTTP_REFERER\')\ndiff --git a/plone/schemaeditor/browser/schema/schema_listing.pt b/plone/schemaeditor/browser/schema/schema_listing.pt\nindex 9d80231..a433394 100644\n--- a/plone/schemaeditor/browser/schema/schema_listing.pt\n+++ b/plone/schemaeditor/browser/schema/schema_listing.pt\n@@ -82,6 +82,11 @@\n <legend tal:define="group_name python:group.label or view.default_fieldset_label"\n tal:content="group_name">Fieldset name</legend>\n \n+ <a id="delete-fieldset-${fieldset_name}" tal:condition="python:context.enableFieldsets and group.__name__ != view.__name__"\n+ href="${context/absolute_url}/@@delete-fieldset?name=${python:group.__name__}&_authenticator=${context/@@authenticator/token}"\n+ i18n:translate="delete_fieldset_hellip">Delete fieldset\n+ </a>\n+\n <tal:block tal:define="errors group/widgets/errors"\n tal:condition="errors"\n tal:repeat="error errors">\ndiff --git a/plone/schemaeditor/tests/editing.rst b/plone/schemaeditor/tests/editing.rst\nindex b9849a9..94ed777 100644\n--- a/plone/schemaeditor/tests/editing.rst\n+++ b/plone/schemaeditor/tests/editing.rst\n@@ -342,6 +342,37 @@ Now the actual IDummySchema schema should have the new fieldset ::\n [<Fieldset \'alpha\'...of fieldA>, <Fieldset \'extra_info\'...of >]\n \n \n+Deleting a fieldset\n+-------------------\n+\n+We can also delete a fieldset, but only if it\'s empty. Say we\'ve moved a field to the new fieldset ::\n+\n+ >>> browser.open(\'http://nohost/@@schemaeditor/field3/@@changefieldset?fieldset_index=2\')\n+ [event: ContainerModifiedEvent on InterfaceClass]\n+ [event: SchemaModifiedEvent on DummySchemaContext]\n+\n+If we try deleting the fieldset now, it won\'t work ::\n+\n+ >>> browser.open(portal_url + \'/@@schemaeditor\')\n+ >>> browser.getLink(id=\'delete-fieldset-2\').click()\n+ >>> IDummySchema.getTaggedValue(FIELDSETS_KEY)\n+ [<Fieldset \'alpha\'...of fieldA>, <Fieldset \'extra_info\'...of field3>]\n+\n+If we move the field out so that the fieldset is empty then we can delete the fieldset ::\n+\n+ >>> browser.open(\'http://nohost/@@schemaeditor/field3/@@changefieldset?fieldset_index=0\')\n+ [event: ContainerModifiedEvent on InterfaceClass]\n+ [event: SchemaModifiedEvent on DummySchemaContext]\n+ >>> browser.open(portal_url + \'/@@schemaeditor\')\n+ >>> browser.getLink(id=\'delete-fieldset-2\').click()\n+ [event: ContainerModifiedEvent on InterfaceClass]\n+ [event: SchemaModifiedEvent on DummySchemaContext]\n+\n+This removes the fieldset from the IDummySchema schema ::\n+\n+ >>> IDummySchema.getTaggedValue(FIELDSETS_KEY)\n+ [<Fieldset \'alpha\'...of fieldA>]\n+\n Miscellaneous field types\n -------------------------\n \n'

0 comments on commit 7c2eaa8

Please sign in to comment.