forked from 0x2620/pandora
update api docs
This commit is contained in:
parent
0a56268b92
commit
6bd001a10a
6 changed files with 213 additions and 280 deletions
|
@ -44,28 +44,29 @@ actions.register(removeVolume, cache=False)
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def update(request, data):
|
def update(request, data):
|
||||||
'''
|
'''
|
||||||
2 steps:
|
Undocumented
|
||||||
send files
|
2 steps:
|
||||||
{volume: 'Videos', files: [{oshash:, path:, mtime:, ,,}]}
|
send files
|
||||||
send info about changed/new files
|
{volume: 'Videos', files: [{oshash:, path:, mtime:, ,,}]}
|
||||||
{volume: 'Videos', info: {oshash: {...}]}
|
send info about changed/new files
|
||||||
|
{volume: 'Videos', info: {oshash: {...}]}
|
||||||
|
|
||||||
call volume/files first and fill in requested info after that
|
call volume/files first and fill in requested info after that
|
||||||
|
|
||||||
takes {
|
takes {
|
||||||
volume: '',
|
volume: '',
|
||||||
files: [
|
files: [
|
||||||
{oshash:, path:, mtime:, },
|
{oshash:, path:, mtime:, },
|
||||||
...
|
...
|
||||||
],
|
],
|
||||||
info: {oshash: object}
|
info: {oshash: object}
|
||||||
}
|
}
|
||||||
|
|
||||||
returns {
|
returns {
|
||||||
info: list, // list of files that need info
|
info: list, // list of files that need info
|
||||||
data: list, // list of flies that should be encoded to highest profile and uploaded
|
data: list, // list of flies that should be encoded to highest profile and uploaded
|
||||||
file: list // list of files that should be uploaded as is
|
file: list // list of files that should be uploaded as is
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
user = request.user
|
user = request.user
|
||||||
upload_only = data.get('upload', False)
|
upload_only = data.get('upload', False)
|
||||||
|
@ -110,16 +111,17 @@ actions.register(update, cache=False)
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def upload(request, data=None):
|
def upload(request, data=None):
|
||||||
'''
|
'''
|
||||||
takes {
|
Uploads one or more media files for a given item
|
||||||
id: string
|
takes {
|
||||||
frame: [] //multipart frames
|
id: string // item id
|
||||||
file: [] //multipart file
|
frame: [] // one or more frames
|
||||||
}
|
file: [] // one or more files
|
||||||
|
}
|
||||||
returns {
|
returns {
|
||||||
info: object,
|
info: object, // undocumented
|
||||||
rename: object
|
rename: object // undocumented
|
||||||
}
|
}
|
||||||
|
see: add, edit, find, get, lookup, remove
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
f = get_object_or_404_json(models.File, oshash=request.POST['id'])
|
f = get_object_or_404_json(models.File, oshash=request.POST['id'])
|
||||||
|
@ -157,15 +159,17 @@ actions.register(upload, cache=False)
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addMedia(request, data):
|
def addMedia(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
Adds media files to a given item
|
||||||
id: oshash
|
takes {
|
||||||
filename: string,
|
filename: string, // undocumented
|
||||||
item: string
|
id: oshash, // undocumented
|
||||||
info: {}
|
info: {}, // undocumented
|
||||||
}
|
item: string // item id
|
||||||
returns {
|
}
|
||||||
item: id,
|
returns {
|
||||||
}
|
item: id // item id
|
||||||
|
}
|
||||||
|
see: editMedia, moveMedia, removeMedia
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
oshash = data.pop('id')
|
oshash = data.pop('id')
|
||||||
|
@ -333,7 +337,7 @@ def taskStatus(request, data):
|
||||||
status: string, // status, 'PENDING' or 'OK'
|
status: string, // status, 'PENDING' or 'OK'
|
||||||
result: object // result data
|
result: object // result data
|
||||||
}
|
}
|
||||||
notes: To be deprecated, will be wrapped in regular API call
|
notes: To be deprecated, will be wrapped in regular API call.
|
||||||
'''
|
'''
|
||||||
#FIXME: should check if user has permissions to get status
|
#FIXME: should check if user has permissions to get status
|
||||||
if 'taskId' in data:
|
if 'taskId' in data:
|
||||||
|
@ -348,14 +352,14 @@ actions.register(taskStatus, cache=False)
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def moveMedia(request, data):
|
def moveMedia(request, data):
|
||||||
'''
|
'''
|
||||||
change file / item link
|
Move media files from one item to another
|
||||||
takes {
|
takes {
|
||||||
ids: ids of files
|
ids: ids of files
|
||||||
item: new public_id
|
item: new public_id
|
||||||
}
|
}
|
||||||
|
returns {}
|
||||||
returns {
|
notes: This will *not* (yet) shift the corresponding annotations.
|
||||||
}
|
see: addMedia, editMedia, findMedia, removeMedia
|
||||||
'''
|
'''
|
||||||
if Item.objects.filter(public_id=data['item']).count() == 1:
|
if Item.objects.filter(public_id=data['item']).count() == 1:
|
||||||
i = Item.objects.get(public_id=data['item'])
|
i = Item.objects.get(public_id=data['item'])
|
||||||
|
@ -395,17 +399,21 @@ actions.register(moveMedia, cache=False)
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editMedia(request, data):
|
def editMedia(request, data):
|
||||||
'''
|
'''
|
||||||
change file / item link
|
Edits one or more media files
|
||||||
takes {
|
takes {
|
||||||
files: [
|
files: [
|
||||||
{id:, key1: value1, key2: value2}
|
{
|
||||||
...
|
id: string, // file id
|
||||||
]
|
key: value, // property id and new value
|
||||||
}
|
... more key/value pairs
|
||||||
possible keys: part, partTitle, language, ignore, extension, version, episodes
|
},
|
||||||
|
// more media files
|
||||||
returns {
|
]
|
||||||
}
|
}
|
||||||
|
returns {}
|
||||||
|
notes: Possible keys are 'episodes', 'extension', 'ignore', 'language',
|
||||||
|
'part', 'partTitle' and 'version'.
|
||||||
|
see: addMedia, findMedia, moveMedia, removeMedia
|
||||||
'''
|
'''
|
||||||
ignore = []
|
ignore = []
|
||||||
save_items = []
|
save_items = []
|
||||||
|
@ -452,6 +460,12 @@ actions.register(editMedia, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeMedia(request, data):
|
def removeMedia(request, data):
|
||||||
|
'''
|
||||||
|
Removes one or more media files from a given item
|
||||||
|
takes {} // undocumented
|
||||||
|
returns {} // undocumented
|
||||||
|
see: addMedia, editMedia, findMedia, moveMedia
|
||||||
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if request.user.get_profile().get_level() == 'admin':
|
if request.user.get_profile().get_level() == 'admin':
|
||||||
qs = models.File.objects.filter(oshash__in=data['ids'], instances__id=None)
|
qs = models.File.objects.filter(oshash__in=data['ids'], instances__id=None)
|
||||||
|
@ -471,14 +485,14 @@ actions.register(removeMedia, cache=False)
|
||||||
|
|
||||||
def getPath(request, data):
|
def getPath(request, data):
|
||||||
'''
|
'''
|
||||||
change file / item link
|
Undocumented
|
||||||
takes {
|
change file / item link
|
||||||
id: [hash of file]
|
takes {
|
||||||
}
|
id: [hash of file]
|
||||||
|
}
|
||||||
returns {
|
returns {
|
||||||
id: path
|
id: path
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
ids = data['id']
|
ids = data['id']
|
||||||
|
@ -527,77 +541,16 @@ def _order_query(qs, sort, prefix=''):
|
||||||
|
|
||||||
def findMedia(request, data):
|
def findMedia(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
Finds media files
|
||||||
'query': query,
|
takes {
|
||||||
'sort': array,
|
query: object, // query object, see `find`
|
||||||
'range': array
|
sort: array, // list of sort objects, see `find`
|
||||||
}
|
range: [int, int] // range of results to return
|
||||||
|
}
|
||||||
query: item query object, more on query syntax at
|
returns {
|
||||||
https://wiki.0x2620.org/wiki/pandora/QuerySyntax
|
items: [object] // list of items
|
||||||
get media for all items matching the given query
|
}
|
||||||
|
see: addMedia, editMedia, moveMedia, removeMedia
|
||||||
sort: array of key, operator dics
|
|
||||||
[
|
|
||||||
{
|
|
||||||
key: "year",
|
|
||||||
operator: "-"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "director",
|
|
||||||
operator: ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
range: result range, array [from, to]
|
|
||||||
keys: array of keys to return
|
|
||||||
group: group elements by, country, genre, director...
|
|
||||||
|
|
||||||
with keys, items is list of dicts with requested properties:
|
|
||||||
returns {
|
|
||||||
items: [object]
|
|
||||||
}
|
|
||||||
|
|
||||||
Groups
|
|
||||||
takes {
|
|
||||||
'query': query,
|
|
||||||
'key': string,
|
|
||||||
'group': string,
|
|
||||||
'range': array
|
|
||||||
}
|
|
||||||
|
|
||||||
query: query object, more on query syntax at
|
|
||||||
https://wiki.0x2620.org/wiki/pandora/QuerySyntax
|
|
||||||
range: result range, array [from, to]
|
|
||||||
keys: array of keys to return
|
|
||||||
group: group elements by, country, genre, director...
|
|
||||||
|
|
||||||
possible values for keys: path, items
|
|
||||||
|
|
||||||
with keys
|
|
||||||
items contains list of {'path': string, 'items': int}:
|
|
||||||
returns {
|
|
||||||
items: [object]
|
|
||||||
}
|
|
||||||
|
|
||||||
without keys: return number of items in given query
|
|
||||||
returns {
|
|
||||||
items: int
|
|
||||||
}
|
|
||||||
|
|
||||||
Positions
|
|
||||||
takes {
|
|
||||||
'query': query,
|
|
||||||
'positions': [string]
|
|
||||||
}
|
|
||||||
|
|
||||||
query: query object, more on query syntax at
|
|
||||||
https://wiki.0x2620.org/wiki/pandora/QuerySyntax
|
|
||||||
positions: ids of items for which positions are required
|
|
||||||
returns {
|
|
||||||
positions: {
|
|
||||||
id: position
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'''
|
'''
|
||||||
if not data.get('sort'):
|
if not data.get('sort'):
|
||||||
data['sort'] = [{'key': 'path', 'operator': '+'}]
|
data['sort'] = [{'key': 'path', 'operator': '+'}]
|
||||||
|
@ -664,12 +617,13 @@ actions.register(findMedia)
|
||||||
|
|
||||||
def parsePath(request, data): #parse path and return info
|
def parsePath(request, data): #parse path and return info
|
||||||
'''
|
'''
|
||||||
takes {
|
Parses a path
|
||||||
path: string
|
takes {
|
||||||
}
|
path: string // undocumented
|
||||||
returns {
|
}
|
||||||
imdb: string
|
returns {
|
||||||
}
|
imdb: string // undocumented
|
||||||
|
}
|
||||||
'''
|
'''
|
||||||
path = data['path']
|
path = data['path']
|
||||||
response = json_response(ox.parse_movie_path(path))
|
response = json_response(ox.parse_movie_path(path))
|
||||||
|
@ -678,13 +632,14 @@ actions.register(parsePath)
|
||||||
|
|
||||||
def getMediaInfo(request, data):
|
def getMediaInfo(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
Gets media file info, undocumented
|
||||||
id: oshash of stream file
|
takes {
|
||||||
}
|
id: string // oshash of media file
|
||||||
returns {
|
}
|
||||||
item: public_id,
|
returns {
|
||||||
file: oshash of source file
|
item: string, // item id
|
||||||
}
|
file: string // oshash of source file
|
||||||
|
}
|
||||||
'''
|
'''
|
||||||
f = None
|
f = None
|
||||||
qs = models.Stream.objects.filter(oshash=data['id'])
|
qs = models.Stream.objects.filter(oshash=data['id'])
|
||||||
|
|
|
@ -19,14 +19,14 @@ import models
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addEvent(request, data):
|
def addEvent(request, data):
|
||||||
'''
|
'''
|
||||||
Adds a calendar event
|
Adds a new calendar event
|
||||||
takes {
|
takes {
|
||||||
name: string,
|
end: string, // 'YYYY-MM-DD HH:MM:SS', arbitrary precision
|
||||||
start: string,
|
name: string, // name
|
||||||
end: string
|
start: string // 'YYYY-MM-DD HH:MM:SS', arbitrary precision
|
||||||
}
|
}
|
||||||
returns {
|
returns {
|
||||||
id: string
|
id: string // event id
|
||||||
}
|
}
|
||||||
see: editEvent, findEvents, removeEvents
|
see: editEvent, findEvents, removeEvents
|
||||||
'''
|
'''
|
||||||
|
@ -73,14 +73,15 @@ def editEvent(request, data):
|
||||||
'''
|
'''
|
||||||
Edits a calendar event
|
Edits a calendar event
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
end: string, // 'YYYY-MM-DD HH:MM:SS', arbitrary precision
|
||||||
name: string,
|
id: string, // event id
|
||||||
start: string,
|
name: string, // event name
|
||||||
end: string
|
start: string // 'YYYY-MM-DD HH:MM:SS', arbitrary precision
|
||||||
}
|
}
|
||||||
returns {
|
returns {
|
||||||
id: string,
|
id: string, // event id
|
||||||
...
|
key: value, // property id and value
|
||||||
|
... // more key/value pairs
|
||||||
}
|
}
|
||||||
see: addEvent, findEvents, removeEvent
|
see: addEvent, findEvents, removeEvent
|
||||||
'''
|
'''
|
||||||
|
@ -176,43 +177,14 @@ def findEvents(request, data):
|
||||||
'''
|
'''
|
||||||
Finds calendar events
|
Finds calendar events
|
||||||
takes {
|
takes {
|
||||||
query: object,
|
query: object, // query object, see `find`
|
||||||
sort: array
|
sort: [object], // list of sort objects, see `find`
|
||||||
range': [int, int]
|
range: [int, int] // range of results to return
|
||||||
}
|
}
|
||||||
|
returns {
|
||||||
query: query object, more on query syntax at
|
items: [object] // list of items
|
||||||
https://wiki.0x2620.org/wiki/pandora/QuerySyntax
|
}
|
||||||
itemsQuery: {
|
see: addEvent, editEvent, removeEvent
|
||||||
//see find request
|
|
||||||
},
|
|
||||||
sort: array of key, operator dics
|
|
||||||
[
|
|
||||||
{
|
|
||||||
key: "year",
|
|
||||||
operator: "-"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: "director",
|
|
||||||
operator: ""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
range: result range, array [from, to]
|
|
||||||
|
|
||||||
itemsQuery can be used to limit the resuts to matches in those items.
|
|
||||||
|
|
||||||
with keys, items is list of dicts with requested properties:
|
|
||||||
returns {'status': {'code': int, 'text': string},
|
|
||||||
'data': {items: array}}
|
|
||||||
|
|
||||||
Positions
|
|
||||||
takes {
|
|
||||||
query: object,
|
|
||||||
ids: [string]
|
|
||||||
}
|
|
||||||
query: query object, more on query syntax at
|
|
||||||
https://wiki.0x2620.org/wiki/pandora/QuerySyntax
|
|
||||||
ids: ids of events for which positions are required
|
|
||||||
'''
|
'''
|
||||||
response = json_response(status=200, text='ok')
|
response = json_response(status=200, text='ok')
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
|
|
@ -499,6 +499,7 @@ def add(request, data):
|
||||||
title: string, // title
|
title: string, // title
|
||||||
... // more item properties
|
... // more item properties
|
||||||
}
|
}
|
||||||
|
notes: To allow for this, set config option `itemRequiresVideo` to false
|
||||||
see: edit, find, get, lookup, remove, upload
|
see: edit, find, get, lookup, remove, upload
|
||||||
'''
|
'''
|
||||||
if not request.user.get_profile().capability('canAddItems'):
|
if not request.user.get_profile().capability('canAddItems'):
|
||||||
|
|
|
@ -141,12 +141,12 @@ def addListItems(request, data):
|
||||||
'''
|
'''
|
||||||
Adds one or more items to a list
|
Adds one or more items to a list
|
||||||
takes {
|
takes {
|
||||||
list: listId,
|
list: string, // list id
|
||||||
items: [itemId],
|
items: [string], // either list of item ids
|
||||||
query: ...
|
query: object // or query object, see `find`
|
||||||
}
|
|
||||||
returns {
|
|
||||||
}
|
}
|
||||||
|
returns {}
|
||||||
|
see: find, orderListItems, removeListItems
|
||||||
'''
|
'''
|
||||||
list = get_list_or_404_json(data['list'])
|
list = get_list_or_404_json(data['list'])
|
||||||
if 'items' in data:
|
if 'items' in data:
|
||||||
|
@ -171,12 +171,12 @@ def removeListItems(request, data):
|
||||||
'''
|
'''
|
||||||
Removes one or more items from a list
|
Removes one or more items from a list
|
||||||
takes {
|
takes {
|
||||||
list: listId,
|
list: string, // list id
|
||||||
items: [itemId],
|
items: [itemId], // either list of item ids
|
||||||
quert: ...
|
query: object // or query object, see `find`
|
||||||
}
|
|
||||||
returns {
|
|
||||||
}
|
}
|
||||||
|
returns {}
|
||||||
|
see: addListItems, find, orderListItems
|
||||||
'''
|
'''
|
||||||
list = get_list_or_404_json(data['list'])
|
list = get_list_or_404_json(data['list'])
|
||||||
if 'items' in data:
|
if 'items' in data:
|
||||||
|
@ -197,14 +197,14 @@ actions.register(removeListItems, cache=False)
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def orderListItems(request, data):
|
def orderListItems(request, data):
|
||||||
'''
|
'''
|
||||||
Sets the manual order of items in a given list
|
Sets the manual orderings of items in a given list
|
||||||
takes {
|
takes {
|
||||||
list: string
|
list: string, // list id
|
||||||
ids: [string]
|
ids: [string] // ordered list of item ids
|
||||||
}
|
|
||||||
returns {
|
|
||||||
}
|
}
|
||||||
|
returns {}
|
||||||
notes: There is no UI for this yet.
|
notes: There is no UI for this yet.
|
||||||
|
see: addListItems, removeListItems
|
||||||
'''
|
'''
|
||||||
list = get_list_or_404_json(data['list'])
|
list = get_list_or_404_json(data['list'])
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
@ -225,22 +225,16 @@ def addList(request, data):
|
||||||
'''
|
'''
|
||||||
Adds a new list
|
Adds a new list
|
||||||
takes {
|
takes {
|
||||||
name: value,
|
name: value, // list name (optional)
|
||||||
|
... // more key/value pairs
|
||||||
}
|
}
|
||||||
possible keys to create list:
|
|
||||||
name
|
|
||||||
description
|
|
||||||
type
|
|
||||||
query
|
|
||||||
items
|
|
||||||
view
|
|
||||||
sort
|
|
||||||
|
|
||||||
returns {
|
returns {
|
||||||
id: string,
|
id: string, // list id
|
||||||
name: string,
|
name: string, // list name
|
||||||
...
|
... // more key/value pairs
|
||||||
}
|
}
|
||||||
|
notes: Possible keys are 'description', 'items', 'name', 'query', 'sort',
|
||||||
|
'type' and 'view'.
|
||||||
see: editList, findLists, getList, removeList, sortLists
|
see: editList, findLists, getList, removeList, sortLists
|
||||||
'''
|
'''
|
||||||
data['name'] = re.sub(' \[\d+\]$', '', data.get('name', 'Untitled')).strip()
|
data['name'] = re.sub(' \[\d+\]$', '', data.get('name', 'Untitled')).strip()
|
||||||
|
@ -287,18 +281,18 @@ def editList(request, data):
|
||||||
'''
|
'''
|
||||||
Edits a list
|
Edits a list
|
||||||
takes {
|
takes {
|
||||||
id: listId,
|
id: string, // list id
|
||||||
key: value,
|
key: value, // property id and new value
|
||||||
|
... // more key/value pairs
|
||||||
}
|
}
|
||||||
keys: name, status, query, position, posterFrames
|
|
||||||
if you change status you have to provide position of list
|
|
||||||
|
|
||||||
posterFrames:
|
|
||||||
array with objects that have item/position
|
|
||||||
returns {
|
returns {
|
||||||
id: string,
|
id: string, // list id
|
||||||
...
|
... // more key/value pairs
|
||||||
}
|
}
|
||||||
|
notes: Possible keys are 'name', 'position', 'posterFrames', 'query' and
|
||||||
|
'status'. 'posterFrames' is an array of {item, position}. If you change
|
||||||
|
'status', you have to pass 'position' (the position of the list in its new
|
||||||
|
list folder).
|
||||||
see: addList, findLists, getList, removeList, sortLists
|
see: addList, findLists, getList, removeList, sortLists
|
||||||
'''
|
'''
|
||||||
list = get_list_or_404_json(data['id'])
|
list = get_list_or_404_json(data['id'])
|
||||||
|
@ -339,7 +333,8 @@ def subscribeToList(request, data):
|
||||||
'''
|
'''
|
||||||
Adds a list to favorites
|
Adds a list to favorites
|
||||||
takes {
|
takes {
|
||||||
id: listId,
|
id: string, // list id
|
||||||
|
user: string // username (admin-only)
|
||||||
}
|
}
|
||||||
returns {}
|
returns {}
|
||||||
see: unsubscribeFromList
|
see: unsubscribeFromList
|
||||||
|
@ -365,8 +360,8 @@ def unsubscribeFromList(request, data):
|
||||||
'''
|
'''
|
||||||
Removes a list from favorites
|
Removes a list from favorites
|
||||||
takes {
|
takes {
|
||||||
id: listId,
|
id: string, // list id
|
||||||
user: username(only admins)
|
user: string // username (admin-only)
|
||||||
}
|
}
|
||||||
returns {}
|
returns {}
|
||||||
see: subscribeToList
|
see: subscribeToList
|
||||||
|
@ -386,12 +381,12 @@ def sortLists(request, data):
|
||||||
'''
|
'''
|
||||||
Set order of lists
|
Set order of lists
|
||||||
takes {
|
takes {
|
||||||
section: 'personal',
|
section: string, // lists section
|
||||||
ids: [1,2,4,3]
|
ids: [string] // ordered list of lists
|
||||||
}
|
}
|
||||||
known sections: 'personal', 'public', 'featured'
|
|
||||||
featured can only be edited by admins
|
|
||||||
returns {}
|
returns {}
|
||||||
|
notes: Possible sections are 'personal', 'favorite' and 'featured'. Setting
|
||||||
|
the order of featured lists requires the appropriate capability.
|
||||||
'''
|
'''
|
||||||
position = 0
|
position = 0
|
||||||
section = data['section']
|
section = data['section']
|
||||||
|
|
|
@ -15,21 +15,25 @@ import models
|
||||||
|
|
||||||
def getNews(request, data):
|
def getNews(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
Gets one or all news items
|
||||||
id: string
|
takes {
|
||||||
}
|
id: string // news item id (optional)
|
||||||
|
}
|
||||||
returns {
|
returns { // if `id` is present
|
||||||
id: string,
|
id: string, // news item id
|
||||||
...
|
key: value, // property id and value
|
||||||
}
|
... // more key/value pairs
|
||||||
|
} or { // if `id` is missing
|
||||||
if not id is passed, return all news items
|
items: [
|
||||||
|
{
|
||||||
takes {}
|
id: string, // news item id
|
||||||
returns {
|
key: value, // property id and value
|
||||||
items: [object]
|
... // more key/value pairs
|
||||||
}
|
},
|
||||||
|
... // more news items
|
||||||
|
]
|
||||||
|
}
|
||||||
|
see: addNews, editNews, removeNews
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if 'id' in data:
|
if 'id' in data:
|
||||||
|
@ -44,15 +48,17 @@ actions.register(getNews)
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addNews(request, data):
|
def addNews(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
Adds a new news item
|
||||||
title: string,
|
takes {
|
||||||
date: string,
|
date: string, // date (format undocumented)
|
||||||
text: text,
|
text: text, // text
|
||||||
}
|
title: string // title
|
||||||
returns {
|
}
|
||||||
id: string,
|
returns {
|
||||||
...
|
id: string, // news item id
|
||||||
}
|
... // more key/value pairs
|
||||||
|
}
|
||||||
|
see: editNews, getNews, removeNews
|
||||||
'''
|
'''
|
||||||
news = models.News()
|
news = models.News()
|
||||||
for key in ('title', 'text', 'date'):
|
for key in ('title', 'text', 'date'):
|
||||||
|
@ -67,10 +73,12 @@ actions.register(addNews, cache=False)
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeNews(request, data):
|
def removeNews(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
Removes a news item
|
||||||
id: id
|
takes {
|
||||||
}
|
id: string // news item id
|
||||||
returns {}
|
}
|
||||||
|
returns {}
|
||||||
|
see: addNews, editNews, getNews
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
news = get_object_or_404_json(models.News, id=ox.fromAZ(data['id']))
|
news = get_object_or_404_json(models.News, id=ox.fromAZ(data['id']))
|
||||||
|
@ -86,16 +94,18 @@ actions.register(removeNews, cache=False)
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editNews(request, data):
|
def editNews(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
Edits a news item
|
||||||
id: string,
|
takes {
|
||||||
title: string,
|
date: string, // date (format undocumented)
|
||||||
text: string,
|
id: string, // news item id
|
||||||
date: string
|
text: string, // text
|
||||||
}
|
title: string // title
|
||||||
returns {
|
}
|
||||||
id: string
|
returns {
|
||||||
...
|
id: string
|
||||||
}
|
...
|
||||||
|
}
|
||||||
|
see: addNews, getNews, removeNews
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
n = get_object_or_404_json(models.News, id=ox.fromAZ(data['id']))
|
n = get_object_or_404_json(models.News, id=ox.fromAZ(data['id']))
|
||||||
|
|
|
@ -20,7 +20,7 @@ import models
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addPlace(request, data):
|
def addPlace(request, data):
|
||||||
'''
|
'''
|
||||||
Adds a place
|
Adds a new place
|
||||||
takes {
|
takes {
|
||||||
name: "",
|
name: "",
|
||||||
alternativeNames: [],
|
alternativeNames: [],
|
||||||
|
|
Loading…
Reference in a new issue