Skip to content

Commit

Permalink
Merge pull request #49 from plone/portal-properties-cleanup
Browse files Browse the repository at this point in the history
Portal properties cleanup
  • Loading branch information
pbauer committed Sep 20, 2015
2 parents 986f147 + 971b6a1 commit e317cd5
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 185 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
1.10.10 (unreleased)
--------------------

- Pull types_link_to_folder_contents values from the configuration registry.
[esteele]

- Set calendar_starting_year and calendar_future_years_available in registry.
See https://github.com/plone/Products.CMFPlone/issues/872
[pbauer]
Expand Down
23 changes: 17 additions & 6 deletions Products/Archetypes/Extensions/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@

from App.Common import package_home
from OFS.ObjectManager import BadRequestException
from zope.component import getUtility
from Products.CMFCore.ActionInformation import ActionInformation
from Products.CMFCore.DirectoryView import addDirectoryViews, \
registerDirectory, manage_listAvailableDirectories
from Products.CMFCore.utils import getToolByName, getPackageName
from Products.CMFPlone.interfaces import ITypesSchema
from plone.registry.interfaces import IRegistry
from Products.Archetypes.config import REFERENCE_CATALOG
from Products.Archetypes.ArchetypeTool import fixActionsForType
from Products.Archetypes.ArchetypeTool import listTypes
Expand Down Expand Up @@ -148,15 +151,23 @@ def install_types(self, out, types, package_name):
sp = getattr(pt, 'site_properties', None)
if sp is None:
return None
props = ('use_folder_tabs', 'typesLinkToFolderContentsInFC')
for prop in props:
folders = sp.getProperty(prop, None)
if folders is None:
continue

folders = sp.getProperty('use_folder_tabs', None)
if folders is not None:
folders = list(folders)
folders.extend(folderish)
folders = tuple(dict(zip(folders, folders)).keys())
sp._updateProperty(prop, folders)
sp._updateProperty('use_folder_tabs', folders)

registry = getUtility(IRegistry)
settings = registry.forInterface(ITypesSchema, prefix="plone")
folders = settings.types_link_to_folder_contents
if folders is not None:
folders = list(folders)
folders.extend(folderish)
folders = tuple(dict(zip(folders, folders)).keys())
settings.types_link_to_folder_contents = folders



def _getFtiAndDataFor(tool, typename, klassname, package_name):
Expand Down
18 changes: 8 additions & 10 deletions Products/Archetypes/Widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@

from plone.app.widgets import base as base_widgets
from plone.app.widgets import utils
from plone.registry.interfaces import IRegistry
from plone.uuid.interfaces import IUUID

from zope.component import getUtility

import json

_marker = []
Expand Down Expand Up @@ -1215,18 +1218,13 @@ def _base_args(self, context, field, request):
membership = getToolByName(context, 'portal_membership')
user = membership.getAuthenticatedMember()

try:
site_properties = getToolByName(
context, 'portal_properties')['site_properties']
allowRolesToAddKeywords = site_properties.getProperty(
'allowRolesToAddKeywords', None)
except AttributeError:
allowRolesToAddKeywords = False
registry = getUtility(IRegistry)
roles_allowed_to_add_keywords = registry.get(
'plone.roles_allowed_to_add_keywords', [])

allowNewItems = False
if allowRolesToAddKeywords and [
role for role in user.getRolesInContext(context)
if role in allowRolesToAddKeywords]:
if [role for role in user.getRolesInContext(context)
if role in roles_allowed_to_add_keywords]:
allowNewItems = True

args.setdefault('pattern_options', {})
Expand Down
6 changes: 3 additions & 3 deletions Products/Archetypes/skins/archetypes/widgets/keyword.pt
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
<metal:use use-macro="field_macro | context/widgets/field/macros/edit">
<tal:define metal:fill-slot="widget_body" define="contentKeywords accessor;
allowedKeywords python: context.collectKeywords(fieldName, field.accessor, widget.vocab_source);
site_props context/portal_properties/site_properties|nothing;
format widget/format | string:select;
allowRolesToAddKeywords site_props/allowRolesToAddKeywords|nothing;">
registry context/portal_registry;
roles_allowed_to_add_keywords python:registry['plone.roles_allowed_to_add_keywords'];">

<div tal:attributes="id string:$fieldName-tags;"
class="tagsContainer">
Expand Down Expand Up @@ -120,7 +120,7 @@
<div class="visualClear"><!-- --></div>
</div>

<tal:condition condition="python:not widget.roleBasedAdd or (allowRolesToAddKeywords and [role for role in user.getRolesInContext(context) if role in allowRolesToAddKeywords])">
<tal:condition condition="python:not widget.roleBasedAdd or (roles_allowed_to_add_keywords and [role for role in user.getRolesInContext(context) if role in roles_allowed_to_add_keywords])">
<dl class="newTagsSection">
<label for="subject_keywords">
<dt class="newTagsTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
<body>
<h1>Keyword multiple select enhancement test - refs PLIP ticket #11017.</h1>

<p>The PLIP adds an accessible, jQuery-based widget,
<p>The PLIP adds an accessible, jQuery-based widget,
which includes both a scrollbar and checkboxes.</p>

