mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-18 16:36:15 +00:00
Use contact email in user profile page
This commit is contained in:
@@ -43,7 +43,7 @@ def tsstr_day(value):
|
||||
except:
|
||||
return datetime.fromtimestamp(value/1000000).strftime("%Y-%m-%d")
|
||||
|
||||
# Supported file extensions and file icon name.
|
||||
# Supported file extensions and file icon name.
|
||||
FILEEXT_ICON_MAP = {
|
||||
# pdf file
|
||||
'pdf' : 'pdf.png',
|
||||
@@ -136,7 +136,7 @@ def file_icon_filter(value, size=None):
|
||||
return FILEEXT_ICON_MAP.get('default')
|
||||
|
||||
# This way of translation looks silly, but works well.
|
||||
COMMIT_MSG_TRANSLATION_MAP = {
|
||||
COMMIT_MSG_TRANSLATION_MAP = {
|
||||
'Added' : _('Added'),
|
||||
'Deleted' : _('Deleted'),
|
||||
'Removed' : _('Removed'),
|
||||
@@ -156,11 +156,11 @@ def translate_commit_desc(value):
|
||||
# Change 'repo' to 'library' in revert commit msg, since 'repo' is
|
||||
# only used inside of seafile system.
|
||||
value = value.replace('repo', 'library')
|
||||
|
||||
|
||||
# Do nothing if current language is English.
|
||||
if translation.get_language() == 'en':
|
||||
return value
|
||||
|
||||
|
||||
if value.startswith('Reverted library'):
|
||||
return value.replace('Reverted library to status at', _('Reverted library to status at'))
|
||||
elif value.startswith('Reverted file'):
|
||||
@@ -189,14 +189,14 @@ def translate_commit_desc(value):
|
||||
if not m:
|
||||
ret_list.append(e)
|
||||
continue
|
||||
|
||||
|
||||
op = m.group(1) # e.g., "Added"
|
||||
op_trans = _(op)
|
||||
file_name = m.group(2) # e.g., "foo.txt"
|
||||
has_more = m.group(3) # e.g., "and 3 more files"
|
||||
n_files = m.group(4) # e.g., "3"
|
||||
more_type = m.group(5) # e.g., "files"
|
||||
|
||||
|
||||
if has_more:
|
||||
if translation.get_language() == 'zh-cn':
|
||||
typ = u'文件' if more_type == 'files' else u'目录'
|
||||
@@ -354,7 +354,7 @@ def translate_seahub_time_str(val):
|
||||
return ret
|
||||
else:
|
||||
return _('Just now')
|
||||
|
||||
|
||||
@register.filter(name='email2nickname')
|
||||
def email2nickname(value):
|
||||
"""
|
||||
@@ -378,12 +378,23 @@ def email2nickname(value):
|
||||
cache.set(key, nickname, NICKNAME_CACHE_TIMEOUT)
|
||||
return nickname
|
||||
|
||||
@register.filter(name='email2contact_email')
|
||||
def email2contact_email(value):
|
||||
"""
|
||||
Return contact_email if it exists and it's not an empty string,
|
||||
otherwise return username(login email).
|
||||
"""
|
||||
if not value:
|
||||
return ''
|
||||
|
||||
return Profile.objects.get_contact_email_by_user(value)
|
||||
|
||||
@register.filter(name='email2id')
|
||||
def email2id(value):
|
||||
"""
|
||||
Return the user id of an email. User id can be 0(ldap user),
|
||||
positive(registered user) or negtive(unregistered user).
|
||||
|
||||
|
||||
"""
|
||||
if not value:
|
||||
return -1
|
||||
@@ -405,7 +416,7 @@ def id_or_email(value):
|
||||
"""
|
||||
uid = email2id(value)
|
||||
return value if uid == 0 else uid
|
||||
|
||||
|
||||
@register.filter(name='url_target_blank')
|
||||
def url_target_blank(text):
|
||||
return text.replace('<a ', '<a target="_blank" ')
|
||||
|
@@ -58,7 +58,7 @@
|
||||
{% avatar request.user 36 %}
|
||||
<div class="txt">
|
||||
{{ request.user.username|email2nickname }} <br />
|
||||
{{ request.user.username}}
|
||||
{{ request.user.username|email2contact_email}}
|
||||
</div>
|
||||
</div>
|
||||
<span class="loading-icon loading-tip"></span>
|
||||
|
@@ -224,7 +224,7 @@
|
||||
{% avatar request.user 36 %}
|
||||
<div class="txt">
|
||||
<%- app.pageOptions.name %><br />
|
||||
<%- app.pageOptions.email %>
|
||||
<%- app.pageOptions.contact_email %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="loading-icon loading-tip"></div>
|
||||
|
@@ -1461,7 +1461,7 @@
|
||||
{% avatar request.user 36 %}
|
||||
<div class="txt">
|
||||
<%- app.pageOptions.name %><br />
|
||||
<%- app.pageOptions.username %>
|
||||
<%- app.pageOptions.contact_email %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="loading-icon loading-tip"></div>
|
||||
|
@@ -239,6 +239,7 @@ app["pageOptions"] = {
|
||||
})(),
|
||||
username: "{{request.user.username}}",
|
||||
name: "{{request.user.username|email2nickname|escapejs}}",
|
||||
contact_email: "{{ request.user.username|email2contact_email|escapejs }}",
|
||||
events_enabled: {% if events_enabled %} true {% else %} false {% endif %},
|
||||
can_add_repo: {% if user.permissions.can_add_repo %} true {% else %} false {% endif %},
|
||||
can_generate_shared_link: {% if user.permissions.can_generate_shared_link %} true {% else %} false {% endif %},
|
||||
|
@@ -56,7 +56,7 @@
|
||||
{% avatar request.user 36 %}
|
||||
<div class="txt">
|
||||
{{ request.user.username|email2nickname }} <br />
|
||||
{{ request.user.username}}
|
||||
{{ request.user.username|email2contact_email }}
|
||||
</div>
|
||||
</div>
|
||||
<span class="loading-icon loading-tip"></span>
|
||||
@@ -107,6 +107,7 @@ app["pageOptions"] = {
|
||||
csrfToken: "{{ csrf_token }}",
|
||||
email: "{{request.user.username}}",
|
||||
name: "{{request.user.username|email2nickname|escapejs}}",
|
||||
contact_email: "{{request.user.username|email2contact_email|escapejs}}",
|
||||
language_code: "{{ LANGUAGE_CODE }}",
|
||||
events_enabled: {% if events_enabled %} true {% else %} false {% endif %},
|
||||
repo_password_min_length: {{ repo_password_min_length }},
|
||||
|
Reference in New Issue
Block a user