forked from 0x2620/pandora
in between queries
default view/sort for lists
This commit is contained in:
parent
d6e27be0cd
commit
0eefc3dfd3
3 changed files with 47 additions and 25 deletions
|
@ -67,6 +67,10 @@ def parseCondition(condition):
|
|||
in_find = False
|
||||
facet_value = 'facets__value%s' % {
|
||||
'==': '__iexact',
|
||||
'>': '__gt',
|
||||
'>=': '__gte',
|
||||
'<': '__lt',
|
||||
'<=': '__lte',
|
||||
'^': '__istartswith',
|
||||
'$': '__iendswith',
|
||||
}.get(op, '__icontains')
|
||||
|
@ -75,6 +79,10 @@ def parseCondition(condition):
|
|||
else:
|
||||
value_key = 'find__value%s' % {
|
||||
'==': '__iexact',
|
||||
'>': '__gt',
|
||||
'>=': '__gte',
|
||||
'<': '__lt',
|
||||
'<=': '__lte',
|
||||
'^': '__istartswith',
|
||||
'$': '__iendswith',
|
||||
}.get(op, '__icontains')
|
||||
|
@ -131,7 +139,7 @@ def parseCondition(condition):
|
|||
}.get(op,'__exact'))
|
||||
|
||||
vk = str('find__%s' % vk)
|
||||
|
||||
|
||||
if exclude: #!1960
|
||||
return ~Q(**{'find__key': k, vk: v})
|
||||
else: #1960
|
||||
|
|
|
@ -34,6 +34,9 @@ class List(models.Model):
|
|||
icon = models.ImageField(default=None, blank=True,
|
||||
upload_to=lambda i, x: i.path("icon.jpg"))
|
||||
|
||||
view = models.TextField(default=settings.CONFIG['user']['ui']['listView'])
|
||||
sort = TupleField(default=tuple(settings.CONFIG['user']['ui']['listSort']), editable=False)
|
||||
|
||||
poster_frames = TupleField(default=[], editable=False)
|
||||
|
||||
#is through table still required?
|
||||
|
@ -50,7 +53,8 @@ class List(models.Model):
|
|||
self.type = 'static'
|
||||
else:
|
||||
self.type = 'smart'
|
||||
self.items_sum = self.get_items_sum(self.user)
|
||||
if self.id:
|
||||
self.items_sum = self.get_items_sum(self.user)
|
||||
super(List, self).save(*args, **kwargs)
|
||||
|
||||
def get_items_sum(self, user=None):
|
||||
|
@ -144,7 +148,7 @@ class List(models.Model):
|
|||
if not os.path.exists(path):
|
||||
folder = os.path.dirname(path)
|
||||
ox.makedirs(folder)
|
||||
if self.icon:
|
||||
if self.icon and os.path.exists(self.icon.path):
|
||||
source = self.icon.path
|
||||
max_size = min(self.icon.width, self.icon.height)
|
||||
else:
|
||||
|
|
|
@ -192,6 +192,8 @@ def addList(request):
|
|||
type
|
||||
query
|
||||
items
|
||||
view
|
||||
sort
|
||||
|
||||
return {
|
||||
status: {'code': int, 'text': string},
|
||||
|
@ -211,28 +213,32 @@ def addList(request):
|
|||
num += 1
|
||||
name = data['name'] + ' [%d]' % num
|
||||
|
||||
for key in data:
|
||||
if key == 'query' and not data['query']:
|
||||
setattr(list, key, {"static":True})
|
||||
elif key == 'query':
|
||||
setattr(list, key, data[key])
|
||||
elif key == 'type':
|
||||
if data[key] == 'static':
|
||||
list.query = {"static":True}
|
||||
list.type = 'static'
|
||||
else:
|
||||
list.type = 'dynamic'
|
||||
if list.query.get('static', False):
|
||||
list.query = {}
|
||||
elif key == 'status':
|
||||
value = data[key]
|
||||
if value not in list._status:
|
||||
value = list._status[0]
|
||||
if not request.user.is_staff and value == 'featured':
|
||||
value = 'private'
|
||||
setattr(list, key, value)
|
||||
elif key == 'description':
|
||||
list.description = data['description']
|
||||
if 'query' in data and data['query']:
|
||||
setattr(list, 'query', data['query'])
|
||||
else:
|
||||
setattr(list, 'query', {"static":True})
|
||||
if 'type' in data:
|
||||
if data['type'] == 'static':
|
||||
list.query = {"static":True}
|
||||
list.type = 'static'
|
||||
else:
|
||||
list.type = 'dynamic'
|
||||
if list.query.get('static', False):
|
||||
list.query = {}
|
||||
if 'status' in data:
|
||||
value = data['status']
|
||||
if value not in list._status:
|
||||
value = list._status[0]
|
||||
if not request.user.is_staff and value == 'featured':
|
||||
value = 'private'
|
||||
list.status = value
|
||||
if 'description' in data:
|
||||
list.description = data['description']
|
||||
if 'view' in data:
|
||||
list.view = data['view']
|
||||
if 'sort' in data:
|
||||
list.sort= tuple(data['sort'])
|
||||
|
||||
list.save()
|
||||
|
||||
if 'items' in data:
|
||||
|
@ -351,6 +357,10 @@ def editList(request):
|
|||
if 'posterFrames' in data:
|
||||
list.poster_frames = tuple(data['posterFrames'])
|
||||
list.update_icon()
|
||||
if 'view' in data:
|
||||
list.view = data['view']
|
||||
if 'sort' in data:
|
||||
list.sort= tuple(data['sort'])
|
||||
list.save()
|
||||
response['data'] = list.json(user=request.user)
|
||||
else:
|
||||
|
|
Loading…
Reference in a new issue