<p>This file is basically a copy of ../keyword.pt, with QUnit added, and
slight modifications to make it run in a static, standalone way,
<p>This file is basically a copy of ../keyword.pt, with QUnit added, and
slight modifications to make it run in a static, standalone way,
looking somewhat realistic, although Plone's css messes up QUnit's a little.</p>

<p>---</p>
Expand All @@ -36,9 +36,9 @@ <h2 id="qunit-userAgent"></h2>

<p>---</p>
<h2>Manual Test</h2>

<!-- Keyword Widgets -->

<metal:view_macro define-macro="view"
tal:define="kssClassesView context/@@kss_field_decorator_view;
getKssClasses nocall:kssClassesView/getKssClassesInlineEditable;">
Expand All @@ -53,15 +53,15 @@ <h2>Manual Test</h2>
</ul>
</div>
</metal:view_macro>

<metal:define define-macro="edit">
<metal:use use-macro="field_macro | context/widgets/field/macros/edit">
<tal:define metal:fill-slot="widget_body" define="contentKeywords accessor;
allowedKeywords python: context.collectKeywords(fieldName, field.accessor, widget.vocab_source);
site_props context/portal_properties/site_properties|nothing;
format widget/format | string:select;
allowRolesToAddKeywords site_props/allowRolesToAddKeywords|nothing;">

registry context/portal_registry;
roles_allowed_to_add_keywords python:registry['plone.roles_allowed_to_add_keywords'];">

<div tal:condition="allowedKeywords" id="existingTagsSection">
<tal:comment tal:replace="nothing">
dl semantically associates selector name with values
Expand All @@ -70,20 +70,20 @@ <h2>Manual Test</h2>
<label for="subject">
<dt id="existingTagsTitle">
<span i18n:translate="label_existing_tags">
Select from existing tags.
Select from existing tags.
</span>
</dt>
<span id="existingTagsHelp" class="formHelp" i18n:translate="label_existingTagsHelp">
Use Control/Command/Shift keys to select multiple tags.
<tal:comment tal:replace="nothing">
Type-to-skip functionality with javascipt enabled
currently is described as
"Hover and type the first letter to skip through tags."
However, on touch-driven devices, vertical hover typically
scrolls the page, so horizontal hover is necessary to enable this.
Alternatively, clicking any of the tags also enables type-to-skip.
So the text could technically be extended to handle this special case
as "Hover or click and type the first letter to skip through tags.",
Type-to-skip functionality with javascipt enabled
currently is described as
"Hover and type the first letter to skip through tags."
However, on touch-driven devices, vertical hover typically
scrolls the page, so horizontal hover is necessary to enable this.
Alternatively, clicking any of the tags also enables type-to-skip.
So the text could technically be extended to handle this special case
as "Hover or click and type the first letter to skip through tags.",
but I think this would be confusing to the majority of users.
</tal:comment>
</span>
Expand Down Expand Up @@ -122,9 +122,9 @@ <h2>Manual Test</h2>
<span id="oneOrMoreTagsSelected" i18n:translate="label_oneOrMoreTagsSelected">% tags currently selected.</span>
<tal:comment tal:replace="nothing">
Call js to modify this widget with both a scrollbar and checkboxes.
There may be a better place to put this js call;
There may be a better place to put this js call;
examples exist in others' widget.py and js files,
but having it here covers cases where some but not all select elements
but having it here covers cases where some but not all select elements
call js to be modified.
Todo: The #subject should eventually refer to the template variable.
</tal:comment>
Expand All @@ -145,7 +145,7 @@ <h2>Manual Test</h2>
id string:${fieldName}_${repeat/keyword/number};
checked python:test(context.unicodeTestIn(keyword, value), 'checked', None);
value keyword" />
<label
<label
tal:content="keyword"
tal:attributes="for string:${fieldName}_${repeat/keyword/number}">
An existing tag
Expand All @@ -159,13 +159,13 @@ <h2>Manual Test</h2>
</dl>
<div class="visualClear"><!-- --></div>
</div>
<tal:condition condition="python:not widget.roleBasedAdd or (allowRolesToAddKeywords and [role for role in user.getRolesInContext(context) if role in allowRolesToAddKeywords])">

<tal:condition condition="python:not widget.roleBasedAdd or (roles_allowed_to_add_keywords and [role for role in user.getRolesInContext(context) if role in roles_allowed_to_add_keywords])">
<dl id="newTagsSection">
<label for="subject_keywords">
<dt id="newTagsTitle">
<span i18n:translate="label_new_tags">
Create and apply new tags.
Create and apply new tags.
</span>
</dt>
<span id="newTagsHelp" i18n:translate="label_newTagsHelp" class="formHelp">
Expand All @@ -174,7 +174,7 @@ <h2>Manual Test</h2>
</label>
<br />
<dd id="newTags">
<textarea
<textarea
id="entered_subjects"
name="subject:lines"
rows="4"
Expand All @@ -186,16 +186,16 @@ <h2>Manual Test</h2>
</dd>
</dl>
</tal:condition>

</tal:define>
</metal:use>
</metal:define>

<div metal:define-macro="search">
<div metal:use-macro="context/widgets/keyword/macros/edit">
</div>
</div>

</body>

</html>
Expand Down
Loading

0 comments on commit e317cd5

Please sign in to comment.