Skip to content

Commit

Permalink
Merge pull request #24 from eea/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
valipod authored Apr 9, 2021
2 parents 82594f7 + 5ce6dfc commit ff18082
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ pipeline {

"Plone5 & Python3": {
node(label: 'docker') {
sh '''docker run -i --rm --name="$BUILD_TAG-plone5py3" -e GIT_BRANCH="$BRANCH_NAME" -e VERSIONS="validate-email=3.0.0rc2" -e ADDONS="$GIT_NAME[test]" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:5-python3 -v -vv -s $GIT_NAME'''
sh '''docker run -i --rm --name="$BUILD_TAG-plone5py3" -e GIT_BRANCH="$BRANCH_NAME" -e ADDONS="$GIT_NAME[test]" -e DEVELOP="src/$GIT_NAME" -e GIT_CHANGE_ID="$CHANGE_ID" eeacms/plone-test:5-python3 -v -vv -s $GIT_NAME'''
}
}
)
Expand Down
5 changes: 5 additions & 0 deletions docs/HISTORY.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

2.6 - (2021-04-09)
---------------------------
* remove dependency on validate_email [dumitval]
* re-allow NFPs to edit users from orgs of their country [dumitval]

2.5 - (2021-01-09)
---------------------------
* remove NFP edit permission on "own country" users [dumitval]
Expand Down
9 changes: 9 additions & 0 deletions eea/userseditor/userdetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from eea.ldapadmin import ldap_config
from eea.ldapadmin.ldap_config import _get_ldap_agent
from eea.ldapadmin.logic_common import _is_authenticated
from eea.ldapadmin.ui_common import nfp_can_change_user
from eea.userseditor.permissions import EIONET_EDIT_USERS
from eea.userseditor.users_editor import load_template
from ldap import SCOPE_BASE
Expand Down Expand Up @@ -153,6 +154,14 @@ def can_edit_users(self):

return bool(user.has_permission(EIONET_EDIT_USERS, self.context))

def can_edit_user(self, uid):
""" check the the authenticated user can edit a specific user
This can mean he has the edit users permission or is an NFP and the
target user is member of an organisation from the NFP's country """
user = self.context.REQUEST.AUTHENTICATED_USER
return (user.has_permission(EIONET_EDIT_USERS, self.context) or
nfp_can_change_user(self, uid, no_org=False))

def can_view_roles(self):
"""can_view_roles."""
if not self.is_authenticated():
Expand Down
2 changes: 1 addition & 1 deletion eea/userseditor/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.5
2.6
11 changes: 7 additions & 4 deletions eea/userseditor/views/userdetails.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ class UserDetailsView(BrowserView):
def __call__(self):
REQUEST = self.request
uid = REQUEST.form.get('uid')
auth_user = REQUEST.AUTHENTICATED_USER
is_auth = ('Authenticated' in auth_user.getRoles())

if not uid:
# a missing uid can only mean this page is called by accident

return
if is_auth:
uid = auth_user.getId()
else:
# a missing uid can only mean this page is called by accident
return
date_for_roles = REQUEST.form.get('date_for_roles')

if "," in uid:
Expand All @@ -33,7 +37,6 @@ def __call__(self):
multi = None
user, roles = self.context._prepare_user_page(uid)

is_auth = ('Authenticated' in REQUEST.AUTHENTICATED_USER.getRoles())
# we can only connect to ldap with bind=True if we have an
# authenticated user
agent = self.context._get_ldap_agent(bind=is_auth)
Expand Down
6 changes: 4 additions & 2 deletions eea/userseditor/zpt/userdetails/index.zpt
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,16 @@
<div xmlns:foaf="http://xmlns.com/foaf/0.1/"
tal:attributes="about string:${common/portal_url}/users/${view/user/uid}" typeof="foaf:Person"
tal:define="user view/user;
uid user/uid;
disabled python:user.get('status') == 'disabled';
can_view_roles common/can_view_roles;
can_edit_user python:common.can_edit_user(uid);
can_edit_users common/can_edit_users;
is_authenticated common/is_authenticated;">

<h1 property="foaf:name">
<tal:block content="user/full_name" />
<a tal:condition="can_edit_users"
<a tal:condition="can_edit_user"
style="background:none"
tal:attributes="href string:${common/portal_url}/eionet-account-tools/eionet_account_tools/users/edit_user?id=${user/uid}">
<img src="/++resource++eea.userseditor-www/edit.gif" alt="Edit" />
Expand All @@ -102,7 +104,7 @@
<div class="figure figure-right" style="clear: both"
tal:condition="python:user['jpegPhoto'] and (not disabled or can_edit_users)">
<div class="figure-image">
<a tal:attributes="href string:userphoto_jpeg?uid=${user/uid}">
<a>
<img tal:attributes="src string:${common/base_url}/userphoto_jpeg?uid=${user/uid}" class="mouseclickpop"
alt="photo of person" style="max-width:200px; max-height:150px" />
</a>
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@
platforms=['OS Independent'],
zip_safe=False,
install_requires=[
'eea.usersdb>=1.3.40',
'eea.usersdb>=2.6',
'deform',
'phonenumbers',
'six'
],
extras_require={
'test': [
'eea.ldapadmin',
'eea.ldapadmin>=2.8',
],
},
)

0 comments on commit ff18082

Please sign in to comment.