Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customized User/Groups Preferences in Site Configuration #2117

Merged
merged 11 commits into from
Aug 21, 2022
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Changelog
2.3.0 (unreleased)
------------------

- #2117 Customized User/Groups Preferences in Site Configuration
- #2115 Fix insufficient privileges for instrument QC viewlet
- #2114 Allow Multi Analysis Results Entry
- #2111 Replace header table with customizable sample header viewlet
Expand Down
1 change: 1 addition & 0 deletions src/senaite/core/browser/configure.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<include package=".portlets"/>
<include package=".samples"/>
<include package=".setup"/>
<include package=".usergroup"/>
<include package=".viewlets"/>
<include package=".widgets"/>

Expand Down
Empty file.
66 changes: 66 additions & 0 deletions src/senaite/core/browser/usergroup/configure.zcml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:browser="http://namespaces.zope.org/browser"
xmlns:zcml="http://namespaces.zope.org/zcml">

<!-- Users Controlpanel -->
<browser:page
name="usergroup-userprefs"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".usergroups_usersoverview.UsersOverviewControlPanel"
permission="plone.app.controlpanel.UsersAndGroups"
template="templates/usergroups_usersoverview.pt"
layer="senaite.core.interfaces.ISenaiteCore"
/>

<!-- Groups Controlpanel -->
<browser:page
name="usergroup-groupprefs"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class=".usergroups_groupsoverview.GroupsOverviewControlPanel"
permission="plone.app.controlpanel.UsersAndGroups"
template="templates/usergroups_groupsoverview.pt"
layer="senaite.core.interfaces.ISenaiteCore"
/>

<!-- Group Membership -->
<browser:page
name="usergroup-groupmembership"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class="Products.CMFPlone.controlpanel.browser.usergroups_groupmembership.GroupMembershipControlPanel"
permission="plone.app.controlpanel.UsersAndGroups"
template="templates/usergroups_groupmembership.pt"
layer="senaite.core.interfaces.ISenaiteCore"
/>

<!-- Group Details -->
<browser:page
name="usergroup-groupdetails"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class="Products.CMFPlone.controlpanel.browser.usergroups_groupdetails.GroupDetailsControlPanel"
permission="plone.app.controlpanel.UsersAndGroups"
template="templates/usergroups_groupdetails.pt"
layer="senaite.core.interfaces.ISenaiteCore"
/>

<!-- User Configlet -->
<browser:page
name="user-information"
for="plone.app.layout.navigation.interfaces.INavigationRoot"
class=".userdatapanel.UserDataConfiglet"
permission="plone.app.controlpanel.UsersAndGroups"
layer="senaite.core.interfaces.ISenaiteCore"
/>

<!-- User Group Membership -->
<browser:page
name="usergroup-usermembership"
for="Products.CMFPlone.interfaces.IPloneSiteRoot"
class="Products.CMFPlone.controlpanel.browser.usergroups_usermembership.UserMembershipControlPanel"
permission="plone.app.controlpanel.UsersAndGroups"
template="templates/usergroups_usermembership.pt"
layer="senaite.core.interfaces.ISenaiteCore"
/>


</configure>
52 changes: 52 additions & 0 deletions src/senaite/core/browser/usergroup/templates/account-configlet.pt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="here/prefs_main_template/macros/master"
i18n:domain="plone">

<div metal:fill-slot="prefs_configlet_content">

<article id="content">

<a
id="setup-link"
href=""
class="link-parent"
tal:attributes="href string:$portal_url/@@usergroup-userprefs"
i18n:translate="label_up_to_usersoverview">
Up to Users Overview
</a>

<h1 class="documentFirstHeading" tal:content="view/label | nothing" />

<div metal:use-macro="context/global_statusmessage/macros/portal_message">
Portal status message
</div>

