diff --git a/seahub/forms.py b/seahub/forms.py index 8eed7d8239..822173af79 100644 --- a/seahub/forms.py +++ b/seahub/forms.py @@ -146,9 +146,6 @@ class RepoPassowrdForm(forms.Form): except SearpcError, e: if e.msg == 'Bad arguments': raise forms.ValidationError(_(u'Bad url format')) - # elif e.msg == 'Repo is not encrypted': - # return HttpResponseRedirect(reverse('repo', - # args=[self.repo_id])) elif e.msg == 'Incorrect password': raise forms.ValidationError(_(u'Wrong password')) elif e.msg == 'Internal server error': diff --git a/seahub/notifications/management/commands/send_notices.py b/seahub/notifications/management/commands/send_notices.py index d1578bdcf3..afe4236d3d 100644 --- a/seahub/notifications/management/commands/send_notices.py +++ b/seahub/notifications/management/commands/send_notices.py @@ -124,7 +124,7 @@ class Command(BaseCommand): if repo is None: notice.delete() - notice.repo_url = reverse('repo', args=[repo.id]) + notice.repo_url = reverse("view_common_lib_dir", args=[repo_id, '/']) notice.notice_from = escape(email2nickname(d['share_from'])) notice.repo_name = repo.name notice.avatar_src = self.get_avatar_src(d['share_from']) @@ -138,7 +138,7 @@ class Command(BaseCommand): uploaded_to = d['uploaded_to'].rstrip('/') file_path = uploaded_to + '/' + file_name file_link = reverse('view_lib_file', args=[repo_id, urlquote(file_path)]) - folder_link = reverse('repo', args=[repo_id]) + '?p=' + urlquote(uploaded_to) + folder_link = reverse('view_common_lib_dir', args=[repo_id, urlquote(uploaded_to).strip('/')]) folder_name = os.path.basename(uploaded_to) notice.file_link = file_link diff --git a/seahub/share/views.py b/seahub/share/views.py index a30d8ea11a..d54a28c618 100644 --- a/seahub/share/views.py +++ b/seahub/share/views.py @@ -716,88 +716,6 @@ def share_permission_admin(request): else: return HttpResponse(json.dumps({'success': False}), status=400, content_type=content_type) - -# 2 views for anonymous share: -# - anonymous_share records share infomation to db and sends the mail -# - anonymous_share_confirm checks the link use clicked and -# adds token to client COOKIE, then redirect client to repo page - -# def anonymous_share(request, email_template_name='repo/anonymous_share_email.html', **kwargs): -# repo_id = kwargs['repo_id'] -# repo_owner = kwargs['repo_owner'] -# anon_email = kwargs['anon_email'] -# is_encrypted = kwargs['is_encrypted'] - -# # Encrypt repo can not be shared to unregistered user. -# if is_encrypted: -# msg = _(u'Failed to share to %s, as encrypted libraries cannot be shared to emails outside the site.') % anon_email -# messages.error(request, msg) -# return - -# token = anon_share_token_generator.make_token() - -# anon_share = AnonymousShare() -# anon_share.repo_owner = repo_owner -# anon_share.repo_id = repo_id -# anon_share.anonymous_email = anon_email -# anon_share.token = token - -# try: -# anon_share.save() -# except: -# msg = _(u'Failed to share to %s.') % anon_email -# messages.add_message(request, messages.ERROR, msg) -# else: -# # send mail -# use_https = request.is_secure() -# site_name = domain = RequestSite(request).domain - -# t = loader.get_template(email_template_name) -# c = { -# 'email': repo_owner, -# 'anon_email': anon_email, -# 'domain': domain, -# 'site_name': site_name, -# 'token': token, -# 'protocol': use_https and 'https' or 'http', -# } - -# try: -# send_mail(_(u'You are shared with a library in Seafile'), t.render(Context(c)), None, -# [anon_email], fail_silently=False) -# except: -# AnonymousShare.objects.filter(token=token).delete() -# msg = _(u'Failed to share to %s.') % anon_email -# messages.add_message(request, messages.ERROR, msg) -# else: -# msg = _(u'Shared to %(email)s successfully, go check it at Share.') % \ -# {'email':anon_email, 'share':reverse('share_admin')} -# messages.add_message(request, messages.INFO, msg) - -# def anonymous_share_confirm(request, token=None): -# assert token is not None # checked by URLconf - -# # Check whether token in db -# try: -# anon_share = AnonymousShare.objects.get(token=token) -# except AnonymousShare.DoesNotExist: -# raise Http404 -# else: -# res = HttpResponseRedirect(reverse('repo', args=[anon_share.repo_id])) -# res.set_cookie("anontoken", token, -# max_age=ANONYMOUS_SHARE_COOKIE_TIMEOUT) -# return res - -# def remove_anonymous_share(request, token): -# AnonymousShare.objects.filter(token=token).delete() - -# next = request.META.get('HTTP_REFERER', None) -# if not next: -# next = reverse('share_admin') - -# messages.add_message(request, messages.INFO, _(u'Deleted successfully.')) - -# return HttpResponseRedirect(next) ########## share link @login_required_ajax diff --git a/seahub/templates/repo.html b/seahub/templates/repo.html deleted file mode 100644 index 6952568c27..0000000000 --- a/seahub/templates/repo.html +++ /dev/null @@ -1,2375 +0,0 @@ -{% extends "myhome_base.html" %} - -{% load seahub_tags avatar_tags i18n upload_tags %} - -{% block sub_title %}{{repo.name}} - {% endblock %} -{% block extra_style %} - - - - -{% endblock %} - -{% block main_panel %} -
-

