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