<div id="content-core">
<div class="autotabs">
<div class="autotoc-nav"
tal:define="view_name view/__name__;
userquery python:view.makeQuery()">
<a href="${portal_url}/@@user-information${userquery}"
tal:define="selected python:view_name=='user-information'"
tal:attributes="class python:'autotoc-level-1' + (' active' if selected else '')"
i18n:translate="title_personal_information_form">Personal Information</a>
<!-- <a href="${portal_url}/@@user-preferences${userquery}"
tal:define="selected python:view_name=='user-preferences'"
tal:attributes="class python:'autotoc-level-1' + (' active' if selected else '')"
i18n:translate="">Personal Preferences</a> -->
<a href="${portal_url}/@@usergroup-usermembership${userquery}"
i18n:translate="label_group_memberships">Group Memberships</a>
</div>
<metal:b use-macro="context/@@ploneform-macros/titlelessform" />
</div>
</div>

</article>

</div>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
lang="en"
metal:use-macro="context/prefs_main_template/macros/master"
i18n:domain="plone">

<body>

<metal:main fill-slot="prefs_configlet_content"
tal:define="template_id string:@@usergroup-groupdetails;
portal_roles view/portal_roles;
groupquery python:view.makeQuery(groupname=view.groupname);
groupkeyquery python:view.makeQuery(key=view.groupname)">


<!-- When no group is specified, this gets used as the add group page page -->
<article id="content" tal:condition="not:view/group">
<metal:block metal:use-macro="template/macros/props">
<metal:title metal:fill-slot="content-title">
<h1 class="documentFirstHeading"
i18n:translate="heading_create_group">Create a Group</h1>
</metal:title>

<metal:name metal:fill-slot="name">
<div class="field">
<label for="addname" i18n:translate="label_name">Name</label>

<span class="fieldRequired" title="Required"
i18n:attributes="title title_required;"
i18n:translate="label_required">(Required)</span>

<div class="formHelp" i18n:translate="help_groupname">
A unique identifier for the group. Can not be changed after creation.
</div>

<input type="text" name="addname" value="groupname"
id="addname"
tal:attributes="value view/groupname | string:"/>
</div>
</metal:name>
</metal:block>
</article>

<article id="content" tal:condition="view/group | nothing">
<metal:block define-macro="props">

<a id="setup-link"
href="${portal_url}/@@usergroup-groupprefs"
class="link-parent"
i18n:translate="label_up_to_groups_overview">
Up to Groups Overview
</a>

<h1 class="documentFirstHeading"
i18n:translate="heading_edit_groupproperties"
metal:define-slot="content-title">Group: <span i18n:name="groupname" tal:replace="view/grouptitle|nothing"/></h1>

<div metal:use-macro="context/global_statusmessage/macros/portal_message">
Portal status message
</div>

<div id="content-core"
tal:define="token context/@@authenticator/token">
<div class="autotabs">

<div class="autotoc-nav">
<a href="${portal_url}/@@usergroup-groupmembership?${groupquery}"
i18n:translate="label_group_members">Group Members</a>
<a class="active"
href="${portal_url}/@@usergroup-groupdetails?${groupquery}"
i18n:translate="label_group_properties">Group Properties</a>
<!-- <a href="${portal_url}/@@manage-group-portlets?${groupkeyquery}&_authenticator=${token}"
i18n:translate="label_group_portlets">Group Portlets</a>
<a href="${portal_url}/@@manage-group-dashboard?${groupkeyquery}&_authenticator=${token}"
i18n:translate="label_group_dashboard">Group Dashboard</a> -->
</div>

<form action=""
id="createGroup"
name="groups"
method="post"
class="pat-formunloadalert pat-formautofocus"
tal:attributes="action string:$portal_url/$template_id"
tal:define="targetobject context/portal_groupdata;">

<fieldset>
<div class="field" metal:define-slot="name">
<label for="groupname" i18n:translate="label_name">Name</label>

<div tal:content="view/groupname | string:" />
<input type="hidden" name="groupname" value="groupname"
id="groupname"
tal:attributes="value view/groupname | string:"/>
</div>

<tal:set tal:condition="targetobject/management_page_charset|nothing"
tal:define="dummy python:request.set('management_page_charset_tag','')" />

