mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 07:08:55 +00:00
[profile] add profile download link
This commit is contained in:
@@ -14,5 +14,15 @@
|
||||
<h3>当前设置</h3>
|
||||
<p>个人 ID: {{ profile.ccnet_user_id }}</p>
|
||||
|
||||
{% if profile_timestamp %}
|
||||
<p>加密后的帐号文件上传时间: {{ profile_timestamp }}
|
||||
<a href="{{ SITE_ROOT }}profile/download/?user_id={{profile.ccnet_user_id}}">
|
||||
点此下载
|
||||
</a>
|
||||
</p>
|
||||
{% else %}
|
||||
<p>帐号文件未上传,请在本地 seafile 界面 "帐号" 标签下上传</p>
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
@@ -5,4 +5,5 @@ urlpatterns = patterns('profile.views',
|
||||
url(r'^ccnet/$', 'get_ccnet_profile'),
|
||||
url(r'^edit/$', 'set_profile', name="profile_setting"),
|
||||
url(r'^edit/ccnet/$', 'set_ccnet_profile', name="ccnet_profile_setting"),
|
||||
url(r'^download/$', 'download_profile', name="profile_download"),
|
||||
)
|
||||
|
@@ -9,7 +9,7 @@ import datetime
|
||||
|
||||
from forms import SetUserProfileForm
|
||||
from models import UserProfile, UserCcnetConf
|
||||
from seaserv import ccnet_rpc
|
||||
from seaserv import ccnet_rpc, translate_time_usec
|
||||
|
||||
@login_required
|
||||
def show_profile(request):
|
||||
@@ -18,8 +18,16 @@ def show_profile(request):
|
||||
except UserProfile.DoesNotExist:
|
||||
profile = UserProfile(user=request.user)
|
||||
profile.save()
|
||||
|
||||
try:
|
||||
profile_timestamp = ccnet_rpc.get_user_profile_timestamp(profile.ccnet_user_id)
|
||||
profile_timestamp = translate_time_usec(profile_timestamp)
|
||||
except:
|
||||
profile_timestamp = None
|
||||
|
||||
return render_to_response('profile/profile.html',
|
||||
{ 'profile': profile, },
|
||||
{ 'profile': profile,
|
||||
'profile_timestamp': profile_timestamp},
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
|
||||
@@ -43,7 +51,7 @@ def set_profile(request):
|
||||
try:
|
||||
ccnet_rpc.add_client(ccnet_user_id)
|
||||
except Exception, e:
|
||||
error_msg = "Ccnet Deamon is not available, try again later"
|
||||
error_msg = "Ccnet Daemon is not available, try again later"
|
||||
else:
|
||||
profile.ccnet_user_id = ccnet_user_id
|
||||
profile.save()
|
||||
@@ -101,3 +109,20 @@ def set_ccnet_profile(request):
|
||||
return render_to_response('profile/set_ccnet_conf.html',
|
||||
{ 'ccnet_profile': ccnet_profile },
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
def download_profile(request):
|
||||
user_id = request.GET.get('user_id', None)
|
||||
err_msg = ''
|
||||
try:
|
||||
profile = ccnet_rpc.get_user_profile(user_id)
|
||||
except Exception as e:
|
||||
err_msg = str(e)
|
||||
profile = None
|
||||
|
||||
if profile:
|
||||
response = HttpResponse(profile, content_type='application/txt')
|
||||
response['Content-Disposition'] = 'attachment; filename=ccnet.profile'
|
||||
return response
|
||||
else:
|
||||
return HttpResponse("Error: " + err_msg)
|
||||
|
Reference in New Issue
Block a user