mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-08 18:30:53 +00:00
Enable user set nickname (#6193)
* enableUserSetNickname * ENABLE_USER_SET_NAME * enableShowLoginIDWhenSearchUser
This commit is contained in:
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import AsyncSelect from 'react-select/async';
|
||||
import { seafileAPI } from '../utils/seafile-api';
|
||||
import { gettext, enableShowContactEmailWhenSearchUser } from '../utils/constants';
|
||||
import { gettext, enableShowContactEmailWhenSearchUser, enableShowLoginIDWhenSearchUser } from '../utils/constants';
|
||||
import { Utils } from '../utils/utils';
|
||||
import toaster from './toast';
|
||||
import { UserSelectStyle } from './common/select';
|
||||
@@ -49,12 +49,13 @@ class UserSelect extends React.Component {
|
||||
let obj = {};
|
||||
obj.value = item.name;
|
||||
obj.email = item.email;
|
||||
obj.label = enableShowContactEmailWhenSearchUser ? (
|
||||
obj.label = (enableShowContactEmailWhenSearchUser || enableShowLoginIDWhenSearchUser) ? (
|
||||
<div className="d-flex">
|
||||
<img src={item.avatar_url} className="avatar" width="24" alt="" />
|
||||
<div className="ml-2">
|
||||
<span className="user-option-name">{item.name}</span><br />
|
||||
<span className="user-option-email">{item.contact_email}</span>
|
||||
{enableShowContactEmailWhenSearchUser && <span className="user-option-email">{item.contact_email}</span>}
|
||||
{enableShowLoginIDWhenSearchUser && <span className="user-option-email">{item.login_id}</span>}
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
|
@@ -5,7 +5,8 @@ import { gettext } from '../../utils/constants';
|
||||
const {
|
||||
nameLabel,
|
||||
enableUpdateUserInfo,
|
||||
enableUserSetContactEmail
|
||||
enableUserSetContactEmail,
|
||||
enableUserSetName
|
||||
} = window.app.pageOptions;
|
||||
|
||||
class UserBasicInfoForm extends React.Component {
|
||||
@@ -38,9 +39,10 @@ class UserBasicInfoForm extends React.Component {
|
||||
|
||||
handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
let data = {
|
||||
name: this.state.name
|
||||
};
|
||||
let data = {};
|
||||
if (enableUserSetName) {
|
||||
data.name = this.state.name;
|
||||
}
|
||||
if (enableUserSetContactEmail) {
|
||||
data.contact_email = this.state.contactEmail;
|
||||
}
|
||||
@@ -60,7 +62,7 @@ class UserBasicInfoForm extends React.Component {
|
||||
<div className="form-group row">
|
||||
<label className="col-sm-1 col-form-label" htmlFor="name">{nameLabel}</label>
|
||||
<div className="col-sm-5">
|
||||
<input className="form-control" id="name" type="text" name="nickname" value={name} disabled={!enableUpdateUserInfo} onChange={this.handleNameInputChange} />
|
||||
<input className="form-control" id="name" type="text" name="nickname" value={name} disabled={!enableUpdateUserInfo || !enableUserSetName} onChange={this.handleNameInputChange} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@@ -78,6 +78,7 @@ export const canInvitePeople = window.app.pageOptions.canInvitePeople;
|
||||
export const canLockUnlockFile = window.app.pageOptions.canLockUnlockFile;
|
||||
export const customNavItems = window.app.pageOptions.customNavItems;
|
||||
export const enableShowContactEmailWhenSearchUser = window.app.pageOptions.enableShowContactEmailWhenSearchUser;
|
||||
export const enableShowLoginIDWhenSearchUser = window.app.pageOptions.enableShowLoginIDWhenSearchUser;
|
||||
export const maxUploadFileSize = window.app.pageOptions.maxUploadFileSize;
|
||||
export const maxNumberOfFilesForFileupload = window.app.pageOptions.maxNumberOfFilesForFileupload;
|
||||
export const enableOCM = window.app.pageOptions.enableOCM;
|
||||
|
@@ -27,7 +27,7 @@ from seahub.contacts.models import Contact
|
||||
from seahub.avatar.templatetags.avatar_tags import api_avatar_url
|
||||
|
||||
from seahub.settings import ENABLE_GLOBAL_ADDRESSBOOK, \
|
||||
ENABLE_SEARCH_FROM_LDAP_DIRECTLY
|
||||
ENABLE_SEARCH_FROM_LDAP_DIRECTLY, ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -175,15 +175,21 @@ class SearchUser(APIView):
|
||||
|
||||
def format_searched_user_result(request, users, size):
|
||||
results = []
|
||||
if ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER:
|
||||
profile_queryset = Profile.objects.filter(user__in=users)
|
||||
profile_dict = { p.user: p.login_id for p in profile_queryset if p.login_id }
|
||||
|
||||
for email in users:
|
||||
url, is_default, date_uploaded = api_avatar_url(email, size)
|
||||
results.append({
|
||||
user_info = {
|
||||
"email": email,
|
||||
"avatar_url": url,
|
||||
"name": email2nickname(email),
|
||||
"contact_email": email2contact_email(email),
|
||||
})
|
||||
}
|
||||
if ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER:
|
||||
user_info['login_id'] = profile_dict.get(email, '')
|
||||
results.append(user_info)
|
||||
|
||||
return results
|
||||
|
||||
|
@@ -19,7 +19,8 @@ from seahub.api2.utils import api_error
|
||||
from seahub.base.templatetags.seahub_tags import email2nickname, \
|
||||
email2contact_email
|
||||
from seahub.profile.models import Profile, DetailedProfile
|
||||
from seahub.settings import ENABLE_UPDATE_USER_INFO, ENABLE_USER_SET_CONTACT_EMAIL, ENABLE_CONVERT_TO_TEAM_ACCOUNT
|
||||
from seahub.settings import ENABLE_UPDATE_USER_INFO, ENABLE_USER_SET_CONTACT_EMAIL, ENABLE_CONVERT_TO_TEAM_ACCOUNT, \
|
||||
ENABLE_USER_SET_NAME
|
||||
|
||||
import seaserv
|
||||
from seaserv import ccnet_api, seafile_api
|
||||
@@ -85,6 +86,9 @@ class User(APIView):
|
||||
# argument check for name
|
||||
name = request.data.get("name", None)
|
||||
if name:
|
||||
if not ENABLE_USER_SET_NAME:
|
||||
error_msg = _('Feature disabled.')
|
||||
return api_error(status.HTTP_403_FORBIDDEN, error_msg)
|
||||
name = name.strip()
|
||||
if len(name) > 64:
|
||||
error_msg = _('Name is too long (maximum is 64 characters)')
|
||||
|
@@ -19,6 +19,7 @@ window.app.pageOptions = {
|
||||
enableUpdateUserInfo: {% if ENABLE_UPDATE_USER_INFO %} true {% else %} false {% endif %},
|
||||
nameLabel: "{% trans "Name:" context "true name" %}",
|
||||
enableUserSetContactEmail: {% if ENABLE_USER_SET_CONTACT_EMAIL %} true {% else %} false {% endif %},
|
||||
enableUserSetName: {% if ENABLE_USER_SET_NAME %} true {% else %} false {% endif %},
|
||||
|
||||
canUpdatePassword: {% if not is_ldap_user and ENABLE_CHANGE_PASSWORD %} true {% else %} false {% endif %},
|
||||
{% if not is_ldap_user and ENABLE_CHANGE_PASSWORD %}
|
||||
|
@@ -164,6 +164,7 @@ def edit_profile(request):
|
||||
'enable_dingtalk': enable_dingtalk,
|
||||
'social_connected_dingtalk': social_connected_dingtalk,
|
||||
'ENABLE_USER_SET_CONTACT_EMAIL': settings.ENABLE_USER_SET_CONTACT_EMAIL,
|
||||
'ENABLE_USER_SET_NAME': settings.ENABLE_USER_SET_NAME,
|
||||
'user_unusable_password': request.user.enc_password == UNUSABLE_PASSWORD,
|
||||
'enable_adfs': enable_adfs,
|
||||
'saml_connected': saml_connected,
|
||||
|
@@ -313,6 +313,7 @@ ENABLE_OAUTH = False
|
||||
ENABLE_WATERMARK = False
|
||||
|
||||
ENABLE_SHOW_CONTACT_EMAIL_WHEN_SEARCH_USER = False
|
||||
ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER = False
|
||||
|
||||
# enable work weixin
|
||||
ENABLE_WORK_WEIXIN = False
|
||||
@@ -760,6 +761,7 @@ WEBDAV_SECRET_MIN_LENGTH = 1
|
||||
WEBDAV_SECRET_STRENGTH_LEVEL = 1
|
||||
|
||||
ENABLE_USER_SET_CONTACT_EMAIL = False
|
||||
ENABLE_USER_SET_NAME = True
|
||||
|
||||
# SSO to thirdparty website
|
||||
ENABLE_SSO_TO_THIRDPART_WEBSITE = False
|
||||
|
@@ -125,6 +125,7 @@
|
||||
canInvitePeople: {% if enable_guest_invitation and user.permissions.can_invite_guest %} true {% else %} false {% endif %},
|
||||
customNavItems: {% if custom_nav_items %} JSON.parse('{{ custom_nav_items | escapejs }}') {% else %} {{'[]'}} {% endif %},
|
||||
enableShowContactEmailWhenSearchUser: {% if enable_show_contact_email_when_search_user %} true {% else %} false {% endif %},
|
||||
enableShowLoginIDWhenSearchUser: {% if enable_show_login_id_when_search_user %} true {% else %} false {% endif %},
|
||||
{% if max_upload_file_size > 0 %}
|
||||
maxUploadFileSize: {{ max_upload_file_size }},
|
||||
{% endif %}
|
||||
|
@@ -1081,6 +1081,7 @@ def react_fake_view(request, **kwargs):
|
||||
'file_audit_enabled': FILE_AUDIT_ENABLED,
|
||||
'custom_nav_items': json.dumps(CUSTOM_NAV_ITEMS),
|
||||
'enable_show_contact_email_when_search_user': settings.ENABLE_SHOW_CONTACT_EMAIL_WHEN_SEARCH_USER,
|
||||
'enable_show_login_id_when_search_user': settings.ENABLE_SHOW_LOGIN_ID_WHEN_SEARCH_USER,
|
||||
'additional_share_dialog_note': ADDITIONAL_SHARE_DIALOG_NOTE,
|
||||
'additional_app_bottom_links': ADDITIONAL_APP_BOTTOM_LINKS,
|
||||
'additional_about_dialog_links': ADDITIONAL_ABOUT_DIALOG_LINKS,
|
||||
|
Reference in New Issue
Block a user