mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-02 07:47:32 +00:00
added 'ajax login check' for notice and my-info, improved html&js for my-info
This commit is contained in:
parent
a41fb9031f
commit
a65913f46f
@ -53,6 +53,7 @@ $(function() {
|
||||
notice_list = $('#notice-list');
|
||||
notice_list.addClass('hide');
|
||||
loading_tip.show();
|
||||
$('.error', popup).addClass('hide');
|
||||
$.ajax({
|
||||
url: popup.data('url'),
|
||||
dataType: 'json',
|
||||
@ -68,6 +69,17 @@ $(function() {
|
||||
dataType:'json'
|
||||
});
|
||||
});
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
if (xhr.responseText) {
|
||||
var error = jQuery.parseJSON(xhr.responseText).error;
|
||||
loading_tip.hide();
|
||||
if ($('.error', popup).length == 0) {
|
||||
loading_tip.after('<p class="error alc">' + error + '</p>');
|
||||
} else {
|
||||
$('.error', popup).removeClass('hide');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -95,29 +107,37 @@ $(function() {
|
||||
}
|
||||
});
|
||||
|
||||
(function () {
|
||||
var my_info = $('#my-info');
|
||||
$('#my-info').click(function() {
|
||||
var popup = $('#user-info-popup');
|
||||
my_info.click(function() {
|
||||
var loading_tip = $('.loading-tip', popup);
|
||||
if (popup.hasClass('hide')) {
|
||||
popup.removeClass('hide');
|
||||
loading_tip.removeClass('hide');
|
||||
$.ajax({
|
||||
url: my_info.data('url'),
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
loading_tip.addClass('hide');
|
||||
$('#space-traffic').html(data['html']);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
popup.addClass('hide');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
})();
|
||||
popup.toggleClass('hide');
|
||||
if (!popup.hasClass('hide')) {
|
||||
var loading_tip = $('.loading-tip', popup),
|
||||
space_traffic = $('#space-traffic');
|
||||
loading_tip.show();
|
||||
space_traffic.addClass('hide');
|
||||
$('.error', popup).addClass('hide');
|
||||
$.ajax({
|
||||
url: space_traffic.data('url'),
|
||||
dataType: 'json',
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
loading_tip.hide();
|
||||
space_traffic.html(data['html']).removeClass('hide');
|
||||
},
|
||||
error: function (xhr, textStatus, errorThrown) {
|
||||
if (xhr.responseText) {
|
||||
var error = jQuery.parseJSON(xhr.responseText).error;
|
||||
loading_tip.hide();
|
||||
if ($('.error', popup).length == 0) {
|
||||
loading_tip.after('<p class="error alc">' + error + '</p>');
|
||||
} else {
|
||||
$('.error', popup).removeClass('hide');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
||||
</div>
|
||||
|
||||
<div id="account" class="fright">
|
||||
<div id="my-info" data-url="{% url 'space_and_traffic' %}">
|
||||
<div id="my-info">
|
||||
{% avatar request.user 36 %} <span class="icon-caret-down vam"></span>
|
||||
</div>
|
||||
<div id="user-info-popup" class="top-info-popup hide">
|
||||
@ -73,9 +73,8 @@
|
||||
{{ request.user.username}}
|
||||
</div>
|
||||
</div>
|
||||
<div id="space-traffic">
|
||||
<img src="{{MEDIA_URL}}img/loading-icon.gif" alt="" class="loading-tip" />
|
||||
</div>
|
||||
<img src="{{MEDIA_URL}}img/loading-icon.gif" alt="" class="loading-tip" />
|
||||
<div id="space-traffic" class="hide" data-url="{% url 'space_and_traffic' %}"></div>
|
||||
<a class="item" href="{{ SITE_ROOT }}profile/">{% trans "Settings" %}</a>
|
||||
<a href="{{ SITE_ROOT }}accounts/logout/" class="item" id="logout">{% trans "Log out" %}</a>
|
||||
</div>
|
||||
|
@ -1255,7 +1255,6 @@ def upload_file_done(request):
|
||||
|
||||
return HttpResponse(json.dumps({'success': True}), content_type=ct)
|
||||
|
||||
@login_required
|
||||
def unseen_notices_count(request):
|
||||
"""Count user's unseen notices.
|
||||
|
||||
@ -1266,6 +1265,12 @@ def unseen_notices_count(request):
|
||||
raise Http404
|
||||
|
||||
content_type = 'application/json; charset=utf-8'
|
||||
|
||||
if not request.user.is_authenticated():
|
||||
return HttpResponse(json.dumps({
|
||||
'error': _('Please log in.')
|
||||
}), status=400, content_type=content_type)
|
||||
|
||||
username = request.user.username
|
||||
|
||||
count = UserNotification.objects.count_unseen_user_notifications(username)
|
||||
@ -1273,7 +1278,6 @@ def unseen_notices_count(request):
|
||||
result['count'] = count
|
||||
return HttpResponse(json.dumps(result), content_type=content_type)
|
||||
|
||||
@login_required
|
||||
def get_popup_notices(request):
|
||||
"""Get user's notifications.
|
||||
|
||||
@ -1289,6 +1293,12 @@ def get_popup_notices(request):
|
||||
raise Http404
|
||||
|
||||
content_type = 'application/json; charset=utf-8'
|
||||
|
||||
if not request.user.is_authenticated():
|
||||
return HttpResponse(json.dumps({
|
||||
'error': _('Please log in.')
|
||||
}), status=400, content_type=content_type)
|
||||
|
||||
username = request.user.username
|
||||
|
||||
result_notices = []
|
||||
@ -1461,13 +1471,17 @@ def repo_remove(request, repo_id):
|
||||
result['error'] = _(u'Permission denied.')
|
||||
return HttpResponse(json.dumps(result), status=403, content_type=ct)
|
||||
|
||||
@login_required
|
||||
def space_and_traffic(request):
|
||||
if not request.is_ajax():
|
||||
raise Http404
|
||||
|
||||
content_type = 'application/json; charset=utf-8'
|
||||
|
||||
if not request.user.is_authenticated():
|
||||
return HttpResponse(json.dumps({
|
||||
'error': _('Please log in.')
|
||||
}), status=400, content_type=content_type)
|
||||
|
||||
username = request.user.username
|
||||
|
||||
quota = seafserv_threaded_rpc.get_user_quota(username)
|
||||
|
Loading…
Reference in New Issue
Block a user