{{repo.props.name}}{% if user_perm == 'r' %} ({% trans "Read-Only" %}){% endif %}

-
- {{ repo.props.desc|truncatechars:25 }} - {% trans 'Size: ' %}{{ repo_size|filesizeformat }} - {% if show_repo_download_button or show_repo_settings or user_perm == 'rw' %} - - {% if show_repo_download_button %} - {% trans "Download" %} - {% endif %} - {% if show_repo_settings %} - {% trans "Settings" %} - {% endif %} - {% if user_perm == 'rw' %} - {% trans "Trash"%} - {% endif %} - - {% endif %} -
-
- - {% if repo.enc_version == 2 and not server_crypto and repo.encrypted %} -
- {% else %} -
- {% include 'snippets/repo_dir_data.html' %} -
- {% endif %} - - - {% if user_perm == 'rw' %} -
- - - -
- {% endif %} - -
- {% if no_quota %} -

{% trans "Upload Files" %}

-

{% trans "The owner of this library has run out of space." %}

- - {% else %} - - {% if repo.enc_version == 2 and not server_crypto and repo.encrypted %} -
{% csrf_token %} -

{% trans "Upload Files" %}

-
-

{% trans "Please select a file at first." %}

- -
- - {% else %} -

{% trans "File Upload" %}

-
- - close -
-
-
- -
-

- - {% trans "Saving..." %} -

-
-
- {% endif %} - {% endif %} -
- -
-

{% trans "Update %(file_name)s" %}

- {% if no_quota %} -

{% trans "The owner of this library has run out of space." %}

- {% else %} -
{% csrf_token %} - - - {% if repo.enc_version == 2 and not server_crypto and repo.encrypted %} -
-

{% trans "Please select a file at first." %}

- - {% else %} - -
- - {% trans "Choose a file" %} - - - {% if max_upload_file_size %} - ({% blocktrans with max_file_size=max_upload_file_size|filesizeformat %}Smaller than {{ max_file_size }}{% endblocktrans %}) - {% endif %} -
-
-
-
-
-
-

- - {% trans "Saving..." %} -

-
-
- {% endif %} -
- {% endif %} -
- -
{% csrf_token %} -

{% trans "New Directory" %}

-
-
-

- - -
- -
{% csrf_token %} -

{% trans "New File" %}

- -
-
-

- - -
- -
{% csrf_token %} -
-
{% trans "Current Library"%}
- -
- {% if not repo.encrypted %} -
{% trans "Other Libraries"%}
- -
- {% endif %} -
- - - - - -

{% trans "Please click and choose a directory."%}

- - -
- -
-

-
-

- -
- -
{% csrf_token %} -

{% trans "Rename %(name)s as:" %}

- -
-

- - -
- - {% include "snippets/file_share_popup.html" %} - - {% with attach_type='dir' %} - {% include "snippets/group_recommend_form.html" %} - {% endwith %} - - {% if repo.enc_version == 2 and not server_crypto and repo.encrypted %} -
-

{% trans "This library is encrypted. Please input the password if you want to browse it online. And the password will be kept in the browser for only 1 hour." %}

- - - -

- {% url 'edit_profile' as profile_edit_url %} -

{% blocktrans %}You can change how to view encrypted libraries online here.{% endblocktrans %}

-
- {% endif %} - -
- -
- - {% if groups|length > 1 %} -
-

{% trans "Groups" %}

- {{ repo_group_str }} -
-
- {% endif %} - -{% endblock %} - -{% block extra_script %} -{% if repo.enc_version == 2 and not server_crypto and repo.encrypted %} - -{% else %} - {% if not no_quota and user_perm == 'rw' %} -{% upload_js %} - -{% endif %} -{% endif %} - -{% endblock %} diff --git a/seahub/templates/snippets/bottom_bar.html b/seahub/templates/snippets/bottom_bar.html deleted file mode 100644 index 127a7100ab..0000000000 --- a/seahub/templates/snippets/bottom_bar.html +++ /dev/null @@ -1,161 +0,0 @@ -{% load i18n %} -{% load url from future %} - -// set 'side toolbar' & 'groups' popup position -function setToolbarPos() { - var toolbar = $('#side-toolbar'); - - // set toolbar pos - toolbar.css({'top': ($(window).height() - toolbar.outerHeight())/2}); - - // set 'groups' popup position - $('#to-group').css({'top': parseInt(toolbar.css('top')) + 59}); -} -$(window).load(function() { - var to_top = $(''); - to_top.click(function() { - $(window).scrollTop(0); - }).appendTo($('#side-toolbar')); - $(window).scroll(function() { - if ($(window).scrollTop() > 0) { - to_top.show(); - } else { - to_top.hide(); - } - }); - setToolbarPos(); -}).resize(setToolbarPos); - - -{% if groups %} -function getAndHandleDiscussions(data_html) { - $('#discussions-to-grp').html(data_html).css({'max-height': parseInt($(window).height() * 0.8 - $('#discuss-to-group-form').outerHeight())}).removeClass('hide'); // 'parseInt' to fix '.msg-main top border missing when the ul's max-height is xxx.5px' - var popup = $('#discuss-to-group'); - popup.css({'top':($(window).height() - popup.outerHeight())/2}); - {% include 'group/msg_js.html' %} -} -$('#discuss').click(function() { - var popup = $('#discuss-to-group'), - form = $('#discuss-to-group-form'), - path = '{{ path }}'; - - // for repo.html: when get dir data with ajax - if ($('#repo-file-list').length > 0) { - path = cur_path; - $('[name="path"]', form).val(path); - // modify attachment dir name - $('.att-name', form).html($('#cur-dir-name').html()); - } - - if (popup.hasClass('hide')) { - $.ajax({ - url: form.attr('action'), - dataType: 'json', - data: { - 'repo_id': '{{ repo.id }}', - 'path': path - }, - success: function(data) { - getAndHandleDiscussions(data['html']); - popup.removeClass('hide'); - }, - error: function(jqXHR, textStatus, errorThrown) { - var err_str = ''; - if (jqXHR.responseText) { - err_str = $.parseJSON(jqXHR.responseText).error; - feedback(err_str, 'error'); - } - } - }); - } else { - popup.addClass('hide'); - } -}); - -// click 'close' to close discuss popup -$('#discuss-to-group .close').click(function () { - $('#discuss-to-group').addClass('hide'); -}); - -$(document).click(function(e) { - var target = e.target || event.srcElement; - if (!$('#discuss, #discuss-to-group').is(target) && !($('#discuss, #discuss-to-group').find('*').is(target))) { - $('#discuss-to-group').addClass('hide'); - } -}); - -$('#discuss-submit').click(function() { - var form = $('#discuss-to-group-form'), - form_id = form.attr('id'); - - if (form.find('.checkbox-checked').length == 0) { - apply_form_error(form_id, "{% trans "Please select at least 1 group." %}"); - return false; - } - - if (!$.trim($('#discuss-to-group-form .input').val())) { - apply_form_error(form_id, "{% trans "Please input a discussion." %}"); - return false; - } - form.find('.error').addClass('hide'); - - var groups = []; - form.find('.checkbox-checked .checkbox-orig').each(function() { - groups.push($(this).val()); - }); - - $.ajax({ - url: form.attr('action'), - type: 'POST', - dataType: 'json', - beforeSend: prepareCSRFToken, - traditional: true, - data: { - 'groups': groups, - 'message': $('[name="message"]', form).val(), - 'repo_id': '{{ repo.id }}', - 'path': $('[name="path"]', form).val(), - 'attach_type': $('[name="attach_type"]', form).val() - }, - success: function(data) { - if(data['success']) { - feedback(data['success'], 'success'); - getAndHandleDiscussions(data['html']); - form.find('.input').val(''); - } - if(data['error']) { - feedback(data['error'], 'error'); - } - }, - error: function(jqXHR, textStatus, errorThrown) { - var err_str = ''; - if (jqXHR.responseText) { - err_str = $.parseJSON(jqXHR.responseText).error; - } else { - err_str = "{% trans "Failed. Please check the network." %}"; - } - apply_form_error(form_id, err_str); - } - }); - return false; -}); - -$('#click-into-group').click(function() { - {% if groups|length == 1 %} - // only one group, just turn to group page - {% for group in groups %} - location.href= "{% url 'group_info' group.id %}"; - {% endfor %} - - {% else %} - // more than one group, then let user choose - $('#to-group').toggleClass('hide'); - {% endif %} -}); -$(document).click(function(e) { - var target = e.target || event.srcElement; - if (!$('#click-into-group, #to-group').is(target) && !($('#click-into-group, #to-group').find('*').is(target))) { - $('#to-group').addClass('hide'); - } -}); -{% endif %} diff --git a/seahub/templates/snippets/current_commit.html b/seahub/templates/snippets/current_commit.html deleted file mode 100644 index 5cde50dd48..0000000000 --- a/seahub/templates/snippets/current_commit.html +++ /dev/null @@ -1,15 +0,0 @@ -{% load seahub_tags avatar_tags i18n %} - - {{ info_commit.props.desc|translate_commit_desc }} - {% trans "Details"%} - - - {% if info_commit.props.creator_name %} - {% avatar info_commit.props.creator_name 20 %} - {{ info_commit.creator_name|email2nickname }} - {% else %} - {% trans "Unknown"%} - {% endif %} - {{ info_commit.props.ctime|translate_seahub_time }} - - {% trans "History"%} diff --git a/seahub/templates/snippets/group_recommend_form.html b/seahub/templates/snippets/group_recommend_form.html deleted file mode 100644 index a1c0e02beb..0000000000 --- a/seahub/templates/snippets/group_recommend_form.html +++ /dev/null @@ -1,37 +0,0 @@ -{% load seahub_tags i18n %} -{% load url from future %} -
-
{% csrf_token %} -

