From 56ea2dbd664dfa2c0f7676a528adfdd639012fe7 Mon Sep 17 00:00:00 2001 From: zhengxie Date: Sat, 20 Oct 2012 19:43:56 +0800 Subject: [PATCH] Added at complete in file commet --- group/views.py | 36 +++++++++++++++++++++++------------ media/css/seahub.css | 3 ++- media/js/utils.js | 4 ++-- templates/repo_view_file.html | 11 ++++++++++- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/group/views.py b/group/views.py index efb45a0091..5dd3248633 100644 --- a/group/views.py +++ b/group/views.py @@ -943,23 +943,35 @@ def attention(request): if not request.is_ajax(): raise Http404 - try: - gid = int(request.GET.get('gid', '')) - except ValueError: - raise Http404 - - name_str = request.GET.get('name_startsWith') user = request.user.username - - if not is_group_user(gid, user): - raise Http404 - + name_str = request.GET.get('name_startsWith') + gids = request.GET.get('gids', '') result = [] - # Get all group users - members = get_group_members(gid) + + members = [] + for gid in gids.split(','): + try: + gid = int(gid) + except ValueError: + continue + + if not is_group_user(gid, user): + continue + + # Get all group users + members += get_group_members(gid) + + member_names = [] for m in members: if m.user_name == user: continue + + if m.user_name in member_names: + # Remove duplicated member names + continue + else: + member_names.append(m.user_name) + from base.templatetags.seahub_tags import email2nickname, char2pinyin nickname = email2nickname(m.user_name) pinyin = char2pinyin(nickname) diff --git a/media/css/seahub.css b/media/css/seahub.css index a067efd2c5..1b2bb88a8a 100644 --- a/media/css/seahub.css +++ b/media/css/seahub.css @@ -1160,7 +1160,8 @@ ul.with-bg li { border:none; } .msg-bd .recommend, -.msg-bd .at { +.msg-bd .at, +.comment-bd .at { color:#808; } .reply-list { diff --git a/media/js/utils.js b/media/js/utils.js index 6424a26e90..130d2cc469 100644 --- a/media/js/utils.js +++ b/media/js/utils.js @@ -81,7 +81,7 @@ function addAutocomplete(ele_id, container_id, data) { * @param ele_css: {'xx':'xxx'}, styles to be applied to ele_cp * @param container_id: id of autocomplete's container, often container of element above */ -function addAtAutocomplete(ele_id, container_id, gid, aj_url, ele_css) { +function addAtAutocomplete(ele_id, container_id, gids, aj_url, ele_css) { var pos = ''; // cursor position var cursor_at_end; // Boolean. if cursor at the end or in the middle. var end_str = ''; // str after '@' when '@' is inserted into the middle of the ele's value @@ -152,7 +152,7 @@ function addAtAutocomplete(ele_id, container_id, gid, aj_url, ele_css) { url: aj_url, dataType: "json", data: { - gid: gid, + gids: gids, name_startsWith: request_term }, success: function(data) { diff --git a/templates/repo_view_file.html b/templates/repo_view_file.html index fe85e2a8ed..208967f6f9 100644 --- a/templates/repo_view_file.html +++ b/templates/repo_view_file.html @@ -160,7 +160,7 @@
{% avatar request.user.username 48 %} -
+

@@ -201,6 +201,15 @@ $('#view-original, #download').click(function() { window.open($(this).attr('data')); }); {% if not view_history %} + +$(function() { + var gids = ''; + {% for g in groups %} + gids = gids + '{{ g.id }}' + ','; + {% endfor %} + addAtAutocomplete('#comment-input', '#comment-container', gids, "{% url 'group_attention' %}", {'width':'315px','max-width':'315px','padding-left':'1px','height':'36px','margin':'0','line-height': '1.5em'}); // remember to add unit (px or em) to line-height, as js in ie will take 1.5 as 1.5, not 1.5em +}); + $('#edit, #update').click(function() { location.href = $(this).attr('data'); });