From 37b0e03df52471a2a42a8fa90b69657c4f6a4339 Mon Sep 17 00:00:00 2001 From: llj Date: Thu, 21 Feb 2013 19:59:58 +0800 Subject: [PATCH 1/2] rewrote pubinfo --- media/css/seahub.css | 61 ++++++++++++++-- templates/myhome_base.html | 2 +- templates/pubgrp.html | 38 ++++++++++ templates/pubinfo.html | 113 ------------------------------ templates/pubrepo.html | 77 ++++++++++++++++++++ templates/pubuser.html | 34 +++++++++ templates/registration/login.html | 31 ++++---- templates/snippets/pubinfo.html | 9 +++ urls.py | 4 +- views.py | 38 +++++++--- 10 files changed, 260 insertions(+), 147 deletions(-) create mode 100644 templates/pubgrp.html delete mode 100644 templates/pubinfo.html create mode 100644 templates/pubrepo.html create mode 100644 templates/pubuser.html create mode 100644 templates/snippets/pubinfo.html diff --git a/media/css/seahub.css b/media/css/seahub.css index 0b759c1b70..79509f6948 100644 --- a/media/css/seahub.css +++ b/media/css/seahub.css @@ -11,10 +11,13 @@ form,input,textarea,button,img { } body, input, textarea, button, select { - font: 13px/19px Arial, Helvetica, sans-serif;/* 19px : for ff*/ + font: 13px/1.5 Arial, Helvetica, sans-serif; color: #333; word-wrap:break-word; /* for en */ } +input, button, select { + line-height:19px;/*for ff*/ +} h1 { font-size:1.9em; margin:1.1em 0 0.5em; @@ -303,7 +306,33 @@ textarea:-moz-placeholder {/* for FF */ .center-contents { text-align: center; } - +.tabnav { + height:37px; + border-bottom:1px solid #ddd; +} +.tabnav-tabs { + display:inline-block; +} +.tabnav-tab { + display:inline-block; + font-size:14px; + padding:8px 10px; + border:1px solid transparent; + border-bottom:0; +} +.tabnav-tab a { + color:#666; + font-weight:normal; +} +.tabnav-tab a:hover { +} +.tabnav-tab-cur { + font-weight:bold; + border-color:#ddd; + border-radius:3px 3px 0 0; + background:#fff; + margin-bottom:-1px; +} /* container */ #main, #footer { width:950px; } #main { margin:0 auto; } @@ -1180,19 +1209,23 @@ textarea:-moz-placeholder {/* for FF */ height:80px; } /* group, org */ -.group-list { - margin-top:20px; +.group-list, +.user-list { + margin-top:30px; } -.group-list .group { +.group-list .group, +.user-list .user { display:inline-block; /*to handle different height of items*/ vertical-align:top; width:315px; margin:0 17px 25px 0; } -.group-list .group { +.group-list .group, +.user-list .user { *display:inline; /* for ie 6,7 */ } -.group .txt { +.group .txt, +.user-list .user .txt { color:#333; width:250px; } @@ -1746,3 +1779,17 @@ textarea:-moz-placeholder {/* for FF */ .diff-chg { color: #c3f; } +.pubinfo-item { + display:inline-block; + min-width:66px; +} +.pubinfo-item .amount { + font-size:28px; + line-height:1; + font-weight:bold; + color:#222; +} +.pubinfo-item .obj { + font-size:11px; + color:#999; +} diff --git a/templates/myhome_base.html b/templates/myhome_base.html index 0f4e8dab80..8eda7a0196 100644 --- a/templates/myhome_base.html +++ b/templates/myhome_base.html @@ -18,7 +18,7 @@ {% if not cloud_mode %}
  • - {% trans "Public Info" %} + {% trans "Public Info" %}
  • {% endif %} diff --git a/templates/pubgrp.html b/templates/pubgrp.html new file mode 100644 index 0000000000..1da8c7c6d5 --- /dev/null +++ b/templates/pubgrp.html @@ -0,0 +1,38 @@ +{% extends "myhome_base.html" %} +{% load seahub_tags avatar_tags group_avatar_tags i18n %} +{% load url from future %} + +{% block nav_pubinfo_class %}class="cur"{% endblock %} + +{% block left_panel %} +{% include 'snippets/pubinfo.html' %} +{% endblock %} + +{% block right_panel %} +
    + +
    +{% if groups %} + +{% else %} +
    +

    {% trans "No one has created any groups yet" %}

    +

    {% blocktrans %}You can click "Add Group" button under "Group" label to create a group. {% endblocktrans %}

    +
    +{% endif %} +{% endblock %} diff --git a/templates/pubinfo.html b/templates/pubinfo.html deleted file mode 100644 index b054ee0867..0000000000 --- a/templates/pubinfo.html +++ /dev/null @@ -1,113 +0,0 @@ -{% extends "myhome_base.html" %} -{% load seahub_tags avatar_tags group_avatar_tags i18n %} -{% load url from future %} - -{% block nav_pubinfo_class %}class="cur"{% endblock %} - -{% block left_panel %} -

    {% trans "Users" %}

    -{% if users %} - -{% include "snippets/user_profile_html.html" %} -{% else %} -

    {% trans "None"%}

    -{% endif %} -{% endblock %} - -{% block right_panel %} -

    {% trans "Libraries & Groups" %}

    -
    -
    - - -
    -
    - {% if public_repos %} - - - - - - - - - - {% for repo in public_repos %} - - - - - - - - - {% endfor %} -
    {% trans "Name"%}{% trans "Description"%}{% trans "Last Update"%}{% trans "Share From"%}{% trans "Operations"%}
    - {% if repo.user_perm == 'rw' %} - {% trans - {% else %} - {% trans - {% endif %} - {{ repo.props.repo_name }}{{ repo.props.repo_desc }}{% if repo.props.last_modified %}{{ repo.props.last_modified|translate_seahub_time }}{% else %}--{% endif %}{{ repo.props.user|email2nickname }} - {% trans -
    - {% else %} -
    -

    {% trans "No public library" %}

    -

    {% blocktrans %}You can create a public library by clicking "New Library" button, others can view and download this library.{% endblocktrans %}

    -
    - {% endif %} - {% include "snippets/repo_create_form.html" %} -
    -
    - {% if groups %} - - {% else %} -
    -

    {% trans "No one has created any groups yet" %}

    -

    {% blocktrans %}You can click "Add Group" button under "Group" label to create a group. {% endblocktrans %}

    -
    - {% endif %} -
    -
    -{% endblock %} - -{% block extra_script %} -{% include "snippets/user_profile_js.html" %} - -{% endblock %} diff --git a/templates/pubrepo.html b/templates/pubrepo.html new file mode 100644 index 0000000000..30186cbdfe --- /dev/null +++ b/templates/pubrepo.html @@ -0,0 +1,77 @@ +{% extends "myhome_base.html" %} +{% load seahub_tags avatar_tags group_avatar_tags i18n %} +{% load url from future %} + +{% block nav_pubinfo_class %}class="cur"{% endblock %} + +{% block left_panel %} +{% include 'snippets/pubinfo.html' %} +{% endblock %} + +{% block right_panel %} +
    + + +
    +{% if public_repos %} + + + + + + + + + + {% for repo in public_repos %} + + + + + + + + + {% endfor %} +
    {% trans "Name"%}{% trans "Description"%}{% trans "Last Update"%}{% trans "Share From"%}{% trans "Operations"%}
    + {% if repo.user_perm == 'rw' %} + {% trans + {% else %} + {% trans + {% endif %} + {{ repo.props.repo_name }}{{ repo.props.repo_desc }}{% if repo.props.last_modified %}{{ repo.props.last_modified|translate_seahub_time }}{% else %}--{% endif %}{{ repo.props.user|email2nickname }} + {% trans +
    +{% else %} +
    +

    {% trans "No public library" %}

    +

    {% blocktrans %}You can create a public library by clicking "New Library" button, others can view and download this library.{% endblocktrans %}

    +
    +{% endif %} +{% include "snippets/repo_create_form.html" %} +{% endblock %} + +{% block extra_script %} + +{% endblock %} diff --git a/templates/pubuser.html b/templates/pubuser.html new file mode 100644 index 0000000000..e74c956f1c --- /dev/null +++ b/templates/pubuser.html @@ -0,0 +1,34 @@ +{% extends "myhome_base.html" %} +{% load seahub_tags avatar_tags group_avatar_tags i18n %} +{% load url from future %} + +{% block nav_pubinfo_class %}class="cur"{% endblock %} + +{% block left_panel %} +{% include 'snippets/pubinfo.html' %} +{% endblock %} + +{% block right_panel %} +
    + +
    +{% if users %} + +{% else %} +

    {% trans "None"%}

    +{% endif %} +{% endblock %} diff --git a/templates/registration/login.html b/templates/registration/login.html index c306d92f33..4c6a1cc691 100644 --- a/templates/registration/login.html +++ b/templates/registration/login.html @@ -9,14 +9,14 @@ + + {% if form.errors %} +

    {% trans "Incorrect email or password" %}

    + {% else %}

    + {% endif %} {% trans "Forgot password?" %} -{% if next %} - -{% else %} - -{% endif %} {% endblock %} @@ -24,17 +24,14 @@ {% block extra_script %} {% endblock %} diff --git a/templates/snippets/pubinfo.html b/templates/snippets/pubinfo.html new file mode 100644 index 0000000000..d33f91de51 --- /dev/null +++ b/templates/snippets/pubinfo.html @@ -0,0 +1,9 @@ +{% load i18n %} +
    +

    {% trans "Organization Info"%}

    + +
    diff --git a/urls.py b/urls.py index de82d587b5..cdd99be45b 100644 --- a/urls.py +++ b/urls.py @@ -114,7 +114,9 @@ if CLOUD_MODE: ) else: urlpatterns += patterns('', - (r'^pubinfo/$', pubinfo), + url(r'^pubinfo/libraries/$', pubrepo, name='pubrepo'), (r'^publicrepo/create/$', public_repo_create), + url(r'^pubinfo/groups/$', pubgrp, name='pubgrp'), + url(r'^pubinfo/users/$', pubuser, name='pubuser'), ) diff --git a/views.py b/views.py index 000b53811c..6610b78cde 100644 --- a/views.py +++ b/views.py @@ -2736,24 +2736,46 @@ def demo(request): return HttpResponseRedirect(redirect_to) @login_required -def pubinfo(request): +def pubrepo(request): """ - Show public information. + Show public libraries. """ if request.cloud_mode: # Users are not allowed to see public information when in cloud mode. raise Http404 else: public_repos = list_inner_pub_repos(request.user.username) - groups = get_personal_groups(-1, -1) - users = get_emailusers(-1, -1) - return render_to_response('pubinfo.html', { - 'groups': groups, - 'users': users, + return render_to_response('pubrepo.html', { 'public_repos': public_repos, 'create_shared_repo': True, }, context_instance=RequestContext(request)) - + +def pubgrp(request): + """ + Show public groups. + """ + if request.cloud_mode: + # Users are not allowed to see public information when in cloud mode. + raise Http404 + else: + groups = get_personal_groups(-1, -1) + return render_to_response('pubgrp.html', { + 'groups': groups, + }, context_instance=RequestContext(request)) + +def pubuser(request): + """ + Show public users. + """ + if request.cloud_mode: + # Users are not allowed to see public information when in cloud mode. + raise Http404 + else: + users = get_emailusers(-1, -1) + return render_to_response('pubuser.html', { + 'users': users, + }, context_instance=RequestContext(request)) + def repo_set_password(request): content_type = 'application/json; charset=utf-8' From 7f887be89f637da80c90f417d4e06945e99896cb Mon Sep 17 00:00:00 2001 From: zhengxie Date: Fri, 22 Feb 2013 14:52:33 +0800 Subject: [PATCH 2/2] Added repos/groups/users count --- templates/snippets/pubinfo.html | 6 +++--- thirdpart/seaserv/__init__.py | 4 ++-- thirdpart/seaserv/service.py | 14 ++++++++++++++ views.py | 23 ++++++++++++++++++++++- 4 files changed, 41 insertions(+), 6 deletions(-) diff --git a/templates/snippets/pubinfo.html b/templates/snippets/pubinfo.html index d33f91de51..7f1cae0c50 100644 --- a/templates/snippets/pubinfo.html +++ b/templates/snippets/pubinfo.html @@ -2,8 +2,8 @@

    {% trans "Organization Info"%}

      -
    • 0
      {% trans 'Libraries' %}
    • -
    • 0
      {% trans 'Groups' %}
    • -
    • 0
      {% trans 'Users' %}
    • +
    • {{ pubrepos_count }}
      {% trans 'Libraries' %}
    • +
    • {{ groups_count }}
      {% trans 'Groups' %}
    • +
    • {{ emailusers_count}}
      {% trans 'Users' %}
    diff --git a/thirdpart/seaserv/__init__.py b/thirdpart/seaserv/__init__.py index abd71b8111..c67eb3a4af 100644 --- a/thirdpart/seaserv/__init__.py +++ b/thirdpart/seaserv/__init__.py @@ -3,7 +3,7 @@ import service from service import ccnet_rpc, monitor_rpc, seafserv_rpc, \ seafserv_threaded_rpc, ccnet_threaded_rpc from service import send_command, check_quota, web_get_access_token, unset_repo_passwd -from service import get_emailusers, get_session_info +from service import get_emailusers, count_emailusers, get_session_info from service import get_org_groups, get_personal_groups_by_user, \ get_group_repoids, get_personal_groups, \ check_group_staff, remove_group_user, get_group, get_org_id_by_group, \ @@ -16,7 +16,7 @@ from service import get_repos, get_repo, get_commits, get_branches, remove_repo, list_personal_shared_repos, is_personal_repo, list_inner_pub_repos, \ is_org_repo_owner, get_org_repo_owner, is_org_repo, get_file_size,\ list_personal_repos_by_owner, get_repo_token_nonnull, get_repo_owner, \ - server_repo_size, get_file_id_by_path, get_commit, \ + server_repo_size, get_file_id_by_path, get_commit, count_inner_pub_repos,\ get_repo_history_limit, set_repo_history_limit from service import get_binding_peerids, is_valid_filename, check_permission,\ diff --git a/thirdpart/seaserv/service.py b/thirdpart/seaserv/service.py index bf3767a208..a56a36d018 100644 --- a/thirdpart/seaserv/service.py +++ b/thirdpart/seaserv/service.py @@ -153,6 +153,13 @@ def get_emailusers(start, limit): users = [] return users +def count_emailusers(): + try: + ret = ccnet_threaded_rpc.count_emailusers() + except SearpcError: + ret = 0 + return ret + def get_session_info(): return ccnet_rpc.get_session_info() @@ -627,6 +634,13 @@ def list_inner_pub_repos(username): shared_repos.sort(lambda x, y: cmp(y.props.last_modified, x.props.last_modified)) return shared_repos +def count_inner_pub_repos(): + try: + ret = seafserv_threaded_rpc.count_inner_pub_repos() + except SearpcError: + ret = 0 + return ret + def is_inner_pub_repo(repo_id): """ Check whether a repo is public. diff --git a/views.py b/views.py index 6610b78cde..4893936448 100644 --- a/views.py +++ b/views.py @@ -47,7 +47,8 @@ from seaserv import ccnet_rpc, ccnet_threaded_rpc, get_repos, get_emailusers, \ get_related_users_by_repo, get_related_users_by_org_repo, HtmlDiff, \ get_session_info, get_group_repoids, get_repo_owner, get_file_id_by_path, \ get_repo_history_limit, set_repo_history_limit, MAX_UPLOAD_FILE_SIZE, \ - get_commit, MAX_DOWNLOAD_DIR_SIZE, CALC_SHARE_USAGE + get_commit, MAX_DOWNLOAD_DIR_SIZE, CALC_SHARE_USAGE, count_emailusers, \ + count_inner_pub_repos from pysearpc import SearpcError from signals import repo_created, repo_deleted @@ -2745,11 +2746,18 @@ def pubrepo(request): raise Http404 else: public_repos = list_inner_pub_repos(request.user.username) + pubrepos_count = len(public_repos) + groups_count = len(get_personal_groups(-1, -1)) + emailusers_count = count_emailusers() return render_to_response('pubrepo.html', { 'public_repos': public_repos, 'create_shared_repo': True, + 'pubrepos_count': pubrepos_count, + 'groups_count': groups_count, + 'emailusers_count': emailusers_count, }, context_instance=RequestContext(request)) +@login_required def pubgrp(request): """ Show public groups. @@ -2759,10 +2767,17 @@ def pubgrp(request): raise Http404 else: groups = get_personal_groups(-1, -1) + pubrepos_count = count_inner_pub_repos() + groups_count = len(groups) + emailusers_count = count_emailusers() return render_to_response('pubgrp.html', { 'groups': groups, + 'pubrepos_count': pubrepos_count, + 'groups_count': groups_count, + 'emailusers_count': emailusers_count, }, context_instance=RequestContext(request)) +@login_required def pubuser(request): """ Show public users. @@ -2772,8 +2787,14 @@ def pubuser(request): raise Http404 else: users = get_emailusers(-1, -1) + pubrepos_count = count_inner_pub_repos() + groups_count = len(get_personal_groups(-1, -1)) + emailusers_count = count_emailusers() return render_to_response('pubuser.html', { 'users': users, + 'pubrepos_count': pubrepos_count, + 'groups_count': groups_count, + 'emailusers_count': emailusers_count, }, context_instance=RequestContext(request)) def repo_set_password(request):