From f2d32a7121e80379a30b679f9dc41bb85891d962 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Thu, 10 Nov 2011 17:53:12 +0000 Subject: [PATCH] itemKey type list --- pandora/0xdb.jsonc | 3 ++- pandora/item/managers.py | 6 +++--- pandora/item/models.py | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index 13f1b05ab..dacb5b3d6 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -455,11 +455,12 @@ { "id": "rightslevel", "title": "Rights Level", - "type": "label", + "type": "list", "columnWidth": 90, "format": {"type": "ColorLevel", "args": [ ["Public", "Relaxed", "Regular", "Restricted", "Private"] ]}, + "list": ["Public", "Relaxed", "Regular", "Restricted", "Private"], "sortOperator": "+" }, { diff --git a/pandora/item/managers.py b/pandora/item/managers.py index 15360861e..c0e3b6d82 100644 --- a/pandora/item/managers.py +++ b/pandora/item/managers.py @@ -52,7 +52,7 @@ def parseCondition(condition, user): 'layer': 'string', }.get(key_type, key_type) if k == 'list': - key_type = 'list' + key_type = '' if (not exclude and op == '=' or op in ('$', '^')) and v == '': return Q() @@ -124,7 +124,7 @@ def parseCondition(condition, user): if exclude: q = ~q return q - elif key_type == 'list': + elif k == 'list': q = Q(id=0) l = v.split(":") if len(l) >= 2: @@ -164,7 +164,7 @@ def parseCondition(condition, user): if exclude: q = ~q return q - else: #numbers + else: #integer, float, list, time #use sort table here if key_type == 'time': v = int(utils.parse_time(v)) diff --git a/pandora/item/models.py b/pandora/item/models.py index c8f8b9d82..f93e584fd 100644 --- a/pandora/item/models.py +++ b/pandora/item/models.py @@ -1156,7 +1156,7 @@ attrs = { 'item': models.OneToOneField('Item', related_name='sort', primary_key=True), 'duration': models.FloatField(null=True, blank=True, db_index=True), } -for key in filter(lambda k: 'columnWidth' in k or k['type'] in ('integer', 'time', 'float', 'data'), settings.CONFIG['itemKeys']): +for key in filter(lambda k: 'columnWidth' in k or k['type'] in ('integer', 'time', 'float', 'date', 'list'), settings.CONFIG['itemKeys']): name = key['id'] name = {'id': 'itemId'}.get(name, name) sort_type = key.get('sort', key['type']) @@ -1178,7 +1178,7 @@ for key in filter(lambda k: 'columnWidth' in k or k['type'] in ('integer', 'time 'date': 'date', 'hue': 'float', 'time': 'integer', - 'label': 'integer', + 'list': 'integer', }.get(sort_type, sort_type)] attrs[name] = model[0](**model[1])