mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 07:01:12 +00:00
Modify autocomplete and contacts
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
{% extends "myhome_base.html" %}
|
{% extends "myhome_base.html" %}
|
||||||
|
{% load avatar_tags %}
|
||||||
|
|
||||||
{% block nav_contacts_class %}class="cur"{% endblock %}
|
{% block nav_contacts_class %}class="cur"{% endblock %}
|
||||||
|
|
||||||
@@ -9,17 +10,19 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block right_panel %}
|
{% block right_panel %}
|
||||||
<h3>联系人列表</h3>
|
<h3>站内联系人列表</h3>
|
||||||
<button id="contact-add">添加联系人</button>
|
<button id="contact-add">添加联系人</button>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th width="4%"></th>
|
||||||
<th width="38%">邮箱</th>
|
<th width="38%">邮箱</th>
|
||||||
<th width="20%">名字</th>
|
<th width="20%">名字</th>
|
||||||
<th width="32%">备注</th>
|
<th width="28%">备注</th>
|
||||||
<th width="10%">操作</th>
|
<th width="10%">操作</th>
|
||||||
</tr>
|
</tr>
|
||||||
{% for contact in contacts %}
|
{% for contact in registered_contacts %}
|
||||||
<tr>
|
<tr>
|
||||||
|
<td>{% avatar contact.contact_email 20 %}</td>
|
||||||
<td>{{ contact.contact_email }}</td>
|
<td>{{ contact.contact_email }}</td>
|
||||||
<td>{{ contact.contact_name }}</td>
|
<td>{{ contact.contact_name }}</td>
|
||||||
<td>{{ contact.note }}</td>
|
<td>{{ contact.note }}</td>
|
||||||
@@ -30,6 +33,30 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
<h3>站外联系人列表</h3>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th width="4%"></th>
|
||||||
|
<th width="38%">邮箱</th>
|
||||||
|
<th width="20%">名字</th>
|
||||||
|
<th width="32%">备注</th>
|
||||||
|
<th width="10%">操作</th>
|
||||||
|
</tr>
|
||||||
|
{% for contact in unregistered_contacts %}
|
||||||
|
<tr>
|
||||||
|
<td>{% avatar contact.contact_email 20 %}</td>
|
||||||
|
<td>{{ contact.contact_email }}</td>
|
||||||
|
<td>{{ contact.contact_name }}</td>
|
||||||
|
<td>{{ contact.note }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="#" data="{{ SITE_ROOT }}contacts/edit/?email={{ contact.contact_email }}" class="contact-edit op">编辑</a>
|
||||||
|
<a href="#" data="{{ SITE_ROOT }}contacts/delete/?email={{ contact.contact_email}}" class="contact-delete op">删除</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
|
||||||
<form action="{% url contact_add_post %}" method="post" id="contact-add-form" class="hide">
|
<form action="{% url contact_add_post %}" method="post" id="contact-add-form" class="hide">
|
||||||
<h3>添加联系人</h3>
|
<h3>添加联系人</h3>
|
||||||
{{ form.user_email.as_hidden }}
|
{{ form.user_email.as_hidden }}
|
||||||
@@ -99,15 +126,6 @@ $('#contact-edit-form').submit(function() {
|
|||||||
|
|
||||||
addConfirmTo($('.contact-delete'));
|
addConfirmTo($('.contact-delete'));
|
||||||
|
|
||||||
$("table tr:gt(0)").hover(
|
|
||||||
function() {
|
|
||||||
$(this).find('img').css('cursor', 'pointer').removeClass('vh');
|
|
||||||
},
|
|
||||||
function() {
|
|
||||||
$(this).find('img').addClass('vh');
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
$('#contact-add')
|
$('#contact-add')
|
||||||
.click(function() {
|
.click(function() {
|
||||||
$('#contact-add-form').modal({appendTo: '#main'});
|
$('#contact-add-form').modal({appendTo: '#main'});
|
||||||
|
@@ -14,20 +14,31 @@ from models import Contact, ContactAddForm, ContactEditForm
|
|||||||
from utils import render_error
|
from utils import render_error
|
||||||
|
|
||||||
from seaserv import ccnet_rpc, ccnet_threaded_rpc
|
from seaserv import ccnet_rpc, ccnet_threaded_rpc
|
||||||
|
from seahub.views import is_registered_user
|
||||||
from seahub.settings import SITE_ROOT
|
from seahub.settings import SITE_ROOT
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def contact_list(request):
|
def contact_list(request):
|
||||||
contacts = Contact.objects.filter(user_email=request.user.username)
|
contacts = Contact.objects.filter(user_email=request.user.username)
|
||||||
|
registered_contacts = []
|
||||||
|
unregistered_contacts = []
|
||||||
|
for c in contacts:
|
||||||
|
if is_registered_user(c.contact_email):
|
||||||
|
registered_contacts.append(c)
|
||||||
|
else:
|
||||||
|
unregistered_contacts.append(c)
|
||||||
|
|
||||||
form = ContactAddForm({'user_email':request.user.username})
|
form = ContactAddForm({'user_email':request.user.username})
|
||||||
edit_init_data = {'user_email':request.user.username,
|
edit_init_data = {'user_email':request.user.username,
|
||||||
'contact_email':'',
|
'contact_email':'',
|
||||||
'contact_name':'',
|
'contact_name':'',
|
||||||
'note':''}
|
'note':''}
|
||||||
edit_form = ContactEditForm(edit_init_data)
|
edit_form = ContactEditForm(edit_init_data)
|
||||||
|
|
||||||
return render_to_response('contacts/contact_list.html', {
|
return render_to_response('contacts/contact_list.html', {
|
||||||
'contacts': contacts,
|
'contacts': contacts,
|
||||||
|
'registered_contacts': registered_contacts,
|
||||||
|
'unregistered_contacts': unregistered_contacts,
|
||||||
'form': form,
|
'form': form,
|
||||||
'edit_form': edit_form,
|
'edit_form': edit_form,
|
||||||
}, context_instance=RequestContext(request))
|
}, context_instance=RequestContext(request))
|
||||||
@@ -43,14 +54,17 @@ def contact_add_post(request):
|
|||||||
|
|
||||||
form = ContactAddForm(request.POST)
|
form = ContactAddForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
|
contact_email = form.cleaned_data['contact_email']
|
||||||
|
|
||||||
contact = Contact()
|
contact = Contact()
|
||||||
contact.user_email = form.cleaned_data['user_email']
|
contact.user_email = form.cleaned_data['user_email']
|
||||||
contact.contact_email = form.cleaned_data['contact_email']
|
contact.contact_email = contact_email
|
||||||
contact.contact_name = form.cleaned_data['contact_name']
|
contact.contact_name = form.cleaned_data['contact_name']
|
||||||
contact.note = form.cleaned_data['note']
|
contact.note = form.cleaned_data['note']
|
||||||
contact.save()
|
contact.save()
|
||||||
|
|
||||||
result['success'] = True
|
result['success'] = True
|
||||||
|
messages.success(request, u"您已成功添加 %s 为联系人" % contact_email)
|
||||||
return HttpResponse(json.dumps(result), content_type=content_type)
|
return HttpResponse(json.dumps(result), content_type=content_type)
|
||||||
else:
|
else:
|
||||||
return HttpResponseBadRequest(json.dumps(form.errors),
|
return HttpResponseBadRequest(json.dumps(form.errors),
|
||||||
@@ -102,6 +116,7 @@ def contact_edit(request):
|
|||||||
contact.note = note
|
contact.note = note
|
||||||
contact.save()
|
contact.save()
|
||||||
result['success'] = True
|
result['success'] = True
|
||||||
|
messages.success(request, u'操作成功')
|
||||||
return HttpResponse(json.dumps(result), content_type=content_type)
|
return HttpResponse(json.dumps(result), content_type=content_type)
|
||||||
else:
|
else:
|
||||||
return HttpResponseBadRequest(json.dumps(form.errors),
|
return HttpResponseBadRequest(json.dumps(form.errors),
|
||||||
@@ -114,5 +129,6 @@ def contact_delete(request):
|
|||||||
contact_email = request.GET.get('email')
|
contact_email = request.GET.get('email')
|
||||||
|
|
||||||
Contact.objects.filter(user_email=user_email, contact_email=contact_email).delete()
|
Contact.objects.filter(user_email=user_email, contact_email=contact_email).delete()
|
||||||
|
messages.success(request, u'删除成功')
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse("contact_list"))
|
return HttpResponseRedirect(reverse("contact_list"))
|
||||||
|
@@ -31,7 +31,9 @@
|
|||||||
|
|
||||||
{% block extra_script %}
|
{% block extra_script %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
{% with groups=org_groups %}
|
||||||
{% include "snippets/myhome_extra_script.html" %}
|
{% include "snippets/myhome_extra_script.html" %}
|
||||||
|
{% endwith %}
|
||||||
|
|
||||||
{% url 'org_repo_create' org.url_prefix as repo_create_url %}
|
{% url 'org_repo_create' org.url_prefix as repo_create_url %}
|
||||||
{% with post_url=repo_create_url %}
|
{% with post_url=repo_create_url %}
|
||||||
|
@@ -109,6 +109,9 @@ def org_personal(request, url_prefix):
|
|||||||
# Org groups user created
|
# Org groups user created
|
||||||
groups = get_org_groups_by_user(org.org_id, user)
|
groups = get_org_groups_by_user(org.org_id, user)
|
||||||
|
|
||||||
|
# All org groups used in auto complete.
|
||||||
|
org_groups = get_org_groups(org.org_id, -1, -1)
|
||||||
|
|
||||||
# Org members used in auto complete
|
# Org members used in auto complete
|
||||||
contacts = []
|
contacts = []
|
||||||
org_members = get_org_users_by_url_prefix(org.url_prefix, 0, MAX_INT)
|
org_members = get_org_users_by_url_prefix(org.url_prefix, 0, MAX_INT)
|
||||||
@@ -123,6 +126,7 @@ def org_personal(request, url_prefix):
|
|||||||
"in_repos": in_repos,
|
"in_repos": in_repos,
|
||||||
'org': org,
|
'org': org,
|
||||||
'groups': groups,
|
'groups': groups,
|
||||||
|
'org_groups': org_groups,
|
||||||
'contacts': contacts,
|
'contacts': contacts,
|
||||||
'create_shared_repo': False,
|
'create_shared_repo': False,
|
||||||
'allow_public_share': True,
|
'allow_public_share': True,
|
||||||
@@ -546,8 +550,8 @@ def org_repo_share(request, url_prefix):
|
|||||||
# TODO: if we know group id, then we can simplly call group_share_repo
|
# TODO: if we know group id, then we can simplly call group_share_repo
|
||||||
group_name = share_to
|
group_name = share_to
|
||||||
|
|
||||||
# get org groups the user joined
|
# Get all org groups.
|
||||||
groups = get_org_groups_by_user(org.org_id, from_email)
|
groups = get_org_groups(org.org_id, -1, -1)
|
||||||
find = False
|
find = False
|
||||||
for group in groups:
|
for group in groups:
|
||||||
# for every group that user joined, if group name and
|
# for every group that user joined, if group name and
|
||||||
|
@@ -165,7 +165,7 @@ GROUP_AVATAR_DEFAULT_URL = 'avatars/groups/default.png'
|
|||||||
AVATAR_MAX_AVATARS_PER_USER = 1
|
AVATAR_MAX_AVATARS_PER_USER = 1
|
||||||
AVATAR_CACHE_TIMEOUT = 24 * 60 * 60
|
AVATAR_CACHE_TIMEOUT = 24 * 60 * 60
|
||||||
AVATAR_ALLOWED_FILE_EXTS = ('.jpg', '.png', '.jpeg', '.gif')
|
AVATAR_ALLOWED_FILE_EXTS = ('.jpg', '.png', '.jpeg', '.gif')
|
||||||
AUTO_GENERATE_AVATAR_SIZES = (16, 28, 48, 60, 80)
|
AUTO_GENERATE_AVATAR_SIZES = (16, 20, 28, 48, 60, 80)
|
||||||
|
|
||||||
CACHES = {
|
CACHES = {
|
||||||
'default': {
|
'default': {
|
||||||
|
12
views.py
12
views.py
@@ -761,8 +761,9 @@ def myhome(request):
|
|||||||
# Personal repos others shared to me
|
# Personal repos others shared to me
|
||||||
in_repos = list_personal_shared_repos(email,'to_email', -1, -1)
|
in_repos = list_personal_shared_repos(email,'to_email', -1, -1)
|
||||||
|
|
||||||
# my contacts
|
# Get registered contacts used in autocomplete.
|
||||||
contacts = Contact.objects.filter(user_email=email)
|
contacts = [ c for c in Contact.objects.filter(user_email=email) \
|
||||||
|
if is_registered_user(c.contact_email) ]
|
||||||
|
|
||||||
# user notifications
|
# user notifications
|
||||||
grpmsg_list = []
|
grpmsg_list = []
|
||||||
@@ -780,10 +781,7 @@ def myhome(request):
|
|||||||
elif n.msg_type == 'org_join_msg':
|
elif n.msg_type == 'org_join_msg':
|
||||||
orgmsg_list.append(n.detail)
|
orgmsg_list.append(n.detail)
|
||||||
|
|
||||||
# Get all personal groups used in autocomplete.
|
# Get all personal groups I joined used in autocomplete.
|
||||||
groups = get_personal_groups(-1, -1)
|
|
||||||
|
|
||||||
# Get all personal groups I joined.
|
|
||||||
joined_groups = get_personal_groups_by_user(request.user.username)
|
joined_groups = get_personal_groups_by_user(request.user.username)
|
||||||
|
|
||||||
# get nickname
|
# get nickname
|
||||||
@@ -807,7 +805,7 @@ def myhome(request):
|
|||||||
"quota_usage": quota_usage,
|
"quota_usage": quota_usage,
|
||||||
"in_repos": in_repos,
|
"in_repos": in_repos,
|
||||||
"contacts": contacts,
|
"contacts": contacts,
|
||||||
"groups": groups,
|
"groups": joined_groups,
|
||||||
"joined_groups": joined_groups,
|
"joined_groups": joined_groups,
|
||||||
"notes": notes,
|
"notes": notes,
|
||||||
"grpmsg_list": grpmsg_list,
|
"grpmsg_list": grpmsg_list,
|
||||||
|
Reference in New Issue
Block a user