everyone can have a license; groups admin

This commit is contained in:
j 2012-01-19 22:05:28 +05:30
parent f4fab78812
commit 10a1239df7
5 changed files with 52 additions and 25 deletions

View file

@ -59,7 +59,8 @@
//{"id": "year", "title": "Years", "type": "integer"}, //{"id": "year", "title": "Years", "type": "integer"},
{"id": "features", "title": "Features", "type": "string"}, {"id": "features", "title": "Features", "type": "string"},
{"id": "director", "title": "Directors", "type": "string"}, {"id": "director", "title": "Directors", "type": "string"},
{"id": "cinematographer", "title": "Cinematographers", "type": "string"} {"id": "cinematographer", "title": "Cinematographers", "type": "string"},
{"id": "license", "title": "License", "type": "string"}
], ],
/* /*
An itemKey must have the following properties: An itemKey must have the following properties:
@ -386,6 +387,14 @@
"type": "integer", "type": "integer",
"columnWidth": 60 "columnWidth": 60
}, },
{
"id": "license",
"title": "License",
"type": ["string"],
"columnWidth": 120,
"autocomplete": true,
"filter": true
},
{ {
"id": "rightslevel", "id": "rightslevel",
"title": "Rights Level", "title": "Rights Level",

View file

@ -38,6 +38,8 @@ class SessionData(models.Model):
objects = managers.SessionDataManager() objects = managers.SessionDataManager()
groupssort = models.CharField(default=None,blank=True,null=True, max_length=255)
def __unicode__(self): def __unicode__(self):
return u"%s" % self.session_key return u"%s" % self.session_key
@ -92,8 +94,10 @@ class SessionData(models.Model):
self.username = self.user.username self.username = self.user.username
self.level = self.user.get_profile().level self.level = self.user.get_profile().level
self.firstseen = self.user.date_joined self.firstseen = self.user.date_joined
self.groupssort = ''.join([g.name for g in self.user.groups.all()])
else: else:
self.level = 0 self.level = 0
self.groupssort = None
self.parse_data() self.parse_data()
super(SessionData, self).save(*args, **kwargs) super(SessionData, self).save(*args, **kwargs)

View file

@ -427,6 +427,7 @@ def order_query(qs, sort):
'browser': 'browser', 'browser': 'browser',
'email': 'user__email', 'email': 'user__email',
'firstseen': 'firstseen', 'firstseen': 'firstseen',
'groups': 'groupssort',
'ip': 'ip', 'ip': 'ip',
'lastseen': 'lastseen', 'lastseen': 'lastseen',
'level': 'level', 'level': 'level',

View file

@ -168,21 +168,25 @@ pandora.ui.infoView = function(data) {
Ox.Editable({ Ox.Editable({
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
editable: isEditable, editable: isEditable,
placeholder: formatLight('unknown'), maxHeight: Infinity,
placeholder: formatLight('No description'),
tooltip: isEditable ? 'Doubleclick to edit' : '', tooltip: isEditable ? 'Doubleclick to edit' : '',
type: 'textarea', type: 'textarea',
value: data.description || '' value: data.description || '',
//width: 300
}) })
.bindEvent({ .bindEvent({
submit: function(event) { submit: function(event) {
editMetadata('description', event.value); editMetadata('description', event.value);
} }
}) })
.css(css)
) )
.appendTo($text); .appendTo($text);
} }
var list_keys = ['language', 'topic', 'director', 'cinematographer', 'features', 'groups']; var listKeys = ['language', 'topic', 'director', 'cinematographer', 'features', 'groups',
'license'];
$('<div>').html('<br>').appendTo($text); $('<div>').html('<br>').appendTo($text);
[ [
'source', 'source',
@ -195,12 +199,12 @@ pandora.ui.infoView = function(data) {
'features', 'features',
'language', 'language',
'topic', 'topic',
'license',
'user', 'user',
].forEach(function(key) { ].forEach(function(key) {
var $div = $('<div>') var $div = $('<div>').appendTo($text),
.appendTo($text), value = listKeys.indexOf(key) >= 0
value = list_keys.indexOf(key) >= 0
? (data[key] || []).join(', ') ? (data[key] || []).join(', ')
: data[key] || ''; : data[key] || '';
if (isEditable || value) { if (isEditable || value) {
@ -214,7 +218,7 @@ pandora.ui.infoView = function(data) {
Ox.Editable({ Ox.Editable({
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
format: function(value) { format: function(value) {
return list_keys.indexOf(key) >= 0 return listKeys.indexOf(key) >= 0
? formatValue(value.split(', '), { ? formatValue(value.split(', '), {
'director': 'name', 'director': 'name',
'cinematographer': 'name', 'cinematographer': 'name',
@ -225,7 +229,7 @@ pandora.ui.infoView = function(data) {
placeholder: formatLight('unknown'), placeholder: formatLight('unknown'),
editable: isEditable, editable: isEditable,
tooltip: isEditable ? 'Doubleclick to edit' : '', tooltip: isEditable ? 'Doubleclick to edit' : '',
value: list_keys.indexOf(key) >= 0 value: listKeys.indexOf(key) >= 0
? (data[key] || []).join(', ') ? (data[key] || []).join(', ')
: data[key] || '' : data[key] || ''
}) })
@ -234,6 +238,7 @@ pandora.ui.infoView = function(data) {
editMetadata(key, event.value); editMetadata(key, event.value);
} }
}) })
.css(css)
.appendTo($div); .appendTo($div);
if(pandora.site.itemKeys.filter(function(item) { if(pandora.site.itemKeys.filter(function(item) {
if (item.id == key) if (item.id == key)
@ -244,7 +249,7 @@ pandora.ui.infoView = function(data) {
.append( .append(
descriptions[key] = Ox.Editable({ descriptions[key] = Ox.Editable({
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
placeholder: formatLight(Ox.toTitleCase(key) + ' Description'), placeholder: formatLight('No ' + Ox.toTitleCase(key) + ' Description'),
editable: isEditable, editable: isEditable,
tooltip: isEditable ? 'Doubleclick to edit' : '', tooltip: isEditable ? 'Doubleclick to edit' : '',
type: 'textarea', type: 'textarea',
@ -255,6 +260,7 @@ pandora.ui.infoView = function(data) {
editMetadata(key + 'description', event.value); editMetadata(key + 'description', event.value);
} }
}) })
.css(css)
).css({ ).css({
'padding-top': '4px', 'padding-top': '4px',
'padding-bottom': '4px' 'padding-bottom': '4px'
@ -354,7 +360,7 @@ pandora.ui.infoView = function(data) {
var edit = {id: data.id}; var edit = {id: data.id};
if (key == 'title') { if (key == 'title') {
edit[key] = value; edit[key] = value;
} else if(list_keys.indexOf(key) > -1) { } else if(listKeys.indexOf(key) > -1) {
edit[key] = value ? value.split(', ') : []; edit[key] = value ? value.split(', ') : [];
} else { } else {
edit[key] = value; edit[key] = value;

View file

@ -125,6 +125,13 @@ pandora.ui.usersDialog = function() {
visible: true, visible: true,
width: 60 width: 60
}, },
{
id: 'groups',
operator: '+',
title: 'Groups',
visible: true,
width: 90
},
{ {
format: function(value) { format: function(value) {
return $('<img>') return $('<img>')
@ -490,18 +497,6 @@ pandora.ui.usersDialog = function() {
.bindEvent({ .bindEvent({
submit: function(data) { submit: function(data) {
}
}),
Ox.Input({
id: 'groups',
label: 'Groups',
labelWidth: 80,
value: user.groups.join(', '),
width: formWidth - 16
})
.bindEvent({
submit: function(data) {
} }
}), }),
Ox.Select({ Ox.Select({
@ -517,6 +512,18 @@ pandora.ui.usersDialog = function() {
value: user.level, value: user.level,
width: formWidth - 16 width: formWidth - 16
}), }),
Ox.Input({
id: 'groups',
label: 'Groups',
labelWidth: 80,
value: user.groups.join(', '),
width: formWidth - 16
})
.bindEvent({
submit: function(data) {
}
}),
Ox.Checkbox({ Ox.Checkbox({
id: 'newsletter', id: 'newsletter',
label: 'Newsletter', label: 'Newsletter',
@ -534,7 +541,7 @@ pandora.ui.usersDialog = function() {
} }
}), }),
Ox.Input({ Ox.Input({
height: dialogHeight - 160, height: dialogHeight - 184,
id: 'notes', id: 'notes',
placeholder: 'Notes', placeholder: 'Notes',
type: 'textarea', type: 'textarea',