prepare public api
This commit is contained in:
parent
507b6fed3e
commit
dd0e22a979
18 changed files with 237 additions and 94 deletions
|
|
@ -55,6 +55,21 @@ def init(data):
|
|||
return response
|
||||
actions.register(init)
|
||||
|
||||
def public_init(data):
|
||||
response = init(data)
|
||||
name = response['user']['preferences']['username']
|
||||
response['user'] = response['config']['user']
|
||||
response['user']['preferences']['username'] = name
|
||||
response['user']['ui']['page'] = ''
|
||||
response['user']['ui']['showFolder'] = {'': True}
|
||||
response['readOnly'] = True
|
||||
for page in response['config']['pages']:
|
||||
if page['id'] == 'preferences':
|
||||
#page['parts'] = [p for p in page['parts'] if p['id'] in ('appearance', 'extensions')]
|
||||
page['parts'] = [p for p in page['parts'] if p['id'] in ('appearance',)]
|
||||
return response
|
||||
actions.register(public_init, action='init', version='public')
|
||||
|
||||
|
||||
def setPreferences(data):
|
||||
'''
|
||||
|
|
@ -149,6 +164,12 @@ def getUsers(data):
|
|||
}
|
||||
actions.register(getUsers)
|
||||
|
||||
def getUsersPublic(data):
|
||||
return {
|
||||
'users': []
|
||||
}
|
||||
actions.register(getUsersPublic, 'getUsers', version='public')
|
||||
|
||||
|
||||
def getLists(data):
|
||||
'''
|
||||
|
|
@ -172,6 +193,29 @@ def getLists(data):
|
|||
}
|
||||
actions.register(getLists)
|
||||
|
||||
def getListsPublic(data):
|
||||
'''
|
||||
returns {
|
||||
lists: []
|
||||
}
|
||||
'''
|
||||
from item.models import Item
|
||||
from sqlalchemy.sql import operators
|
||||
user = state.user()
|
||||
lists = []
|
||||
lists.append({
|
||||
'id': '',
|
||||
'items': user.items.count(),
|
||||
'name': 'Libraries',
|
||||
'type': 'libraries',
|
||||
'user': None,
|
||||
})
|
||||
lists += user.lists_json()
|
||||
return {
|
||||
'lists': lists
|
||||
}
|
||||
actions.register(getListsPublic, 'getLists', version='public')
|
||||
|
||||
def validate_query(query):
|
||||
validate_conditions(query['conditions'])
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue