mirror of
https://github.com/haiwen/seahub.git
synced 2025-10-21 10:51:17 +00:00
show user-profile in popup
This commit is contained in:
@@ -22,18 +22,21 @@
|
||||
<p class="intro">{{ intro }}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<form id="add-as-contact" class="hide" action="{{ SITE_ROOT }}contacts/add/" method="post">
|
||||
<input type="hidden" name="user_email" value="{{ request.user.username }}" id="id_user_email" />
|
||||
<label>邮箱:</label><br />
|
||||
<input id="id_contact_email" type="text" name="contact_email" maxlength="255" value="{{ email }}" /><br />
|
||||
<label>名字(可选):</label><br />
|
||||
<input id="id_contact_name" type="text" name="contact_name" maxlength="255" /><br />
|
||||
<label>备注(可选):</label><br />
|
||||
<input id="id_note" type="text" name="note" maxlength="255" /><br />
|
||||
<input type="submit" value="提交" class="submit" />
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% if new_user %}
|
||||
<form id="add-as-contact" class="hide" action="{{ SITE_ROOT }}contacts/add/" method="post">
|
||||
<input type="hidden" name="user_email" value="{{ request.user.username }}" id="id_user_email" />
|
||||
<label>邮箱:</label><br />
|
||||
<input id="id_contact_email" type="text" name="contact_email" maxlength="255" value="{{ email }}" /><br />
|
||||
<label>名字(可选):</label><br />
|
||||
<input id="id_contact_name" type="text" name="contact_name" maxlength="255" /><br />
|
||||
<label>备注(可选):</label><br />
|
||||
<input id="id_note" type="text" name="note" maxlength="255" /><br />
|
||||
<input type="submit" value="提交" class="submit" />
|
||||
</form>
|
||||
{% endif %}
|
||||
|
||||
{% else %}
|
||||
<div class="text-panel">
|
||||
<p class="error">{{ err_msg }}</p>
|
||||
@@ -42,9 +45,11 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_script %}
|
||||
{% if new_user %}
|
||||
<script type="text/javascript">
|
||||
$('#add').click(function() {
|
||||
$('#add-as-contact').modal({appendTo: '#main'});
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
@@ -4,5 +4,6 @@ urlpatterns = patterns('profile.views',
|
||||
url(r'^list_user/$', 'list_userids', name="list_userids"),
|
||||
url(r'^$', 'edit_profile', name="edit_profile"),
|
||||
url(r'^(?P<user>[^/]+)/$', 'user_profile', name="user_profile"),
|
||||
url(r'^(?P<user>[^/]+)/get/$', 'get_user_profile', name="get_user_profile"),
|
||||
url(r'^logout/$', 'logout_relay', name="logout_relay"),
|
||||
)
|
||||
|
@@ -1,4 +1,5 @@
|
||||
# encoding: utf-8
|
||||
import simplejson as json
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
from django.shortcuts import render_to_response, get_object_or_404
|
||||
@@ -103,3 +104,36 @@ def user_profile(request, user):
|
||||
'err_msg': err_msg,
|
||||
},
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
def get_user_profile(request, user):
|
||||
data = {
|
||||
'email': user,
|
||||
'user_nickname': '',
|
||||
'user_intro': '',
|
||||
'err_msg': '',
|
||||
'new_user': ''
|
||||
}
|
||||
content_type = 'application/json; charset=utf-8'
|
||||
|
||||
try:
|
||||
user_check = ccnet_rpc.get_emailuser(user)
|
||||
except:
|
||||
user_check = None
|
||||
|
||||
if user_check:
|
||||
profile = Profile.objects.filter(user=user)
|
||||
if profile:
|
||||
profile = profile[0]
|
||||
data['user_nickname'] = profile.nickname
|
||||
data['user_intro'] = profile.intro
|
||||
else:
|
||||
data['err_msg'] = '该用户不存在'
|
||||
|
||||
if user == request.user.username or \
|
||||
Contact.objects.filter(user_email=request.user.username,
|
||||
contact_email=user).count() > 0:
|
||||
data['new_user'] = False
|
||||
else:
|
||||
data['new_user'] = True
|
||||
|
||||
return HttpResponse(json.dumps(data), content_type=content_type)
|
||||
|
Reference in New Issue
Block a user