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,6 +408,30 @@ 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 = [];
if (['admin', 'staff'].indexOf(pandora.user.level) > -1) {
$('<div>')
.css({float: 'left'})
.html(formatKey('user').replace('</span>', '&nbsp;</span>'))
.appendTo($div);
Ox.Editable({
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) { ['user', 'created', 'modified'].forEach(function(key) {
data[key] && html.push( data[key] && html.push(
formatKey(key == 'modified' ? 'Last Modified' : key) formatKey(key == 'modified' ? 'Last Modified' : key)
@ -415,6 +439,7 @@ pandora.ui.infoView = function(data) {
); );
}); });
$div.html(html.join('; ')); $div.html(html.join('; '));
}
$('<div>').css({height: '16px'}).appendTo($center); $('<div>').css({height: '16px'}).appendTo($center);