{% trans "Post a discussion to group" %}

-
- {% for group in groups %} - - {% endfor %} -
- - - - -

- - - {% if attach_type == 'dir' %} - {% trans 'Directory icon' %} - {% endif %} - - {% for name,link in zipped %} - {% if forloop.last %} - {% if attach_type == 'file' %} - {% trans 'File' %} - {% endif %} - {{ name }} - {% endif %} - {% endfor %} - -
-
    - {% trans -
    diff --git a/seahub/templates/snippets/repo_dir_data.html b/seahub/templates/snippets/repo_dir_data.html deleted file mode 100644 index 04df791eb3..0000000000 --- a/seahub/templates/snippets/repo_dir_data.html +++ /dev/null @@ -1,73 +0,0 @@ -{% load seahub_tags i18n %} -
    -

    - {% for name, link in zipped %} - {% if forloop.first or not forloop.last %} - {{ name }} / - {% else %} - {{ name }} / - {% endif %} - {% endfor %} -

    -
    - {% if user_perm == 'rw' %} - - {% if repo.encrypted and repo.enc_version == 2 and not server_crypto %} - - {% else %} - {% if no_quota %} - - {% else %} -
    - {% trans "Upload"%} - -
    - {% if enable_upload_folder %} -
      -
    • - {% trans "Upload Files" %} - -
    • -
    • - {% trans "Upload Folder" %} - -
    • -
    - {% endif %} - {% endif %} - {% endif %} - - {% if repo.encrypted and repo.enc_version == 2 and not server_crypto %} - {% else %} - - {% endif %} - {% endif %} - - {% if path != '/' %} - {% if not repo.encrypted %} - - {% endif %} - {% endif %} -
    -
    - {% include 'snippets/current_commit.html' %} -
    -
    - - - - - - - - - - - - {% include 'snippets/repo_dirents.html' %} -
    - - {% trans "Name"%} {% trans "Size"%}{% trans "Last Update" %} {% trans "Operations"%}
    -{% if dirent_more %} - -{% endif %} diff --git a/seahub/templates/snippets/repo_dirents.html b/seahub/templates/snippets/repo_dirents.html deleted file mode 100644 index 96b488f91c..0000000000 --- a/seahub/templates/snippets/repo_dirents.html +++ /dev/null @@ -1,98 +0,0 @@ -{% load seahub_tags i18n %} - {% for dirent in dir_list %} - - - - - - {% if dirent.permission = 'r' %} - {% trans - {% else %} - {% trans - {% endif %} - - {{ dirent.obj_name }} - - - - - {{ dirent.last_modified|translate_seahub_time }} - - -
    -
    - - - - {% if not repo.encrypted %} - - - - {% endif %} -
    - {% if user_perm == 'rw' %} - {% trans 'More operations'%} - - {% endif %} -
    - - - {% endfor %} - {% for dirent in file_list %} - - - - - - {% if dirent.starred %} - - {% else %} - - {% endif %} - - - {% trans - - - {% if repo.encrypted and repo.enc_version == 2 and not server_crypto %} - {{ dirent.obj_name }} - {% else %} - {{ dirent.obj_name }} - {% endif %} - - {{ dirent.file_size|filesizeformat }} - - {{ dirent.last_modified|translate_seahub_time }} - - -
    -
    - - - - {% if not repo.encrypted %} - - - - {% endif %} -
    - {% if user_perm == 'rw' %} - {% trans - - {% endif %} -
    - - - {% endfor %} diff --git a/seahub/templates/snippets/repo_group_list.html b/seahub/templates/snippets/repo_group_list.html deleted file mode 100644 index e5e5073f2c..0000000000 --- a/seahub/templates/snippets/repo_group_list.html +++ /dev/null @@ -1,9 +0,0 @@ -{% load url from future %} -{% autoescape off %} - -{% endautoescape %} - diff --git a/seahub/templates/sysadmin/admin_repo_view.html b/seahub/templates/sysadmin/admin_repo_view.html index 77056a8045..4bb189a79a 100644 --- a/seahub/templates/sysadmin/admin_repo_view.html +++ b/seahub/templates/sysadmin/admin_repo_view.html @@ -25,8 +25,16 @@ {% endif %} {% endfor %}

    -
    + {% if is_default_repo %} +
    +
    + {% trans "Upload"%} + +
    +
    + {% endif %} +
    @@ -49,6 +57,15 @@ {{ dirent.last_modified|translate_seahub_time }} {% endfor %} @@ -67,6 +84,11 @@
    + {% if is_default_repo %} +
    +
    + + + +
    +
    + {% endif %}
    + {% if is_default_repo %} + + + + {% endif %} @@ -78,9 +100,41 @@
    + {% if is_default_repo %} +
    {% csrf_token %} +

    {% trans "New Directory" %}

    +
    +
    +

    + + +
    + +
    +

    {% trans "File Upload" %}

    +
    + + close +
    +
    +
    + +
    +

    + + {% trans "Saving..." %} +

    +
    +
    +
    + {% endif %} + {% endblock %} {% block extra_script %} +{% if is_default_repo %} +{% upload_js %} +{% endif %} {% endblock %} diff --git a/seahub/templates/sysadmin/repoadmin_table.html b/seahub/templates/sysadmin/repoadmin_table.html index 0eac76c4be..910bc549f1 100644 --- a/seahub/templates/sysadmin/repoadmin_table.html +++ b/seahub/templates/sysadmin/repoadmin_table.html @@ -15,9 +15,7 @@ {{ repo.props.name }} {% else %} {% trans - {% if repo.is_default_repo %} - {{ repo.props.name }} - {% elif enable_sys_admin_view_repo and is_pro_version %} + {% if enable_sys_admin_view_repo and is_pro_version %} {{ repo.props.name }} {% else %} {{ repo.props.name }} diff --git a/seahub/templates/sysadmin/sys_list_system.html b/seahub/templates/sysadmin/sys_list_system.html index 84358aab1b..b12a494e39 100644 --- a/seahub/templates/sysadmin/sys_list_system.html +++ b/seahub/templates/sysadmin/sys_list_system.html @@ -2,12 +2,6 @@ {% load i18n %} {% block cur_repo %}tab-cur{% endblock %} -{% block left_panel %}{{block.super}} -
    - -
    -{% endblock %} - {% block right_panel %}