add per list export_json

This commit is contained in:
j 2016-01-15 13:29:35 +05:30
commit b961086475
4 changed files with 31 additions and 12 deletions

View file

@ -242,20 +242,11 @@ def command_dump_json(*args):
if not args:
print('usage: ./ctl json_dump dump.json')
sys.exit(1)
import json
from ox.django.shortcuts import _to_json
import item.models
import db
import state
with db.session():
items = []
for i in item.models.Item.query:
j = i.json()
for f in i.files:
j['path'] = f.fullpath()
break
items.append(j)
with open(args[0], 'w') as f:
json.dump(items, f, indent=1, default=_to_json, ensure_ascii=False, sort_keys=True)
library = state.user().library
library.export_json(args[0])
def main():
actions = globals()