Fixes for editor tools viewing JS.
This commit is contained in:
Родитель
08beb782c6
Коммит
60cf9e574e
|
@ -208,5 +208,5 @@ VERSION_BETA = re.compile('(a|alpha|b|beta|pre|rc)\d*$')
|
||||||
VERSION_SEARCH = re.compile('\.(\d+)$')
|
VERSION_SEARCH = re.compile('\.(\d+)$')
|
||||||
|
|
||||||
# Editor Tools
|
# Editor Tools
|
||||||
EDITOR_VIEWING_INTERVAL = 8
|
EDITOR_VIEWING_INTERVAL = 8 # How often we ping for "who's watching?"
|
||||||
|
|
||||||
|
|
|
@ -432,6 +432,7 @@ def review_viewing(request):
|
||||||
current_name = ''
|
current_name = ''
|
||||||
is_user = 0
|
is_user = 0
|
||||||
key = '%s:review_viewing:%s' % (settings.CACHE_PREFIX, addon_id)
|
key = '%s:review_viewing:%s' % (settings.CACHE_PREFIX, addon_id)
|
||||||
|
interval = amo.EDITOR_VIEWING_INTERVAL
|
||||||
|
|
||||||
# Check who is viewing.
|
# Check who is viewing.
|
||||||
currently_viewing = cache.get(key)
|
currently_viewing = cache.get(key)
|
||||||
|
@ -440,7 +441,7 @@ def review_viewing(request):
|
||||||
if not currently_viewing or currently_viewing == user_id:
|
if not currently_viewing or currently_viewing == user_id:
|
||||||
# We want to save it for twice as long as the ping interval,
|
# We want to save it for twice as long as the ping interval,
|
||||||
# just to account for latency and the like.
|
# just to account for latency and the like.
|
||||||
cache.set(key, user_id, amo.EDITOR_VIEWING_INTERVAL * 2)
|
cache.set(key, user_id, interval * 2)
|
||||||
currently_viewing = user_id
|
currently_viewing = user_id
|
||||||
current_name = request.amo_user.name
|
current_name = request.amo_user.name
|
||||||
is_user = 1
|
is_user = 1
|
||||||
|
@ -448,7 +449,7 @@ def review_viewing(request):
|
||||||
current_name = UserProfile.objects.get(pk=currently_viewing).name
|
current_name = UserProfile.objects.get(pk=currently_viewing).name
|
||||||
|
|
||||||
return {'current': currently_viewing, 'current_name': current_name,
|
return {'current': currently_viewing, 'current_name': current_name,
|
||||||
'is_user': is_user}
|
'is_user': is_user, 'interval_seconds': interval}
|
||||||
|
|
||||||
|
|
||||||
@editor_required
|
@editor_required
|
||||||
|
|
|
@ -111,19 +111,21 @@ function initReviewActions() {
|
||||||
|
|
||||||
|
|
||||||
/* Who's currently on this page? */
|
/* Who's currently on this page? */
|
||||||
|
var addon_id = location.href.match(/review\/([0-9]*)/)[1];
|
||||||
function check_currently_viewing() {
|
function check_currently_viewing() {
|
||||||
$.post('/en-US/editors/review_viewing', {'addon_id':1}, function(d){
|
$.post('/en-US/editors/review_viewing', {'addon_id': addon_id}, function(d){
|
||||||
$current = $('.currently_viewing_warning');
|
$current = $('.currently_viewing_warning');
|
||||||
$current.toggle(d.is_user != 1);
|
$current.toggle(d.is_user != 1);
|
||||||
|
|
||||||
var title = format(gettext('{name} was viewing this page first.'), {name: d.current_name})
|
var title = format(gettext('{name} was viewing this page first.'), {name: d.current_name});
|
||||||
$current_div = $current.filter('div');
|
$current_div = $current.filter('div');
|
||||||
$current_div.find('strong').remove();
|
$current_div.find('strong').remove();
|
||||||
$current_div.prepend($('<strong>', {'text': title}));
|
$current_div.prepend($('<strong>', {'text': title}));
|
||||||
});
|
|
||||||
|
setTimeout(check_currently_viewing, d.interval_seconds * 1000);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
check_currently_viewing();
|
check_currently_viewing();
|
||||||
setInterval(check_currently_viewing, 8000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertAtCursor(textarea, text) {
|
function insertAtCursor(textarea, text) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче