Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into unibe/customizing
Browse files Browse the repository at this point in the history
# Conflicts:
#	Products/zms/standard.py
  • Loading branch information
cmeier76 committed Sep 20, 2023
2 parents fbea5fa + 8ab6bb0 commit 12cd66f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 18 deletions.
18 changes: 9 additions & 9 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
},
"python.formatting.provider": "none",

// "python.testing.pytestEnabled": false,
// "python.testing.unittestEnabled": true,
// "python.testing.unittestArgs": [
// "-v",
// "-s",
// "./tests",
// "-p",
// "test*.py"
// ],
"python.testing.pytestEnabled": false,
"python.testing.unittestEnabled": true,
"python.testing.unittestArgs": [
"-v",
"-s",
"./tests",
"-p",
"test*.py"
],
}
2 changes: 1 addition & 1 deletion Products/zms/standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -2476,7 +2476,7 @@ def sendMail(context, mto, msubject, mbody, REQUEST=None, mattach=None):
part = MIMEAudio(filedata, fileextn)
else:
part = MIMEApplication(filedata)
part.add_header('Content-Disposition', 'attachment; filename="%s"'%umlaut_quote(filename).replace(' ','_'))
part.add_header('Content-Disposition', 'attachment; filename="%s"'%url_quote(umlaut_quote(filename).replace(' ','_')))
mime_msg.attach(part)

# Get MailHost.
Expand Down
1 change: 1 addition & 0 deletions Products/zms/zpt/ZMSContainerObject/manage_main.zpt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
data-root python:here.getRootElement().getHome().id;
data-client python:here.getHome().id;
data-level python:here.getLevel();
data-type python:here.attr('attr_dc_type') or nothing;
id python:'zmsid_%s'%(here.id);
class python:here.zmi_body_class(id='properties')">
<header tal:replace="structure python:here.zmi_body_header(here,request)">zmi_body_header</header>
Expand Down
16 changes: 8 additions & 8 deletions docker/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
"name": "ZMS5-Docker",
"type": "python",
"request": "launch",
"program": "/home/zope/venv/bin/runwsgi",
"program": "/app/zope/bin/runwsgi",
"justMyCode": false,
"console": "integratedTerminal",
"args": [
"--debug",
"--verbose",
"/home/zope/venv/instance/zms5/etc/zope.ini",
"/app/zope/etc/zope.ini",
"debug-mode=on",
"http_port=8086",
"http_port=8087",
],
"env": {
"PYTHONUNBUFFERED":"1",
"CONFIG_FILE": "/home/zope/venv/instance/zms5etc/zope.ini",
"INSTANCE_HOME": "/home/zope/venv/instance/zms5",
"CLIENT_HOME": "/home/zope/venv/instance/zms5",
"PYTHON": "/home/zope/venv/bin/python",
"SOFTWARE_HOME": "/home/zope/venv/bin/"
"CONFIG_FILE": "/app/zope/etc/zope.ini",
"INSTANCE_HOME": "/app/zope",
"CLIENT_HOME": "/app/zope",
"PYTHON": "/app/zope/bin/python",
"SOFTWARE_HOME": "/app/zope/bin/"
},
"serverReadyAction":{
"pattern":"Serving on http://0.0.0.0:8086",
Expand Down
38 changes: 38 additions & 0 deletions docs/develop_api_exampels_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,3 +371,41 @@ for r in q:
In addition ZMS offers useful API functions to make the code short and use it TAL :
1. zmscontext.get_uid(): returns UID of the context object, eg. `uid:d67ef401-db9b-46bd-9108-35f3c8d959a0`
2. zmscontext.getLinkObj(url): if url written in ZMS-internal url syntax `{$...}`, the targeted object will be returned, eg. this call `zmscontext.getLinkObj('{$uid:d67ef401-db9b-46bd-9108-35f3c8d959a0}')` will return the object. *Hint*: make sure, that the uid follows the syntax like this `'{$%s}'%(uid)`

## 9. Using the `internal_dict`-Attribute
The invisible multilingual attribute `internal_dict` is a ZMS-default python dictionary of any content object and can be used to store any additional technical data. A typical use case is adding new CSS-Classes to the body-element of a specific ZMS-GUI node for customizing it's GUI (aka ZMI):
the ZMS-action *manage_css_classes* can be imported via ZMS configuration and will appear in the contextual action menu. It triggers an External Python Method and adds the key `css_classes` to the internal_dict of the current node. The value can be a list of arbitray CSS-classnames the action will provide to the ZMI as a select list to the ZMS-user, e.g. ZMS-rolenames plus a suffix "_special":

```python
# GENERATE CSS LIST (Example Code)
css_classes = list(self.getRootElement().getSecurityRoles().keys())
css_classes.extend(['ZMSAdministrator','ZMSEditor','ZMSAuthor','ZMSSubscriber','ZMSUserAdministrator'])
css_classes = map(lambda r: [str(r)+'_special',str(r)+'_special'],css_classes)
```
Ref: *[Full Source on Github](https://github.com/zms-publishing/ZMS/blob/main/Products/zms/conf/metacmd_manager/manage_css_classes/manage_css_classes.py#L64-L69)*

With a CSS snippet injected via admininstration menu *Design* as *Additional ZMI CSS* the ZMS-GUI easily can be customized for specific user roles like this:

```css
body.ZMSAuthor_special .zmi-action .dropdown-menu a.dropdown-item {
display:none;
}
body.ZMSAuthor_special .zmi-action .dropdown-menu a.dropdown-item[title='ZMSFile'],
body.ZMSAuthor_special .zmi-action .dropdown-menu a.dropdown-item[title='ZMSLinkElement'] {
display:block;
}
```
For the ZMSAuthor the CSS snippet hides all the menu items besides "ZMSFile" and "ZMSLinkElement".

### Other Attributes for Customizing the ZMI
As an alternative to the ZMS-Action *manage_css_classes* the meta-attribute `attr_dc_type` can be used to add a specific style to the ZMI. The attribute value will be added as a CSS-class systematically as `data-type`- attribute to the body-element of the ZMI. This is useful if the CSS-class is static and does not need to be changed by the ZMS-User.

```css
body[data-type='News'] .zmi-action .dropdown-menu a.dropdown-item {
display:none;
}
body[data-type='News'] .zmi-action .dropdown-menu a.dropdown-item[title='News-Article'],
body[data-type='News'] .zmi-action .dropdown-menu a.dropdown-item[title='ZMSFolder'] {
display:block;
}
```

0 comments on commit 12cd66f

Please sign in to comment.