mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-13 05:39:59 +00:00
Translate repo history page and formate modual import
This commit is contained in:
@@ -4,20 +4,15 @@ from django.utils.hashcompat import md5_constructor, sha_constructor
|
|||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
|
||||||
from auth.models import get_hexdigest, check_password
|
|
||||||
|
|
||||||
from auth import authenticate, login
|
|
||||||
|
|
||||||
from django.contrib.sites.models import RequestSite
|
from django.contrib.sites.models import RequestSite
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
|
from auth.models import get_hexdigest, check_password
|
||||||
|
from auth import authenticate, login
|
||||||
from registration import signals
|
from registration import signals
|
||||||
from registration.forms import RegistrationForm
|
from registration.forms import RegistrationForm
|
||||||
from registration.models import RegistrationProfile
|
from registration.models import RegistrationProfile
|
||||||
|
|
||||||
from seaserv import ccnet_rpc, get_ccnetuser
|
from seaserv import ccnet_rpc, get_ccnetuser
|
||||||
|
|
||||||
|
|
||||||
class UserManager(object):
|
class UserManager(object):
|
||||||
def create_user(self, username, password=None, is_staff=False, is_active=False):
|
def create_user(self, username, password=None, is_staff=False, is_active=False):
|
||||||
ccnet_rpc.add_emailuser(username, password, is_staff, is_active)
|
ccnet_rpc.add_emailuser(username, password, is_staff, is_active)
|
||||||
|
@@ -1,7 +1,12 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from django import template
|
from django import template
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
from seahub.settings import FILEEXT_ICON_MAP
|
from seahub.settings import FILEEXT_ICON_MAP
|
||||||
|
from seahub.po import TRANSLATION_MAP
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@@ -25,3 +30,13 @@ def file_icon_filter(value):
|
|||||||
return FILEEXT_ICON_MAP.get(file_ext)
|
return FILEEXT_ICON_MAP.get(file_ext)
|
||||||
else:
|
else:
|
||||||
return FILEEXT_ICON_MAP.get('default')
|
return FILEEXT_ICON_MAP.get('default')
|
||||||
|
|
||||||
|
def desc_repl(matchobj):
|
||||||
|
if TRANSLATION_MAP.has_key(matchobj.group(0)):
|
||||||
|
return TRANSLATION_MAP.get(matchobj.group(0))
|
||||||
|
|
||||||
|
@register.filter(name='translate_commit_desc')
|
||||||
|
def translate_commit_desc(value):
|
||||||
|
reg = '|'.join(TRANSLATION_MAP.keys())
|
||||||
|
|
||||||
|
return re.sub(reg, desc_repl, value)
|
||||||
|
@@ -1,20 +1,17 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
from django.http import HttpResponse, HttpResponseRedirect, Http404
|
from django.http import HttpResponse, HttpResponseRedirect, Http404
|
||||||
from django.shortcuts import render_to_response, redirect
|
from django.shortcuts import render_to_response, redirect
|
||||||
from django.core.urlresolvers import reverse
|
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from auth.decorators import login_required
|
|
||||||
|
|
||||||
|
from auth.decorators import login_required
|
||||||
from seaserv import ccnet_rpc, seafserv_threaded_rpc, get_repo, \
|
from seaserv import ccnet_rpc, seafserv_threaded_rpc, get_repo, \
|
||||||
get_group_repoids
|
get_group_repoids
|
||||||
|
|
||||||
from seahub.views import validate_emailuser
|
|
||||||
from seahub.utils import go_error, go_permission_error, validate_group_name
|
|
||||||
|
|
||||||
from pysearpc import SearpcError
|
from pysearpc import SearpcError
|
||||||
|
|
||||||
from seahub.contacts.models import Contact
|
from seahub.contacts.models import Contact
|
||||||
|
from seahub.utils import go_error, go_permission_error, validate_group_name
|
||||||
|
from seahub.views import validate_emailuser
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def group_list(request):
|
def group_list(request):
|
||||||
|
13
po.py
Normal file
13
po.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
TRANSLATION_MAP = {
|
||||||
|
'Added' : u'添加了',
|
||||||
|
'Deleted' : u'删除了',
|
||||||
|
'Modified' : u'修改了',
|
||||||
|
'Renamed' : u'重命名了',
|
||||||
|
'and' : u'以及另外',
|
||||||
|
'more files' : u'个文件',
|
||||||
|
'Reverted repo to status at' : u'同步目录状态恢复到',
|
||||||
|
'Merged others\' changes' : u'合并了其他人的修改',
|
||||||
|
}
|
@@ -11,7 +11,7 @@
|
|||||||
{% if not repo.props.encrypted %}
|
{% if not repo.props.encrypted %}
|
||||||
{% if is_owner or repo_ap == 'public' or share_to_me %}
|
{% if is_owner or repo_ap == 'public' or share_to_me %}
|
||||||
<p class="latest-commit mgt10">
|
<p class="latest-commit mgt10">
|
||||||
{{ latest_commit.props.desc }}<br />
|
{{ latest_commit.props.desc|translate_commit_desc }}<br />
|
||||||
<span class="author">by
|
<span class="author">by
|
||||||
{% if latest_commit.props.creator_name %}
|
{% if latest_commit.props.creator_name %}
|
||||||
{{ latest_commit.props.creator_name }}
|
{{ latest_commit.props.creator_name }}
|
||||||
|
@@ -24,7 +24,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<td>未知</td>
|
<td>未知</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<td>{{ commit.props.desc }}</td>
|
<td>{{ commit.props.desc|translate_commit_desc }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
11
utils.py
11
utils.py
@@ -1,14 +1,11 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
|
||||||
from django.shortcuts import render_to_response
|
|
||||||
from django.template import RequestContext
|
|
||||||
|
|
||||||
from django.utils.hashcompat import sha_constructor
|
|
||||||
|
|
||||||
import time
|
|
||||||
import re
|
import re
|
||||||
import settings
|
import settings
|
||||||
|
import time
|
||||||
|
from django.shortcuts import render_to_response
|
||||||
|
from django.template import RequestContext
|
||||||
|
from django.utils.hashcompat import sha_constructor
|
||||||
|
|
||||||
def go_permission_error(request, msg=None):
|
def go_permission_error(request, msg=None):
|
||||||
"""
|
"""
|
||||||
|
31
views.py
31
views.py
@@ -1,36 +1,31 @@
|
|||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
|
import settings
|
||||||
|
import stat
|
||||||
|
from urllib import quote
|
||||||
|
from django.core.urlresolvers import reverse
|
||||||
|
from django.db import IntegrityError
|
||||||
from django.http import HttpResponse, HttpResponseRedirect, Http404
|
from django.http import HttpResponse, HttpResponseRedirect, Http404
|
||||||
from django.shortcuts import render_to_response, redirect
|
from django.shortcuts import render_to_response, redirect
|
||||||
from django.core.urlresolvers import reverse
|
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from auth.decorators import login_required
|
|
||||||
from django.db import IntegrityError
|
|
||||||
from django.views.decorators.csrf import csrf_protect
|
from django.views.decorators.csrf import csrf_protect
|
||||||
|
|
||||||
|
from auth.decorators import login_required
|
||||||
from auth.forms import AuthenticationForm, PasswordResetForm, SetPasswordForm, \
|
from auth.forms import AuthenticationForm, PasswordResetForm, SetPasswordForm, \
|
||||||
PasswordChangeForm
|
PasswordChangeForm
|
||||||
from auth.tokens import default_token_generator
|
from auth.tokens import default_token_generator
|
||||||
|
|
||||||
from pysearpc import SearpcError
|
|
||||||
from seaserv import ccnet_rpc, get_groups, get_users, get_repos, \
|
from seaserv import ccnet_rpc, get_groups, get_users, get_repos, \
|
||||||
get_repo, get_commits, get_branches, \
|
get_repo, get_commits, get_branches, \
|
||||||
seafserv_threaded_rpc, seafserv_rpc, get_binding_peerids, get_ccnetuser, \
|
seafserv_threaded_rpc, seafserv_rpc, get_binding_peerids, get_ccnetuser, \
|
||||||
get_group_repoids
|
get_group_repoids
|
||||||
|
from pysearpc import SearpcError
|
||||||
|
|
||||||
from seahub.share.models import GroupShare, UserShare
|
|
||||||
from seahub.share.forms import GroupAddRepoForm
|
|
||||||
from seahub.base.accounts import CcnetUser
|
from seahub.base.accounts import CcnetUser
|
||||||
from forms import AddUserForm
|
|
||||||
from urllib import quote
|
|
||||||
|
|
||||||
from seahub.contacts.models import Contact
|
from seahub.contacts.models import Contact
|
||||||
|
from seahub.share.forms import GroupAddRepoForm
|
||||||
from utils import go_permission_error, go_error, list_to_string, get_httpserver_root, \
|
from seahub.share.models import GroupShare, UserShare
|
||||||
get_ccnetapplet_root, gen_token
|
from forms import AddUserForm
|
||||||
|
from utils import go_permission_error, go_error, list_to_string, \
|
||||||
import stat
|
get_httpserver_root, get_ccnetapplet_root, gen_token
|
||||||
import settings
|
|
||||||
import urllib
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def root(request):
|
def root(request):
|
||||||
|
Reference in New Issue
Block a user