mirror of
https://github.com/haiwen/seahub.git
synced 2025-10-20 10:20:42 +00:00
@@ -14,6 +14,7 @@ class Acticity {
|
||||
this.op_type = json.op_type;
|
||||
this.createdFilesCount = 0;
|
||||
this.createdFilesList = [];
|
||||
this.login_id = json.login_id;
|
||||
if (json.op_type === 'clean-up-trash') {
|
||||
this.days = json.days;
|
||||
} else if (json.op_type === 'rename' && json.obj_type === 'repo') {
|
||||
|
@@ -53,7 +53,8 @@ class FilesActivities extends Component {
|
||||
name: item.author_name,
|
||||
contact_email: item.author_contact_email,
|
||||
avatar_url: item.avatar_url,
|
||||
isSelected: false
|
||||
isSelected: false,
|
||||
login_id: item.login_id
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -152,7 +153,8 @@ class FilesActivities extends Component {
|
||||
name: item.author_name,
|
||||
contact_email: item.author_contact_email,
|
||||
avatar_url: item.avatar_url,
|
||||
isSelected: false
|
||||
isSelected: false,
|
||||
login_id: item.login_id,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@@ -69,7 +69,7 @@ class UserSelector extends Component {
|
||||
const { isPopoverOpen, query } = this.state;
|
||||
const { currentSelectedUsers, availableUsers } = this.props;
|
||||
const selectedUsers = availableUsers.filter(item => item.isSelected);
|
||||
const filteredAvailableUsers = query.trim() ? availableUsers.filter(item => item.contact_email.indexOf(query.trim()) != -1 || item.name.indexOf(query.trim()) != -1) : availableUsers;
|
||||
const filteredAvailableUsers = query.trim() ? availableUsers.filter(item => item.contact_email.indexOf(query.trim()) != -1 || item.name.indexOf(query.trim()) != -1 || item.login_id.indexOf(query.trim()) != -1) : availableUsers;
|
||||
return (
|
||||
<div className="mt-4 position-relative">
|
||||
<span className="cur-activity-modifiers d-inline-block p-2 rounded" onClick={this.onToggleClick}>
|
||||
|
@@ -9,7 +9,7 @@ from rest_framework.response import Response
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.authentication import SessionAuthentication
|
||||
|
||||
from seahub.base.templatetags.seahub_tags import email2contact_email
|
||||
from seahub.base.templatetags.seahub_tags import email2contact_email, email2login_id
|
||||
from seahub.utils import EVENTS_ENABLED, get_user_activities, is_pro_version, IS_DB_SQLITE3
|
||||
from seahub.utils.timeutils import utc_datetime_to_isoformat_timestr
|
||||
from seahub.api2.utils import api_error
|
||||
@@ -65,6 +65,7 @@ class ActivitiesView(APIView):
|
||||
d['author_email'] = e.op_user
|
||||
d['author_name'] = email2nickname(e.op_user)
|
||||
d['author_contact_email'] = email2contact_email(e.op_user)
|
||||
d['login_id'] = email2login_id(e.op_user)
|
||||
|
||||
try:
|
||||
avatar_size = int(request.GET.get('avatar_size', 72))
|
||||
|
@@ -444,7 +444,7 @@ class GroupMembersImport(APIView):
|
||||
emails_list = []
|
||||
for record in records:
|
||||
if record[0]:
|
||||
email = record[0].strip().lower()
|
||||
email = str(record[0]).strip().lower()
|
||||
emails_list.append(email)
|
||||
|
||||
result = {}
|
||||
@@ -463,12 +463,14 @@ class GroupMembersImport(APIView):
|
||||
user_not_found = False
|
||||
|
||||
try:
|
||||
User.objects.get(email=email)
|
||||
User.objects.get(email=email_from_excel)
|
||||
except User.DoesNotExist:
|
||||
user_not_found = True
|
||||
|
||||
if user_not_found:
|
||||
email = Profile.objects.get_username_by_contact_email(email)
|
||||
email = Profile.objects.get_username_by_contact_email(email_from_excel)
|
||||
if not email:
|
||||
email = Profile.objects.get_username_by_login_id(email_from_excel)
|
||||
try:
|
||||
User.objects.get(email=email)
|
||||
user_not_found = False
|
||||
@@ -538,10 +540,14 @@ class GroupMembersImportExample(APIView):
|
||||
def get(self, request):
|
||||
|
||||
data_list = []
|
||||
head = [_('Email')]
|
||||
head = [_('Email or LoginID')]
|
||||
for i in range(5):
|
||||
username = "test" + str(i) + "@example.com"
|
||||
data_list.append([username])
|
||||
|
||||
for i in range(5):
|
||||
login_id = "ID" + str(i)
|
||||
data_list.append([login_id])
|
||||
|
||||
wb = write_xls('sample', head, data_list)
|
||||
if not wb:
|
||||
|
@@ -58,8 +58,10 @@ class AuthenticationForm(forms.Form):
|
||||
try:
|
||||
user = User.objects.get(email=email)
|
||||
if not user.is_active:
|
||||
self.errors['inactive'] = _("This account is inactive.")
|
||||
raise forms.ValidationError(_("This account is inactive."))
|
||||
is_first_login = not UserOptions.objects.is_user_logged_in(user.username)
|
||||
if not is_first_login:
|
||||
self.errors['inactive'] = _("This account is inactive.")
|
||||
raise forms.ValidationError(_("This account is inactive."))
|
||||
except User.DoesNotExist:
|
||||
pass
|
||||
|
||||
|
@@ -19,7 +19,7 @@ from seahub.base.accounts import User
|
||||
from seahub.profile.models import Profile
|
||||
from seahub.profile.settings import NICKNAME_CACHE_TIMEOUT, NICKNAME_CACHE_PREFIX, \
|
||||
EMAIL_ID_CACHE_TIMEOUT, EMAIL_ID_CACHE_PREFIX, CONTACT_CACHE_TIMEOUT, \
|
||||
CONTACT_CACHE_PREFIX
|
||||
CONTACT_CACHE_PREFIX, LOGIN_ID_CACHE_PREFIX, LOGIN_ID_CACHE_TIMEOUT
|
||||
from seahub.cconvert import CConvert
|
||||
from seahub.settings import TIME_ZONE
|
||||
from seahub.shortcuts import get_first_object_or_none
|
||||
@@ -393,6 +393,22 @@ def email2contact_email(value):
|
||||
cache.set(key, contact_email, CONTACT_CACHE_TIMEOUT)
|
||||
return contact_email
|
||||
|
||||
@register.filter(name='email2login_id')
|
||||
def email2login_id(value):
|
||||
if not value:
|
||||
return ''
|
||||
|
||||
key = normalize_cache_key(value, LOGIN_ID_CACHE_PREFIX)
|
||||
login_id = cache.get(key)
|
||||
if login_id and login_id.strip():
|
||||
return login_id
|
||||
|
||||
profile = Profile.objects.get_profile_by_user(value)
|
||||
login_id = profile and profile.login_id or ''
|
||||
cache.set(key, login_id, LOGIN_ID_CACHE_TIMEOUT)
|
||||
return login_id
|
||||
|
||||
|
||||
@register.filter(name='email2id')
|
||||
def email2id(value):
|
||||
"""
|
||||
|
@@ -9,3 +9,6 @@ EMAIL_ID_CACHE_PREFIX = getattr(settings, 'EMAIL_ID_CACHE_PREFIX', 'EMAIL_ID_')
|
||||
|
||||
CONTACT_CACHE_TIMEOUT = getattr(settings, 'CONTACT_CACHE_TIMEOUT', 24 * 60 * 60)
|
||||
CONTACT_CACHE_PREFIX = getattr(settings, 'CONTACT_CACHE_PREFIX', 'CONTACT_')
|
||||
|
||||
LOGIN_ID_CACHE_TIMEOUT = getattr(settings, 'LOGIN_ID_CACHE_TIMEOUT', 24 * 60 * 60)
|
||||
LOGIN_ID_CACHE_PREFIX = getattr(settings, 'LOGIN_ID_CACHE_PREFIX', 'LOGIN_ID_')
|
||||
|
Reference in New Issue
Block a user