forked from 0x2620/pandora
add random order. fixes #414
This commit is contained in:
parent
fbe8c9160b
commit
3ed46c3f6d
3 changed files with 24 additions and 2 deletions
|
@ -442,6 +442,12 @@
|
||||||
"capability": "canSeeFiles",
|
"capability": "canSeeFiles",
|
||||||
"find": true
|
"find": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "random",
|
||||||
|
"title": "Random",
|
||||||
|
"type": "integer",
|
||||||
|
"columnWidth": 60
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "created",
|
"id": "created",
|
||||||
"title": "Date Created",
|
"title": "Date Created",
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
import os
|
import os
|
||||||
from datetime import timedelta, datetime
|
from datetime import timedelta, datetime
|
||||||
import gzip
|
import gzip
|
||||||
|
import random
|
||||||
|
random
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from ox.utils import ET
|
from ox.utils import ET
|
||||||
|
@ -14,8 +15,17 @@ import models
|
||||||
|
|
||||||
@periodic_task(run_every=timedelta(days=1))
|
@periodic_task(run_every=timedelta(days=1))
|
||||||
def cronjob(**kwargs):
|
def cronjob(**kwargs):
|
||||||
print "do some cleanup stuff once a day"
|
update_random_sort()
|
||||||
|
|
||||||
|
def update_random_sort():
|
||||||
|
if filter(lambda f: f['id'] == 'random', settings.CONFIG['itemKeys']):
|
||||||
|
random.seed()
|
||||||
|
ids = [f['item'] for f in models.ItemSort.objects.values('item')]
|
||||||
|
random.shuffle(ids)
|
||||||
|
n = 0
|
||||||
|
for i in ids:
|
||||||
|
models.ItemSort.objects.filter(pk=i).update(random=n)
|
||||||
|
n += 1
|
||||||
|
|
||||||
@task(ignore_resulsts=True, queue='default')
|
@task(ignore_resulsts=True, queue='default')
|
||||||
def update_poster(itemId):
|
def update_poster(itemId):
|
||||||
|
|
|
@ -351,6 +351,12 @@
|
||||||
"capability": "canSeeFiles",
|
"capability": "canSeeFiles",
|
||||||
"find": true
|
"find": true
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "random",
|
||||||
|
"title": "Random",
|
||||||
|
"type": "integer",
|
||||||
|
"columnWidth": 60
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "created",
|
"id": "created",
|
||||||
"title": "Date Created",
|
"title": "Date Created",
|
||||||
|
|
Loading…
Reference in a new issue