admins should be able to edit user

This commit is contained in:
j 2012-02-10 22:08:53 +05:30
parent 9de8f260c8
commit 4857b65268
2 changed files with 38 additions and 9 deletions

View file

@ -438,6 +438,10 @@ def edit(request):
if 'rightslevel' in data: if 'rightslevel' in data:
item.level = data['rightslevel'] item.level = data['rightslevel']
del data['rightslevel'] del data['rightslevel']
if 'user' in data:
if request.user.get_profile().get_level() in ('admin', 'staff'):
item.user = models.User.objects.get(username=data['user'])
del data['user']
r = item.edit(data) r = item.edit(data)
if r: if r:
r.wait() r.wait()

View file

@ -268,7 +268,7 @@ pandora.ui.infoView = function(data) {
html.push( html.push(
formatKey(key) formatKey(key)
+ formatValue(data[key], key) + formatValue(data[key], key)
) );
} }
}); });
$('<div>').css(css).html(html.join('; ')).appendTo($center); $('<div>').css(css).html(html.join('; ')).appendTo($center);
@ -311,7 +311,7 @@ pandora.ui.infoView = function(data) {
html.push( html.push(
formatKey(key) formatKey(key)
+ formatValue(data[key], key) + formatValue(data[key], key)
) );
} }
}); });
$('<div>').css(css).html(html.join('; ')).appendTo($center); $('<div>').css(css).html(html.join('; ')).appendTo($center);
@ -408,13 +408,38 @@ pandora.ui.infoView = function(data) {
$div = $('<div>').css(css).css({marginTop: '16px'}).appendTo($center); $div = $('<div>').css(css).css({marginTop: '16px'}).appendTo($center);
html = []; html = [];
['user', 'created', 'modified'].forEach(function(key) { if (['admin', 'staff'].indexOf(pandora.user.level) > -1) {
data[key] && html.push( $('<div>')
formatKey(key == 'modified' ? 'Last Modified' : key) .css({float: 'left'})
+ (key == 'user' ? data.user : Ox.formatDate(data[key], '%F %T')) .html(formatKey('user').replace('</span>', '&nbsp;</span>'))
); .appendTo($div);
}); Ox.Editable({
$div.html(html.join('; ')); placeholder: formatLight('No User'),
tooltip: 'Doubleclick to edit',
value: data.user
})
.bindEvent({
submit: function(event) {
editMetadata('user', event.value);
}
})
.appendTo($div);
['created', 'modified'].forEach(function(key) {
data[key] && html.push(
formatKey(key == 'modified' ? 'Last Modified' : key)
+ (key == 'user' ? data.user : Ox.formatDate(data[key], '%F %T'))
);
});
$div.append(html.join('; '));
} else {
['user', 'created', 'modified'].forEach(function(key) {
data[key] && html.push(
formatKey(key == 'modified' ? 'Last Modified' : key)
+ (key == 'user' ? data.user : Ox.formatDate(data[key], '%F %T'))
);
});
$div.html(html.join('; '));
}
$('<div>').css({height: '16px'}).appendTo($center); $('<div>').css({height: '16px'}).appendTo($center);