mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-01 15:09:14 +00:00
Removed org
This commit is contained in:
@@ -15,39 +15,39 @@ def sys_staff_required(func):
|
||||
raise Http404
|
||||
return _decorated
|
||||
|
||||
def ctx_switch_required(func):
|
||||
"""
|
||||
Decorator for views to change navigation bar automatically that render
|
||||
same template when both in org context and personal context.
|
||||
"""
|
||||
def _decorated(request, *args, **kwargs):
|
||||
if not request.cloud_mode:
|
||||
# no need to switch context when `CLOUD_MODE` is false
|
||||
request.user.org = None
|
||||
request.base_template = 'myhome_base.html'
|
||||
return func(request, *args, **kwargs)
|
||||
# def ctx_switch_required(func):
|
||||
# """
|
||||
# Decorator for views to change navigation bar automatically that render
|
||||
# same template when both in org context and personal context.
|
||||
# """
|
||||
# def _decorated(request, *args, **kwargs):
|
||||
# if not request.cloud_mode:
|
||||
# # no need to switch context when `CLOUD_MODE` is false
|
||||
# request.user.org = None
|
||||
# request.base_template = 'myhome_base.html'
|
||||
# return func(request, *args, **kwargs)
|
||||
|
||||
repo_id = kwargs.get('repo_id', '')
|
||||
group_id = kwargs.get('group_id', '')
|
||||
if repo_id and group_id:
|
||||
return func(request, *args, **kwargs)
|
||||
if not repo_id and not group_id:
|
||||
return func(request, *args, **kwargs)
|
||||
# repo_id = kwargs.get('repo_id', '')
|
||||
# group_id = kwargs.get('group_id', '')
|
||||
# if repo_id and group_id:
|
||||
# return func(request, *args, **kwargs)
|
||||
# if not repo_id and not group_id:
|
||||
# return func(request, *args, **kwargs)
|
||||
|
||||
user = request.user.username
|
||||
if repo_id:
|
||||
org, base_template = check_and_get_org_by_repo(repo_id, user)
|
||||
# user = request.user.username
|
||||
# if repo_id:
|
||||
# org, base_template = check_and_get_org_by_repo(repo_id, user)
|
||||
|
||||
if group_id:
|
||||
org, base_template = check_and_get_org_by_group(int(group_id), user)
|
||||
# if group_id:
|
||||
# org, base_template = check_and_get_org_by_group(int(group_id), user)
|
||||
|
||||
if org:
|
||||
request.user.org = org._dict
|
||||
else:
|
||||
request.user.org = None
|
||||
request.base_template = base_template
|
||||
return func(request, *args, **kwargs)
|
||||
return _decorated
|
||||
# if org:
|
||||
# request.user.org = org._dict
|
||||
# else:
|
||||
# request.user.org = None
|
||||
# request.base_template = base_template
|
||||
# return func(request, *args, **kwargs)
|
||||
# return _decorated
|
||||
|
||||
def repo_passwd_set_required(func):
|
||||
"""
|
||||
|
@@ -1,7 +1,7 @@
|
||||
from django.utils.decorators import method_decorator
|
||||
from auth.decorators import login_required
|
||||
|
||||
from base.decorators import ctx_switch_required
|
||||
# from base.decorators import ctx_switch_required
|
||||
|
||||
class LoginRequiredMixin(object):
|
||||
"""
|
||||
@@ -15,8 +15,8 @@ class LoginRequiredMixin(object):
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(LoginRequiredMixin, self).dispatch(*args, **kwargs)
|
||||
|
||||
class CtxSwitchRequiredMixin(object):
|
||||
@method_decorator(ctx_switch_required)
|
||||
def dispatch(self, *args, **kwargs):
|
||||
return super(CtxSwitchRequiredMixin, self).dispatch(*args, **kwargs)
|
||||
# class CtxSwitchRequiredMixin(object):
|
||||
# @method_decorator(ctx_switch_required)
|
||||
# def dispatch(self, *args, **kwargs):
|
||||
# return super(CtxSwitchRequiredMixin, self).dispatch(*args, **kwargs)
|
||||
|
||||
|
@@ -133,7 +133,7 @@ INSTALLED_APPS = (
|
||||
'seahub.contacts',
|
||||
'seahub.group',
|
||||
'seahub.notifications',
|
||||
'seahub.organizations',
|
||||
# 'seahub.organizations',
|
||||
'seahub.profile',
|
||||
'seahub.share',
|
||||
'api2',
|
||||
|
@@ -31,31 +31,10 @@
|
||||
<div class="top-bar-inner">
|
||||
<div class="top-bar-con">
|
||||
<div class="manage fleft">
|
||||
{% if request.user.is_authenticated %}
|
||||
{% if cloud_mode %}
|
||||
<a href="#" id="account-context" data="no-popup">
|
||||
{% if org %} {{ org.org_name }} {% else %} {% trans "Personal" %} {% endif %}
|
||||
<span class="tri-bg tri-down-bg"></span>
|
||||
</a>
|
||||
<ul class="hide" id="account-context-selector">
|
||||
<li><a href="{% url 'myhome' %}">{% trans "Personal" %}</a></li>
|
||||
{% for org in request.user.orgs %}
|
||||
<li><a href="{% url 'org_personal' org.url_prefix %}">{{ org.org_name }}</a></li>
|
||||
{% endfor %}
|
||||
<li><a href="{% url 'create_org' %}">{% trans "New Organization" %}</a></li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% if request.user.is_staff %}
|
||||
<a href="{{ SITE_ROOT }}sys/useradmin/"{% block top_bar_sys_manager_class %}{% endblock %}>{% trans "System Admin" %}</a>
|
||||
<a href="{{ SITE_ROOT }}home/my/"{% block top_bar_myaccount_class %}{% endblock %}>{% trans "Workspace" %}</a>
|
||||
{% endif %}
|
||||
|
||||
{% if org.is_staff %}
|
||||
<a href="{% url 'org_admin' org.url_prefix %}"{% block top_bar_org_manager_class %}{% endblock %}>{% trans "Admin" %}</a>
|
||||
<a href="{% url 'org_personal' org.url_prefix %}"{% block top_bar_org_myaccount_class %}{% endblock %}>{% trans "Workspace" %}</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="account fright">
|
||||
@@ -133,7 +112,7 @@
|
||||
<ul>
|
||||
<li><a href="http://seafile.com/{% if LANGUAGE_CODE == 'en' %}en/{% endif %}home/" target="_blank">{% trans "Introduction" %}</a></li>
|
||||
<li><a href="https://github.com/haiwen/seafile/wiki{% if LANGUAGE_CODE == 'zh-cn' %}/Seafile-服务器手册中文版{% endif %}" target="_blank">Wiki</a></li>
|
||||
{% if LANGUAGE_CODE == 'zh-cn' %}<li><a href="http://gonggeng.org/vanilla/" target="_blank">{% trans "Forum" %}</a></li>{% endif %}
|
||||
{% if LANGUAGE_CODE == 'zh-cn' %}<li><a href="http://bbs.seafile.com/" target="_blank"> {% else %}<li><a href="https://groups.google.com/forum/#!forum/seafile" target="_blank"> {% endif %}{% trans "Forum" %}</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="item">
|
||||
@@ -182,29 +161,6 @@ $('#info-bar .close').click(function() {
|
||||
}
|
||||
}
|
||||
});
|
||||
{% endif %}
|
||||
|
||||
{% if request.cloud_mode %}
|
||||
$('#account-context').click(function() {
|
||||
if ($(this).attr('data') == 'no-popup') {
|
||||
$(this).parent().css('position', 'relative');
|
||||
$('#account-context-selector').removeClass('hide');
|
||||
$(this).attr('data', 'has-popup');
|
||||
} else {
|
||||
$('#account-context-selector').addClass('hide');
|
||||
$(this).attr('data', 'no-popup');
|
||||
}
|
||||
return false;
|
||||
}).focus(function() { $(this).blur(); });
|
||||
|
||||
$(document).click(function(e) {
|
||||
var element = e.target || e.srcElement;
|
||||
if (element.id != 'account-context-selector' && element.id != 'account-context') {
|
||||
$('#account-context-selector').addClass('hide');
|
||||
$('#account-context').attr('data', 'no-popup');
|
||||
}
|
||||
});
|
||||
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</script>
|
||||
|
2
urls.py
2
urls.py
@@ -117,7 +117,7 @@ except ImportError:
|
||||
CLOUD_MODE = False
|
||||
if CLOUD_MODE:
|
||||
urlpatterns += patterns('',
|
||||
(r'^organizations/', include('seahub.organizations.urls')),
|
||||
# (r'^organizations/', include('seahub.organizations.urls')),
|
||||
(r'^demo/', demo),
|
||||
)
|
||||
else:
|
||||
|
@@ -46,7 +46,7 @@ from seaserv import ccnet_rpc, ccnet_threaded_rpc, get_repos, get_emailusers, \
|
||||
from pysearpc import SearpcError
|
||||
|
||||
from seahub.base.accounts import User
|
||||
from seahub.base.decorators import sys_staff_required, ctx_switch_required
|
||||
from seahub.base.decorators import sys_staff_required
|
||||
from seahub.base.models import UuidObjidMap, FileComment, InnerPubMsg, InnerPubMsgReply
|
||||
from seahub.contacts.models import Contact
|
||||
from seahub.contacts.signals import mail_sended
|
||||
@@ -280,7 +280,6 @@ def render_recycle_dir(request, repo_id, commit_id):
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
@ctx_switch_required
|
||||
def repo_recycle_view(request, repo_id):
|
||||
if get_user_permission(request, repo_id) != 'rw':
|
||||
return render_permission_error(request, _(u'Unable to view recycle page'))
|
||||
@@ -292,7 +291,6 @@ def repo_recycle_view(request, repo_id):
|
||||
return render_recycle_dir(request, repo_id, commit_id)
|
||||
|
||||
@login_required
|
||||
@ctx_switch_required
|
||||
def repo_save_settings(request):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
@@ -360,7 +358,6 @@ def upload_error_msg (code):
|
||||
err_msg = _(u'An error occurs during file transfer')
|
||||
return err_msg
|
||||
|
||||
@ctx_switch_required
|
||||
def upload_file_error(request, repo_id):
|
||||
if request.method == 'GET':
|
||||
repo = get_repo(repo_id)
|
||||
@@ -384,7 +381,6 @@ def upload_file_error(request, repo_id):
|
||||
'err_msg': err_msg,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@ctx_switch_required
|
||||
def update_file_error(request, repo_id):
|
||||
if request.method == 'GET':
|
||||
repo = get_repo(repo_id)
|
||||
@@ -451,7 +447,6 @@ def get_subdir(request):
|
||||
content_type=content_type)
|
||||
|
||||
@login_required
|
||||
@ctx_switch_required
|
||||
def repo_history(request, repo_id):
|
||||
"""
|
||||
List library modification histories.
|
||||
@@ -504,7 +499,6 @@ def repo_history(request, repo_id):
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
@login_required
|
||||
@ctx_switch_required
|
||||
def repo_view_snapshot(request, repo_id):
|
||||
if not access_to_repo(request, repo_id, ''):
|
||||
return render_permission_error(request, _(u'Unable to view library snapshots'))
|
||||
@@ -697,7 +691,7 @@ def repo_remove(request, repo_id):
|
||||
)
|
||||
else:
|
||||
err_msg = _(u'Failed to remove library. Only staff or owner can perform this operation.')
|
||||
return render_permission_error(request, err_msg)
|
||||
messages.error(request, err_msg)
|
||||
else:
|
||||
# Remove repo in personal context, only repo owner or site staff can
|
||||
# perform this operation.
|
||||
@@ -711,9 +705,10 @@ def repo_remove(request, repo_id):
|
||||
repo_id=repo_id,
|
||||
repo_name=repo.name,
|
||||
)
|
||||
messages.success(request, _(u'Successfully deleted library "%s".') % repo.name)
|
||||
else:
|
||||
err_msg = _(u'Failed to remove library. Only staff or owner can perform this operation.')
|
||||
return render_permission_error(request, err_msg)
|
||||
messages.error(request, err_msg)
|
||||
|
||||
next = request.META.get('HTTP_REFERER', None)
|
||||
if not next:
|
||||
@@ -1977,7 +1972,6 @@ def repo_revert_dir (request, repo_id):
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
@login_required
|
||||
@ctx_switch_required
|
||||
def file_revisions(request, repo_id):
|
||||
if request.method != 'GET':
|
||||
return render_error(request)
|
||||
|
@@ -28,7 +28,7 @@ from seaserv import list_dir_by_path, get_repo, web_get_access_token, \
|
||||
from pysearpc import SearpcError
|
||||
|
||||
from auth.decorators import login_required
|
||||
from base.decorators import ctx_switch_required, repo_passwd_set_required
|
||||
from base.decorators import repo_passwd_set_required
|
||||
from base.models import UuidObjidMap, FileComment
|
||||
from contacts.models import Contact
|
||||
from share.models import FileShare
|
||||
@@ -251,7 +251,6 @@ def convert_md_link(file_content, repo_id, username):
|
||||
|
||||
return re.sub(r'\[\[(.+)\]\]|(`.+`)', repl, file_content)
|
||||
|
||||
@ctx_switch_required
|
||||
@repo_passwd_set_required
|
||||
def view_file(request, repo_id):
|
||||
"""
|
||||
@@ -489,7 +488,6 @@ def view_history_file_common(request, repo_id, ret_dict):
|
||||
ret_dict['DOCUMENT_CONVERTOR_ROOT'] = DOCUMENT_CONVERTOR_ROOT
|
||||
ret_dict['use_pdfjs'] = USE_PDFJS
|
||||
|
||||
@ctx_switch_required
|
||||
@repo_passwd_set_required
|
||||
def view_history_file(request, repo_id):
|
||||
ret_dict = {}
|
||||
@@ -505,7 +503,6 @@ def view_history_file(request, repo_id):
|
||||
return render_to_response('view_history_file.html', ret_dict,
|
||||
context_instance=RequestContext(request))
|
||||
|
||||
@ctx_switch_required
|
||||
@repo_passwd_set_required
|
||||
def view_trash_file(request, repo_id):
|
||||
ret_dict = {}
|
||||
@@ -528,7 +525,6 @@ def view_trash_file(request, repo_id):
|
||||
return render_to_response('view_trash_file.html', ret_dict,
|
||||
context_instance=RequestContext(request), )
|
||||
|
||||
@ctx_switch_required
|
||||
@repo_passwd_set_required
|
||||
def view_snapshot_file(request, repo_id):
|
||||
ret_dict = {}
|
||||
@@ -621,7 +617,6 @@ def file_edit_submit(request, repo_id):
|
||||
return error_json(str(e))
|
||||
|
||||
@login_required
|
||||
@ctx_switch_required
|
||||
def file_edit(request, repo_id):
|
||||
repo = get_repo(repo_id)
|
||||
if not repo:
|
||||
|
@@ -10,7 +10,7 @@ from seaserv import server_repo_size, is_passwd_set, get_commits, get_repo, \
|
||||
check_quota, MAX_UPLOAD_FILE_SIZE, web_get_access_token, is_repo_owner, \
|
||||
is_org_repo_owner, get_repo_history_limit, get_commit
|
||||
|
||||
from base.mixins import LoginRequiredMixin, CtxSwitchRequiredMixin
|
||||
from base.mixins import LoginRequiredMixin
|
||||
from contacts.models import Contact
|
||||
from share.models import FileShare
|
||||
from seahub.forms import RepoPassowrdForm
|
||||
@@ -97,8 +97,8 @@ class RepoMixin(object):
|
||||
self.prepare_property()
|
||||
return super(RepoMixin, self).post(request, *args, **kwargs)
|
||||
|
||||
class RepoView(LoginRequiredMixin, CtxSwitchRequiredMixin, RepoMixin,
|
||||
TemplateResponseMixin, BaseFormView):
|
||||
class RepoView(LoginRequiredMixin, RepoMixin, TemplateResponseMixin,
|
||||
BaseFormView):
|
||||
"""
|
||||
View to show repo page and handle post request to decrypt repo.
|
||||
"""
|
||||
@@ -228,8 +228,7 @@ class RepoView(LoginRequiredMixin, CtxSwitchRequiredMixin, RepoMixin,
|
||||
|
||||
return kwargs
|
||||
|
||||
class RepoHistoryView(LoginRequiredMixin, CtxSwitchRequiredMixin, RepoMixin,
|
||||
TemplateView):
|
||||
class RepoHistoryView(LoginRequiredMixin, RepoMixin, TemplateView):
|
||||
"""
|
||||
View to show repo page in history.
|
||||
"""
|
||||
|
Reference in New Issue
Block a user