<tal:set tal:condition="not:targetobject/management_page_charset|nothing">
<tal:defines define="dummy python:request.set('management_page_charset','UTF-8');
dummy python:request.set('management_page_charset_tag','UTF-8:');" />
</tal:set>

<tal:properties repeat="property targetobject/propertyMap">
<div class="field"
tal:define="id property/id;
type property/type;
propertyvalue python:view.get_group_property(id);">

<label for="value"
tal:attributes="for id"
i18n:translate=""
tal:content="python:targetobject.propertyLabel(id).capitalize()">Property Value</label>

<div tal:define="propertyitem python:targetobject.getProperty(id);
disabled python:None if (not view.group or view.group.canWriteProperty(id)) else 'disabled';"
tal:condition="python:'w' in property.get('mode', 'awd')">

<input type="text" name="id" size="35"
tal:condition="python:type in ('int', 'long')"
tal:attributes="name string:$id:$type;
id id;
value python:propertyvalue if propertyvalue else '';
disabled disabled;" />

<input type="text" name="id" size="35"
tal:condition="python:type in ('float','date')"
tal:attributes="name string:$id:${request/management_page_charset_tag}$type;
id id;
value python:propertyvalue if propertyvalue else '';
disabled disabled;" />

<input type="text" name="string and ustring" size="35"
tal:condition="python:type in ('string','ustring')"
tal:attributes="name string:$id:${request/management_page_charset_tag}$type;
id id;
value python:propertyvalue if propertyvalue else '';
disabled disabled;" />

<input type="checkbox"
class="noborder"
name="id"
id="cb-checkbox"
tal:condition="python: type in ('boolean',)"
tal:attributes="name string:$id:$type;
id id;
checked python:'checked' if propertyvalue else '';
disabled disabled;" />

<input name="tokens and utokens" value="" type="text" size="35"
tal:condition="python:type in ('tokens', 'utokens')"
tal:attributes="name string:$id:${request/management_page_charset_tag}$type;
value python:propertyvalue if propertyvalue else '';
disabled disabled;" />

<textarea name="text and utext"
rows="6"
cols="35"
tal:condition="python: type in ('text', 'utext')"
tal:attributes="name string:$id:${request/management_page_charset_tag}$type;
disabled disabled;"
tal:content="propertyvalue">some data</textarea>

<textarea name="lines and ulines"
rows="6"
cols="35"
tal:condition="python: type in ('lines', 'ulines')"
tal:attributes="name string:$id:${request/management_page_charset_tag}$type;
disabled disabled;"
tal:content="python: propertyvalue and '\n'.join(propertyvalue) or ''">
</textarea>


<tal:selections tal:condition="python:type in ('selection', 'multiple selection')"
tal:define="select_variable python:property.get('select_variable','');
select_value python:select_variable and path('context/%s' %select_variable) or [];">

<select name="selection" tal:condition="python:type in ('selection',)"
tal:attributes="name string:$id:${request/management_page_charset_tag}text;
disabled disabled;">
<tal:values repeat="option select_value">
<option tal:attributes="SELECTED python:'SELECTED' if propertyvalue==option else ''"
tal:content="option">value</option>
</tal:values>
</select>

<select name="multiple selection" multiple="multiple" tal:condition="python:type in ('multiple selection',)"
tal:attributes="name string:$id:${request/management_page_charset_tag}list:string;
size python:min(7, len(select_value));
disabled disabled;">
<tal:values repeat="option select_value">
<option tal:attributes="SELECTED python:'selected' if (propertyvalue and option in propertyvalue) else ''"
tal:content="option">value</option>
</tal:values>
</select>

</tal:selections>

</div>

</div>
</tal:properties>

<input type="hidden" name="form.submitted" value="1" />

<div class="formControls">
<input class="context btn btn-sm mt-3"
type="submit"
name="form.button.Save"
value="Save"
i18n:attributes="value label_save;" />
</div>
</fieldset>

<input tal:replace="structure context/@@authenticator/authenticator" />
</form>
</div>
</div>
</metal:block>
</article>

</metal:main>

</body>
</html>
Loading