diff --git a/media/js/base.js b/media/js/base.js index cb34a61f88..b0eff2640f 100644 --- a/media/js/base.js +++ b/media/js/base.js @@ -24,7 +24,7 @@ $('#top-nav-grp').click(function() { return false; }); -$(document).ready(function(){ +$(function(){ var msg_ct = $("#msg-count"); $.ajax({ url: msg_ct.data('cturl'), diff --git a/seahub/templates/my_group_repos.html b/seahub/templates/snippets/my_group_repos.html similarity index 96% rename from seahub/templates/my_group_repos.html rename to seahub/templates/snippets/my_group_repos.html index c2b0903ded..d2d3e30353 100644 --- a/seahub/templates/my_group_repos.html +++ b/seahub/templates/snippets/my_group_repos.html @@ -1,4 +1,4 @@ -{% load seahub_tags group_avatar_tags i18n %}
+{% load seahub_tags group_avatar_tags i18n %} {% if group_repos %} @@ -47,4 +47,3 @@

{% trans "No library is shared to your groups" %}

{% endif %} - diff --git a/seahub/templates/snippets/my_owned_repos.html b/seahub/templates/snippets/my_owned_repos.html index 9ad56fb054..defda67015 100644 --- a/seahub/templates/snippets/my_owned_repos.html +++ b/seahub/templates/snippets/my_owned_repos.html @@ -7,8 +7,8 @@ {% if ENABLE_SUB_LIBRARY and sub_lib_enabled %}
  • {% trans "Sub-libraries" %}
  • {% endif %} -
  • {% trans "Shared" %}
  • -
  • {% trans "Group" %}
  • +
  • {% trans "Shared" %}
  • +
  • {% trans "Group" %}
  • @@ -106,6 +106,9 @@ {% endif %} +
    +
    +
    diff --git a/seahub/templates/my_shared_repos.html b/seahub/templates/snippets/my_shared_repos.html similarity index 79% rename from seahub/templates/my_shared_repos.html rename to seahub/templates/snippets/my_shared_repos.html index fa36d25417..a963f5b38d 100644 --- a/seahub/templates/my_shared_repos.html +++ b/seahub/templates/snippets/my_shared_repos.html @@ -1,5 +1,4 @@ {% load seahub_tags i18n %} -
    {% if shared_repos %}
    @@ -49,27 +48,3 @@

    {% trans "No library is shared to you" %}

    {% endif %} - - - - diff --git a/seahub/templates/snippets/myhome_extra_script.html b/seahub/templates/snippets/myhome_extra_script.html index 20e6aa2e0d..80f7dc5b95 100644 --- a/seahub/templates/snippets/myhome_extra_script.html +++ b/seahub/templates/snippets/myhome_extra_script.html @@ -90,9 +90,6 @@ $(function () { disable($(this)); }); - $('.unshare-btn').click(function() { - location.href = $(this).data('url'); - }); {% include 'snippets/repo_del_js.html' %} @@ -123,3 +120,29 @@ function repoCreateSuccessCallback(data) { $('tr:first', my_own_repos).after(new_repo_item); } } + +$(function() { + $.ajax({ + url:'{% url 'my_shared_and_group_repos' %}', + cache: false, + dataType: 'json', + success: function(data) { + $('#repos-shared-to-me').html(data['shared']); + $('#group-repos').html(data['group']); + $('.unshare-btn').click(function() { + location.href = $(this).data('url'); + }); + $("tr:gt(0)", $('table')).unbind().hover( + function() { + $(this).addClass('hl'); + $(this).find('.op-icon').removeClass('vh'); + }, + function() { + $(this).find('.op-icon').addClass('vh'); + $(this).removeClass('hl'); + } + ); + $('#tabs').unbind().tabs({cookie:{expires:1}}); + } + }); +}); diff --git a/seahub/urls.py b/seahub/urls.py index cb22af7543..88e585a442 100644 --- a/seahub/urls.py +++ b/seahub/urls.py @@ -148,8 +148,7 @@ urlpatterns = patterns('', url(r'^ajax/upload-file-done/$', upload_file_done, name='upload_file_done'), url(r'^ajax/unseen-notices-count/$', unseen_notices_count, name='unseen_notices_count'), url(r'^ajax/space_and_traffic/$', space_and_traffic, name='space_and_traffic'), - url(r'^ajax/my-shared-repos/$', my_shared_repos, name='my_shared_repos'), - url(r'^ajax/my-group-repos/$', my_group_repos, name='my_group_repos'), + url(r'^ajax/my-shared-and-group-repos/$', my_shared_and_group_repos, name='my_shared_and_group_repos'), ### Apps ### diff --git a/seahub/views/ajax.py b/seahub/views/ajax.py index dcdc64779f..91fa502803 100644 --- a/seahub/views/ajax.py +++ b/seahub/views/ajax.py @@ -1213,8 +1213,8 @@ def space_and_traffic(request): return HttpResponse(json.dumps({"html": html}), content_type=content_type) @login_required -def my_shared_repos(request): - """Return html snippet of repos that shared to user. +def my_shared_and_group_repos(request): + """Return html snippet of repos that shared to user and group repos. Arguments: - `request`: @@ -1222,31 +1222,13 @@ def my_shared_repos(request): if not request.is_ajax(): raise Http404 + content_type = 'application/json; charset=utf-8' + username = request.user.username shared_repos = seafile_api.get_share_in_repo_list(username, -1, -1) shared_repos.sort(lambda x, y: cmp(y.last_modified, x.last_modified)) - ctx = { - "shared_repos": shared_repos, - } - html = render_to_string('my_shared_repos.html', ctx, - context_instance=RequestContext(request)) - - return HttpResponse(html) - -@login_required -def my_group_repos(request): - """Return html snippet of group repos. - - Arguments: - - `request`: - """ - if not request.is_ajax(): - raise Http404 - - username = request.user.username - group_repos = [] # Get all personal groups I joined. joined_groups = request.user.joined_groups @@ -1280,11 +1262,17 @@ def my_group_repos(request): if repo.group.group_name != group_repos[i-1].group.group_name: repo.show_group_name = True - ctx = { + + ctx_shared = { + "shared_repos": shared_repos, + } + ctx_group = { "group_repos": group_repos, } - html = render_to_string('my_group_repos.html', ctx, + shared_repos_html = render_to_string('snippets/my_shared_repos.html', ctx_shared, + context_instance=RequestContext(request)) + group_repos_html = render_to_string('snippets/my_group_repos.html', ctx_group, context_instance=RequestContext(request)) - return HttpResponse(html) - + return HttpResponse(json.dumps({"shared": shared_repos_html, "group": group_repos_html}), + content_type=content_type)