its an inbox
This commit is contained in:
parent
b1215fbc1b
commit
aac3e66f7b
8 changed files with 58 additions and 54 deletions
|
@ -81,9 +81,9 @@ def api_upload(user_id, items):
|
||||||
from user.models import List
|
from user.models import List
|
||||||
peer = User.get(user_id)
|
peer = User.get(user_id)
|
||||||
if peer:
|
if peer:
|
||||||
l = List.get_or_create(':Public')
|
l = List.get_or_create(':Inbox')
|
||||||
if l:
|
if l:
|
||||||
logger.debug('%s added items to public folder: %s', user_id, items)
|
logger.debug('%s added items to inbox: %s', user_id, items)
|
||||||
l.add_items(items)
|
l.add_items(items)
|
||||||
trigger_event('change', {})
|
trigger_event('change', {})
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -461,7 +461,7 @@ class Node(Thread):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def upload(self, items):
|
def upload(self, items):
|
||||||
logger.debug('add items to %s\'s public folder: %s', self.id, items)
|
logger.debug('add items to %s\'s inbox: %s', self.user_id, items)
|
||||||
r = self.request('upload', items)
|
r = self.request('upload', items)
|
||||||
return bool(r)
|
return bool(r)
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ def getLists(data):
|
||||||
'type': 'libraries',
|
'type': 'libraries',
|
||||||
'user': None,
|
'user': None,
|
||||||
})
|
})
|
||||||
List.get_or_create(':Public')
|
List.get_or_create(':Inbox')
|
||||||
for u in models.User.query.filter((models.User.peered==True)|(models.User.id==settings.USER_ID)):
|
for u in models.User.query.filter((models.User.peered==True)|(models.User.id==settings.USER_ID)):
|
||||||
lists += u.lists_json()
|
lists += u.lists_json()
|
||||||
return {
|
return {
|
||||||
|
@ -289,7 +289,7 @@ def removeList(data):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
l = models.List.get(data['id'])
|
l = models.List.get(data['id'])
|
||||||
if l and l.name != 'Public':
|
if l and l.name != 'Inbox':
|
||||||
l.remove()
|
l.remove()
|
||||||
return {}
|
return {}
|
||||||
actions.register(removeList, cache=False)
|
actions.register(removeList, cache=False)
|
||||||
|
@ -308,12 +308,10 @@ def addListItems(data):
|
||||||
i = Item.get(item_id)
|
i = Item.get(item_id)
|
||||||
i.queue_download()
|
i.queue_download()
|
||||||
i.update()
|
i.update()
|
||||||
elif data['list'] and (data['list'].startswith(':') or
|
elif data['list'] and (data['list'].startswith(':') or data['list'].endswith(':')):
|
||||||
data['list'].endswith(':Public') or
|
|
||||||
data['list'].enswtih(':')):
|
|
||||||
l = models.List.get_or_create(data['list'])
|
l = models.List.get_or_create(data['list'])
|
||||||
if l:
|
if l:
|
||||||
if l.name in ('Public', '') and l.user_id != settings.USER_ID:
|
if l.name in ('Inbox', '') and l.user_id != settings.USER_ID:
|
||||||
state.tasks.queue('upload', {
|
state.tasks.queue('upload', {
|
||||||
'user': l.user_id,
|
'user': l.user_id,
|
||||||
'items': data['items']
|
'items': data['items']
|
||||||
|
@ -350,12 +348,11 @@ def sortLists(data):
|
||||||
'''
|
'''
|
||||||
n = 0
|
n = 0
|
||||||
logger.debug('sortLists %s', data)
|
logger.debug('sortLists %s', data)
|
||||||
lists = ['Public']
|
|
||||||
for id in data['ids']:
|
for id in data['ids']:
|
||||||
l = models.List.get(id)
|
l = models.List.get(id)
|
||||||
l.index_ = n
|
l.index_ = n
|
||||||
n += 1
|
n += 1
|
||||||
if l.type == 'static':
|
if l.type == 'static' and l.name not in ('', 'Inbox'):
|
||||||
lists.append(l.name)
|
lists.append(l.name)
|
||||||
state.db.session.add(l)
|
state.db.session.add(l)
|
||||||
state.db.session.commit()
|
state.db.session.commit()
|
||||||
|
|
|
@ -217,7 +217,7 @@ class User(db.Model):
|
||||||
Changelog.record(self, 'edititem', item.id, item.meta, _commit=False)
|
Changelog.record(self, 'edititem', item.id, item.meta, _commit=False)
|
||||||
lists = []
|
lists = []
|
||||||
for l in List.query.filter_by(user_id=self.id, type='static').order_by('index_'):
|
for l in List.query.filter_by(user_id=self.id, type='static').order_by('index_'):
|
||||||
if l.name:
|
if l.name and l.name != 'Inbox':
|
||||||
lists.append(l.name)
|
lists.append(l.name)
|
||||||
Changelog.record(self, 'addlist', l.name, _commit=False)
|
Changelog.record(self, 'addlist', l.name, _commit=False)
|
||||||
items = [i.id for i in l.get_items().options(load_only('id'))]
|
items = [i.id for i in l.get_items().options(load_only('id'))]
|
||||||
|
@ -300,7 +300,7 @@ class List(db.Model):
|
||||||
state.db.session.add(l)
|
state.db.session.add(l)
|
||||||
state.db.session.commit()
|
state.db.session.commit()
|
||||||
if user_id == settings.USER_ID:
|
if user_id == settings.USER_ID:
|
||||||
if l.type == 'static' and name != '':
|
if l.type == 'static' and name != '' and name != 'Inbox':
|
||||||
add_record('addlist', l.name)
|
add_record('addlist', l.name)
|
||||||
return l
|
return l
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ oml.ui.folderList = function(options) {
|
||||||
src: Ox.UI.getImageURL(
|
src: Ox.UI.getImageURL(
|
||||||
value == 'libraries' ? 'symbolData'
|
value == 'libraries' ? 'symbolData'
|
||||||
: value == 'library' ? 'symbolUser'
|
: value == 'library' ? 'symbolUser'
|
||||||
: data.name == 'Public' ? 'symbolPublish'
|
: data.name == 'Inbox' ? 'symbolPublish'
|
||||||
: value == 'static' ? 'symbolClick'
|
: value == 'static' ? 'symbolClick'
|
||||||
: 'symbolFind'
|
: 'symbolFind'
|
||||||
)
|
)
|
||||||
|
|
|
@ -42,7 +42,7 @@ oml.ui.folders = function() {
|
||||||
}).indexOf(list.user) : null;
|
}).indexOf(list.user) : null;
|
||||||
return list.id == '' ? oml.$ui.librariesList
|
return list.id == '' ? oml.$ui.librariesList
|
||||||
: Ox.endsWith(list.id, ':') ? oml.$ui.libraryList[index]
|
: Ox.endsWith(list.id, ':') ? oml.$ui.libraryList[index]
|
||||||
: Ox.endsWith(list.id, ':Public') ? oml.$ui.publicList[index]
|
: Ox.endsWith(list.id, ':Inbox') ? oml.$ui.inboxList[index]
|
||||||
: oml.$ui.folderList[index];
|
: oml.$ui.folderList[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ oml.ui.folders = function() {
|
||||||
!list ? 'libraryList'
|
!list ? 'libraryList'
|
||||||
: 'folderList'
|
: 'folderList'
|
||||||
][index]
|
][index]
|
||||||
: list == 'Public' ? oml.$ui.publicList[index]
|
: list == 'Inbox' ? oml.$ui.inboxList[index]
|
||||||
: oml.$ui.folderList[index];
|
: oml.$ui.folderList[index];
|
||||||
$lists.forEach(function($list) {
|
$lists.forEach(function($list) {
|
||||||
if ($list == $selectedList) {
|
if ($list == $selectedList) {
|
||||||
|
@ -87,7 +87,7 @@ oml.ui.folders = function() {
|
||||||
oml.$ui.folder = [];
|
oml.$ui.folder = [];
|
||||||
oml.$ui.libraryList = [];
|
oml.$ui.libraryList = [];
|
||||||
oml.$ui.folderList = [];
|
oml.$ui.folderList = [];
|
||||||
oml.$ui.publicList = [];
|
oml.$ui.inboxList = [];
|
||||||
|
|
||||||
getUsersAndLists(function(users, lists) {
|
getUsersAndLists(function(users, lists) {
|
||||||
|
|
||||||
|
@ -120,10 +120,11 @@ oml.ui.folders = function() {
|
||||||
var $content,
|
var $content,
|
||||||
items = lists.filter(function(list) {
|
items = lists.filter(function(list) {
|
||||||
return list.user === user.name
|
return list.user === user.name
|
||||||
&& list.type != 'library' && list.name != 'Public';
|
&& list.type != 'library' && list.name != 'Inbox';
|
||||||
}),
|
}),
|
||||||
libraryId = user.name + ':',
|
libraryId = user.name + ':',
|
||||||
publicId = user.name + ':Public';
|
inboxId = user.name + ':Inbox',
|
||||||
|
offset = 16;
|
||||||
|
|
||||||
userIndex[user.name] = index;
|
userIndex[user.name] = index;
|
||||||
|
|
||||||
|
@ -193,7 +194,7 @@ oml.ui.folders = function() {
|
||||||
oml.UI.set({find: getFind(data.ids[0])});
|
oml.UI.set({find: getFind(data.ids[0])});
|
||||||
},
|
},
|
||||||
selectnext: function() {
|
selectnext: function() {
|
||||||
oml.UI.set({find: getFind(publicId)});
|
oml.UI.set({find: getFind(inboxId)});
|
||||||
},
|
},
|
||||||
selectprevious: function() {
|
selectprevious: function() {
|
||||||
// FIXME: ugly
|
// FIXME: ugly
|
||||||
|
@ -216,11 +217,11 @@ oml.ui.folders = function() {
|
||||||
})
|
})
|
||||||
.appendTo($content)
|
.appendTo($content)
|
||||||
);
|
);
|
||||||
|
if (user.name == '') {
|
||||||
$lists.push(
|
$lists.push(
|
||||||
oml.$ui.publicList[index] = oml.ui.folderList({
|
oml.$ui.inboxList[index] = oml.ui.folderList({
|
||||||
items: lists.filter(function(list) {
|
items: lists.filter(function(list) {
|
||||||
return list.user == user.name && list.name == 'Public';
|
return list.user == user.name && list.name == 'Inbox';
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
|
@ -236,7 +237,9 @@ oml.ui.folders = function() {
|
||||||
})
|
})
|
||||||
.appendTo($content)
|
.appendTo($content)
|
||||||
);
|
);
|
||||||
oml.$ui.publicList[index].$body.css({top: '16px'});
|
oml.$ui.inboxList[index].$body.css({top: offset + 'px'});
|
||||||
|
offset += 16;
|
||||||
|
}
|
||||||
|
|
||||||
$lists.push(
|
$lists.push(
|
||||||
oml.$ui.folderList[index] = oml.ui.folderList({
|
oml.$ui.folderList[index] = oml.ui.folderList({
|
||||||
|
@ -258,7 +261,7 @@ oml.ui.folders = function() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
'delete': function(data) {
|
'delete': function(data) {
|
||||||
!index && !Ox.contains(data.ids, ':Public') && oml.ui.deleteListDialog().open();
|
!index && !Ox.contains(data.ids, ':Inbox') && oml.ui.deleteListDialog().open();
|
||||||
},
|
},
|
||||||
key_control_d: function() {
|
key_control_d: function() {
|
||||||
oml.addList(ui._list);
|
oml.addList(ui._list);
|
||||||
|
@ -275,7 +278,7 @@ oml.ui.folders = function() {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
open: function(data) {
|
open: function(data) {
|
||||||
!index && !Ox.contains(data.ids, ':Public') && oml.ui.listDialog().open();
|
!index && !Ox.contains(data.ids, ':Inbox') && oml.ui.listDialog().open();
|
||||||
},
|
},
|
||||||
select: function(data) {
|
select: function(data) {
|
||||||
oml.UI.set({find: getFind(data.ids[0])});
|
oml.UI.set({find: getFind(data.ids[0])});
|
||||||
|
@ -290,14 +293,14 @@ oml.ui.folders = function() {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectprevious: function() {
|
selectprevious: function() {
|
||||||
oml.UI.set({find: getFind(publicId)});
|
oml.UI.set({find: getFind(inboxId)});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.css({height: items.length * 16 + 'px'})
|
.css({height: items.length * 16 + 'px'})
|
||||||
.appendTo($content)
|
.appendTo($content)
|
||||||
);
|
);
|
||||||
|
|
||||||
oml.$ui.folderList[index].$body.css({top: '32px'});
|
oml.$ui.folderList[index].$body.css({top: offset + 'px'});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -353,7 +356,7 @@ oml.ui.folders = function() {
|
||||||
oml.$ui.folder[index].options({title: Ox.encodeHTMLEntities(name)});
|
oml.$ui.folder[index].options({title: Ox.encodeHTMLEntities(name)});
|
||||||
oml.getLists(function(lists) {
|
oml.getLists(function(lists) {
|
||||||
var items = lists.filter(function(list) {
|
var items = lists.filter(function(list) {
|
||||||
return list.user == name && list.type != 'library' && list.name != 'Public';
|
return list.user == name && list.type != 'library' && list.name != 'Inbox';
|
||||||
}),
|
}),
|
||||||
library = lists.filter(function(list) {
|
library = lists.filter(function(list) {
|
||||||
return list.user == name && list.type == 'library';
|
return list.user == name && list.type == 'library';
|
||||||
|
|
|
@ -956,7 +956,7 @@ oml.ui.mainMenu = function() {
|
||||||
isLibrary = Ox.endsWith(ui._list, ':'),
|
isLibrary = Ox.endsWith(ui._list, ':'),
|
||||||
isList = !isLibraries && !isLibrary,
|
isList = !isLibraries && !isLibrary,
|
||||||
isOwnList = ui._list[0] == ':',
|
isOwnList = ui._list[0] == ':',
|
||||||
isPublic = ui._list == ':Public';
|
isInbox = ui._list == ':Inbox';
|
||||||
|
|
||||||
if (oml.readOnly) {
|
if (oml.readOnly) {
|
||||||
return {
|
return {
|
||||||
|
@ -1020,13 +1020,13 @@ oml.ui.mainMenu = function() {
|
||||||
id: 'editlist',
|
id: 'editlist',
|
||||||
title: Ox._('Edit List...'),
|
title: Ox._('Edit List...'),
|
||||||
keyboard: 'return',
|
keyboard: 'return',
|
||||||
disabled: !isList || !isOwnList || isPublic
|
disabled: !isList || !isOwnList || isInbox
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'deletelist',
|
id: 'deletelist',
|
||||||
title: Ox._('Delete List...'),
|
title: Ox._('Delete List...'),
|
||||||
keyboard: 'delete',
|
keyboard: 'delete',
|
||||||
disabled: !isList || !isOwnList || isPublic
|
disabled: !isList || !isOwnList || isInbox
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
};
|
};
|
||||||
|
|
|
@ -316,7 +316,7 @@ oml.enableDragAndDrop = function($list, canMove) {
|
||||||
|
|
||||||
$list.bindEvent({
|
$list.bindEvent({
|
||||||
draganddropstart: function(data) {
|
draganddropstart: function(data) {
|
||||||
var $lists = oml.$ui.libraryList.concat(oml.$ui.publicList).concat(oml.$ui.folderList);
|
var $lists = oml.$ui.libraryList.concat(oml.$ui.inboxList).concat(oml.$ui.folderList);
|
||||||
drag.action = 'copy';
|
drag.action = 'copy';
|
||||||
drag.ids = $list.options('selected');
|
drag.ids = $list.options('selected');
|
||||||
drag.item = drag.ids.length == 1
|
drag.item = drag.ids.length == 1
|
||||||
|
@ -335,9 +335,9 @@ oml.enableDragAndDrop = function($list, canMove) {
|
||||||
&& drag.source.user != ''
|
&& drag.source.user != ''
|
||||||
&& data.user == ''
|
&& data.user == ''
|
||||||
) || (
|
) || (
|
||||||
data.type == 'static'
|
data.type == 'library'
|
||||||
&& data.name == 'Public'
|
|
||||||
&& drag.source.user == ''
|
&& drag.source.user == ''
|
||||||
|
&& data.user != ''
|
||||||
),
|
),
|
||||||
selected: data.id == ui._list
|
selected: data.id == ui._list
|
||||||
}, data);
|
}, data);
|
||||||
|
@ -492,8 +492,12 @@ oml.enableDragAndDrop = function($list, canMove) {
|
||||||
text = Ox._('You cannot move books<br>out of a smart list.');
|
text = Ox._('You cannot move books<br>out of a smart list.');
|
||||||
}
|
}
|
||||||
} else if (drag.target) {
|
} else if (drag.target) {
|
||||||
|
console.log(drag.target)
|
||||||
targetText = drag.target.type == 'libraries' ? Ox._('a library')
|
targetText = drag.target.type == 'libraries' ? Ox._('a library')
|
||||||
: drag.target.type == 'library' ? Ox._('your library')
|
: drag.target.type == 'library' ?
|
||||||
|
drag.target.user == ''
|
||||||
|
? Ox._('your library')
|
||||||
|
: Ox._('{0}\'s library', [Ox.encodeHTMLEntities(Ox.truncate(drag.target.user, 32))])
|
||||||
: Ox._('the list "{0}"', [Ox.encodeHTMLEntities(Ox.truncate(drag.target.name, 32))]);
|
: Ox._('the list "{0}"', [Ox.encodeHTMLEntities(Ox.truncate(drag.target.name, 32))]);
|
||||||
if (
|
if (
|
||||||
(
|
(
|
||||||
|
@ -507,7 +511,7 @@ oml.enableDragAndDrop = function($list, canMove) {
|
||||||
Ox._(itemText[0] == '"' ? '' : 'These ') + itemText,
|
Ox._(itemText[0] == '"' ? '' : 'These ') + itemText,
|
||||||
targetText
|
targetText
|
||||||
]);
|
]);
|
||||||
} else if (drag.target.user != '' && drag.target.name != 'Public') {
|
} else if (drag.target.user != '' && drag.target.type != 'library') {
|
||||||
text = Ox._(
|
text = Ox._(
|
||||||
'You can only {0} books<br>to your own {1}.',
|
'You can only {0} books<br>to your own {1}.',
|
||||||
[actionText, drag.target.type == 'library' ? 'library' : 'lists']
|
[actionText, drag.target.type == 'library' ? 'library' : 'lists']
|
||||||
|
@ -992,7 +996,7 @@ oml.resizeListFolders = function() {
|
||||||
oml.$ui.libraryList[index]
|
oml.$ui.libraryList[index]
|
||||||
.css({width: width + 'px'})
|
.css({width: width + 'px'})
|
||||||
.resizeColumn('name', columnWidth);
|
.resizeColumn('name', columnWidth);
|
||||||
oml.$ui.publicList[index]
|
oml.$ui.inboxList[index] && oml.$ui.inboxList[index]
|
||||||
.css({width: width + 'px'})
|
.css({width: width + 'px'})
|
||||||
.resizeColumn('name', columnWidth);
|
.resizeColumn('name', columnWidth);
|
||||||
oml.$ui.folderList[index]
|
oml.$ui.folderList[index]
|
||||||
|
|
Loading…
Reference in a new issue