not in
This commit is contained in:
parent
3e5c3c9a47
commit
abc0b82961
4 changed files with 48 additions and 47 deletions
|
@ -157,6 +157,7 @@ class UploadHandler(tornado.web.RequestHandler):
|
||||||
self.set_status(403)
|
self.set_status(403)
|
||||||
self.write('')
|
self.write('')
|
||||||
return
|
return
|
||||||
|
|
||||||
def save_files(context, request, callback):
|
def save_files(context, request, callback):
|
||||||
listname = request.arguments.get('list', None)
|
listname = request.arguments.get('list', None)
|
||||||
if listname:
|
if listname:
|
||||||
|
@ -198,7 +199,7 @@ class UploadHandler(tornado.web.RequestHandler):
|
||||||
callback(response)
|
callback(response)
|
||||||
|
|
||||||
response = yield tornado.gen.Task(save_files, self._context, self.request)
|
response = yield tornado.gen.Task(save_files, self._context, self.request)
|
||||||
if not 'status' in response:
|
if 'status' not in response:
|
||||||
response = json_response(response)
|
response = json_response(response)
|
||||||
response = json_dumps(response)
|
response = json_dumps(response)
|
||||||
self.set_header('Content-Type', 'application/json')
|
self.set_header('Content-Type', 'application/json')
|
||||||
|
|
|
@ -36,8 +36,7 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
user_items = sa.Table('useritem', db.metadata,
|
user_items = sa.Table('useritem', db.metadata,
|
||||||
sa.Column('user_id', sa.String(43), sa.ForeignKey('user.id')),
|
sa.Column('user_id', sa.String(43), sa.ForeignKey('user.id')),
|
||||||
sa.Column('item_id', sa.String(32), sa.ForeignKey('item.id'))
|
sa.Column('item_id', sa.String(32), sa.ForeignKey('item.id')))
|
||||||
)
|
|
||||||
|
|
||||||
class Item(db.Model):
|
class Item(db.Model):
|
||||||
__tablename__ = 'item'
|
__tablename__ = 'item'
|
||||||
|
@ -118,10 +117,10 @@ class Item(db.Model):
|
||||||
|
|
||||||
def add_user(self, user):
|
def add_user(self, user):
|
||||||
from user.models import list_items
|
from user.models import list_items
|
||||||
if not user in self.users:
|
if user not in self.users:
|
||||||
self.users.append(user)
|
self.users.append(user)
|
||||||
l = user.library
|
l = user.library
|
||||||
if not self in l.items:
|
if self not in l.items:
|
||||||
q = list_items.insert({'item_id': self.id, 'list_id': l.id})
|
q = list_items.insert({'item_id': self.id, 'list_id': l.id})
|
||||||
state.db.session.execute(q)
|
state.db.session.execute(q)
|
||||||
|
|
||||||
|
@ -251,7 +250,8 @@ class Item(db.Model):
|
||||||
value = self.json().get(key['id'], None)
|
value = self.json().get(key['id'], None)
|
||||||
if key.get('filterMap') and value:
|
if key.get('filterMap') and value:
|
||||||
value = re.compile(key.get('filterMap')).findall(value)
|
value = re.compile(key.get('filterMap')).findall(value)
|
||||||
if value: value = value[0]
|
if value:
|
||||||
|
value = value[0]
|
||||||
if key.get('type') == 'boolean':
|
if key.get('type') == 'boolean':
|
||||||
value = True if value else False
|
value = True if value else False
|
||||||
value = str(value).lower()
|
value = str(value).lower()
|
||||||
|
@ -473,7 +473,7 @@ class Item(db.Model):
|
||||||
if preview:
|
if preview:
|
||||||
icons[key] = preview
|
icons[key] = preview
|
||||||
self.info['previewRatio'] = get_ratio(preview)
|
self.info['previewRatio'] = get_ratio(preview)
|
||||||
if not 'coverRatio' in self.info:
|
if 'coverRatio' not in self.info:
|
||||||
self.info['coverRatio'] = self.info['previewRatio']
|
self.info['coverRatio'] = self.info['previewRatio']
|
||||||
else:
|
else:
|
||||||
del icons[key]
|
del icons[key]
|
||||||
|
@ -515,13 +515,13 @@ class Item(db.Model):
|
||||||
|
|
||||||
def queue_download(self):
|
def queue_download(self):
|
||||||
u = state.user()
|
u = state.user()
|
||||||
if not self.id in state.downloads.transfers:
|
if self.id not in state.downloads.transfers:
|
||||||
state.downloads.transfers[self.id] = {
|
state.downloads.transfers[self.id] = {
|
||||||
'added': datetime.utcnow(),
|
'added': datetime.utcnow(),
|
||||||
'progress': 0
|
'progress': 0
|
||||||
}
|
}
|
||||||
logger.debug('queue %s for download', self.id)
|
logger.debug('queue %s for download', self.id)
|
||||||
if not u in self.users:
|
if u not in self.users:
|
||||||
self.add_user(u)
|
self.add_user(u)
|
||||||
|
|
||||||
def save_file(self, content):
|
def save_file(self, content):
|
||||||
|
@ -730,7 +730,7 @@ class File(db.Model):
|
||||||
|
|
||||||
def move(self):
|
def move(self):
|
||||||
def format_underscores(string):
|
def format_underscores(string):
|
||||||
return re.sub('^\.|\.$|:|/|\?|<|>', '_', string)
|
return re.sub(r'^\.|\.$|:|/|\?|<|>', '_', string)
|
||||||
prefs = settings.preferences
|
prefs = settings.preferences
|
||||||
prefix = os.sep.join(os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books/').split('/'))
|
prefix = os.sep.join(os.path.join(os.path.expanduser(prefs['libraryPath']), 'Books/').split('/'))
|
||||||
if not self.item:
|
if not self.item:
|
||||||
|
@ -833,7 +833,7 @@ def update_sort_table():
|
||||||
sort_indexes = [i[len('ix_sort_'):] for i in layout['indexes'] if i.startswith('ix_sort_')]
|
sort_indexes = [i[len('ix_sort_'):] for i in layout['indexes'] if i.startswith('ix_sort_')]
|
||||||
for col in set(Item.sort_keys)-set(sort_indexes):
|
for col in set(Item.sort_keys)-set(sort_indexes):
|
||||||
sql.append('CREATE INDEX ix_sort_{col} ON sort ({col})'.format(col=col))
|
sql.append('CREATE INDEX ix_sort_{col} ON sort ({col})'.format(col=col))
|
||||||
if not 'sortvalue' in db.get_table_columns('find'):
|
if 'sortvalue' not in db.get_table_columns('find'):
|
||||||
create_table = str(CreateTable(Find.__table__).compile(db.engine)).split('\n')
|
create_table = str(CreateTable(Find.__table__).compile(db.engine)).split('\n')
|
||||||
col = 'sortvalue'
|
col = 'sortvalue'
|
||||||
add = [r for r in create_table if '\t%s ' % col in r][0].strip()[:-1]
|
add = [r for r in create_table if '\t%s ' % col in r][0].strip()[:-1]
|
||||||
|
|
|
@ -63,6 +63,7 @@ class TkUI:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.root = Tk()
|
self.root = Tk()
|
||||||
self.root.withdraw() # hiding tkinter window
|
self.root.withdraw() # hiding tkinter window
|
||||||
|
|
||||||
def selectFolder(self, data):
|
def selectFolder(self, data):
|
||||||
return tkinter.filedialog.askdirectory(title=data.get("title", "Select Folder"))
|
return tkinter.filedialog.askdirectory(title=data.get("title", "Select Folder"))
|
||||||
|
|
||||||
|
|
|
@ -160,7 +160,7 @@ class User(db.Model):
|
||||||
self.save()
|
self.save()
|
||||||
if not was_peering:
|
if not was_peering:
|
||||||
Changelog.record(state.user(), 'addpeer', self.id, self.nickname)
|
Changelog.record(state.user(), 'addpeer', self.id, self.nickname)
|
||||||
if not 'index' in self.info:
|
if 'index' not in self.info:
|
||||||
self.info['index'] = max([
|
self.info['index'] = max([
|
||||||
u.info.get('index', -1) for u in User.query.filter_by(peered=True)
|
u.info.get('index', -1) for u in User.query.filter_by(peered=True)
|
||||||
] + [0]) + 1
|
] + [0]) + 1
|
||||||
|
@ -238,8 +238,7 @@ class User(db.Model):
|
||||||
|
|
||||||
list_items = sa.Table('listitem', db.metadata,
|
list_items = sa.Table('listitem', db.metadata,
|
||||||
sa.Column('list_id', sa.Integer(), sa.ForeignKey('list.id')),
|
sa.Column('list_id', sa.Integer(), sa.ForeignKey('list.id')),
|
||||||
sa.Column('item_id', sa.String(32), sa.ForeignKey('item.id'))
|
sa.Column('item_id', sa.String(32), sa.ForeignKey('item.id')))
|
||||||
)
|
|
||||||
|
|
||||||
class List(db.Model):
|
class List(db.Model):
|
||||||
__tablename__ = 'list'
|
__tablename__ = 'list'
|
||||||
|
@ -305,7 +304,7 @@ class List(db.Model):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def rename_user(cls, old, new):
|
def rename_user(cls, old, new):
|
||||||
for l in cls.query.filter(cls._query!=None):
|
for l in cls.query.filter(cls._query is not None):
|
||||||
|
|
||||||
def update_conditions(conditions):
|
def update_conditions(conditions):
|
||||||
changed = False
|
changed = False
|
||||||
|
|
Loading…
Reference in a new issue