data is passed to api functions now
This commit is contained in:
parent
5e130a7c9b
commit
ceb507020b
19 changed files with 126 additions and 238 deletions
|
@ -61,7 +61,7 @@ def order_query(qs, sort):
|
||||||
qs = qs.order_by(*order_by, nulls_last=True)
|
qs = qs.order_by(*order_by, nulls_last=True)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def findAnnotations(request):
|
def findAnnotations(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -82,7 +82,6 @@ def findAnnotations(request):
|
||||||
annotations = [{..}, {...}, ...]
|
annotations = [{..}, {...}, ...]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
@ -111,7 +110,7 @@ actions.register(findAnnotations)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addAnnotation(request):
|
def addAnnotation(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
item: public_id,
|
item: public_id,
|
||||||
|
@ -125,7 +124,6 @@ def addAnnotation(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
for key in ('item', 'layer', 'in', 'out', 'value'):
|
for key in ('item', 'layer', 'in', 'out', 'value'):
|
||||||
if key not in data:
|
if key not in data:
|
||||||
return render_to_json_response(json_response(status=400,
|
return render_to_json_response(json_response(status=400,
|
||||||
|
@ -152,7 +150,7 @@ def addAnnotation(request):
|
||||||
actions.register(addAnnotation, cache=False)
|
actions.register(addAnnotation, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addAnnotations(request):
|
def addAnnotations(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
item: public_id,
|
item: public_id,
|
||||||
|
@ -167,7 +165,6 @@ def addAnnotations(request):
|
||||||
taskId: string
|
taskId: string
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
for key in ('item', 'layer', 'annotations'):
|
for key in ('item', 'layer', 'annotations'):
|
||||||
if key not in data:
|
if key not in data:
|
||||||
return render_to_json_response(json_response(status=400,
|
return render_to_json_response(json_response(status=400,
|
||||||
|
@ -189,7 +186,7 @@ def addAnnotations(request):
|
||||||
actions.register(addAnnotations, cache=False)
|
actions.register(addAnnotations, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeAnnotation(request):
|
def removeAnnotation(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: annotationId
|
id: annotationId
|
||||||
|
@ -198,7 +195,6 @@ def removeAnnotation(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
a = get_object_or_404_json(models.Annotation, public_id=data['id'])
|
a = get_object_or_404_json(models.Annotation, public_id=data['id'])
|
||||||
if a.editable(request.user):
|
if a.editable(request.user):
|
||||||
a.log()
|
a.log()
|
||||||
|
@ -210,7 +206,7 @@ actions.register(removeAnnotation, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editAnnotation(request):
|
def editAnnotation(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id:,
|
id:,
|
||||||
|
@ -224,7 +220,6 @@ def editAnnotation(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
a = get_object_or_404_json(models.Annotation, public_id=data['id'])
|
a = get_object_or_404_json(models.Annotation, public_id=data['id'])
|
||||||
if a.editable(request.user):
|
if a.editable(request.user):
|
||||||
a.log()
|
a.log()
|
||||||
|
|
|
@ -93,7 +93,7 @@ def robots_txt(request, url):
|
||||||
'text/plain'
|
'text/plain'
|
||||||
)
|
)
|
||||||
|
|
||||||
def getPage(request):
|
def getPage(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
name: pagename
|
name: pagename
|
||||||
|
@ -103,7 +103,6 @@ def getPage(request):
|
||||||
text:
|
text:
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if isinstance(data, basestring):
|
if isinstance(data, basestring):
|
||||||
name = data
|
name = data
|
||||||
else:
|
else:
|
||||||
|
@ -118,7 +117,7 @@ actions.register(getPage)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editPage(request):
|
def editPage(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
name: pagename
|
name: pagename
|
||||||
|
@ -130,7 +129,6 @@ def editPage(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
if request.user.get_profile().capability('canEditSitePages'):
|
if request.user.get_profile().capability('canEditSitePages'):
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
page, created = models.Page.objects.get_or_create(name=data['name'])
|
page, created = models.Page.objects.get_or_create(name=data['name'])
|
||||||
if not created:
|
if not created:
|
||||||
page.log()
|
page.log()
|
||||||
|
@ -143,7 +141,7 @@ def editPage(request):
|
||||||
actions.register(editPage)
|
actions.register(editPage)
|
||||||
|
|
||||||
|
|
||||||
def init(request):
|
def init(request, data):
|
||||||
'''
|
'''
|
||||||
takes {}
|
takes {}
|
||||||
returns {
|
returns {
|
||||||
|
@ -162,7 +160,7 @@ def init(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(init)
|
actions.register(init)
|
||||||
|
|
||||||
def embedURL(request):
|
def embedURL(request, data):
|
||||||
'''
|
'''
|
||||||
|
|
||||||
takes {
|
takes {
|
||||||
|
@ -175,13 +173,12 @@ def embedURL(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
response['data'] = ox.get_embed_code(data['url'], data.get('maxwidth'), data.get('maxheight'))
|
response['data'] = ox.get_embed_code(data['url'], data.get('maxwidth'), data.get('maxheight'))
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(embedURL)
|
actions.register(embedURL)
|
||||||
|
|
||||||
def getEmbedDefaults(request):
|
def getEmbedDefaults(request, data):
|
||||||
'''
|
'''
|
||||||
takes {}
|
takes {}
|
||||||
returns {
|
returns {
|
||||||
|
@ -202,7 +199,6 @@ def getEmbedDefaults(request):
|
||||||
from itemlist.models import List
|
from itemlist.models import List
|
||||||
from edit.models import Edit
|
from edit.models import Edit
|
||||||
from text.models import Text
|
from text.models import Text
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
qs = Document.objects.filter(uploading=False).order_by('id')
|
qs = Document.objects.filter(uploading=False).order_by('id')
|
||||||
if qs.exists():
|
if qs.exists():
|
||||||
|
|
|
@ -27,8 +27,7 @@ from chunk import process_chunk
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeVolume(request):
|
def removeVolume(request, data):
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
user = request.user
|
user = request.user
|
||||||
try:
|
try:
|
||||||
volume = models.Volume.objects.get(user=user, name=data['volume'])
|
volume = models.Volume.objects.get(user=user, name=data['volume'])
|
||||||
|
@ -42,7 +41,7 @@ actions.register(removeVolume, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def update(request):
|
def update(request, data):
|
||||||
'''
|
'''
|
||||||
2 steps:
|
2 steps:
|
||||||
send files
|
send files
|
||||||
|
@ -67,7 +66,6 @@ def update(request):
|
||||||
file: list // list of files that should be uploaded as is
|
file: list // list of files that should be uploaded as is
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
user = request.user
|
user = request.user
|
||||||
upload_only = data.get('upload', False)
|
upload_only = data.get('upload', False)
|
||||||
|
|
||||||
|
@ -109,7 +107,7 @@ actions.register(update, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def upload(request):
|
def upload(request, data=None):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string
|
id: string
|
||||||
|
@ -156,7 +154,7 @@ actions.register(upload, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addMedia(request):
|
def addMedia(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: oshash
|
id: oshash
|
||||||
|
@ -169,7 +167,6 @@ def addMedia(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
oshash = data.pop('id')
|
oshash = data.pop('id')
|
||||||
if not request.user.get_profile().capability('canAddItems'):
|
if not request.user.get_profile().capability('canAddItems'):
|
||||||
response = json_response(status=403, text='permission denied')
|
response = json_response(status=403, text='permission denied')
|
||||||
|
@ -324,9 +321,8 @@ def direct_upload(request):
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def taskStatus(request):
|
def taskStatus(request, data):
|
||||||
#FIXME: should check if user has permissions to get status
|
#FIXME: should check if user has permissions to get status
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if 'taskId' in data:
|
if 'taskId' in data:
|
||||||
task_id = data['taskId']
|
task_id = data['taskId']
|
||||||
else:
|
else:
|
||||||
|
@ -337,7 +333,7 @@ actions.register(taskStatus, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def moveMedia(request):
|
def moveMedia(request, data):
|
||||||
'''
|
'''
|
||||||
change file / item link
|
change file / item link
|
||||||
takes {
|
takes {
|
||||||
|
@ -348,7 +344,6 @@ def moveMedia(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
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'])
|
||||||
else:
|
else:
|
||||||
|
@ -384,7 +379,7 @@ def moveMedia(request):
|
||||||
actions.register(moveMedia, cache=False)
|
actions.register(moveMedia, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editMedia(request):
|
def editMedia(request, data):
|
||||||
'''
|
'''
|
||||||
change file / item link
|
change file / item link
|
||||||
takes {
|
takes {
|
||||||
|
@ -398,8 +393,6 @@ def editMedia(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
|
|
||||||
ignore = []
|
ignore = []
|
||||||
save_items = []
|
save_items = []
|
||||||
dont_ignore = []
|
dont_ignore = []
|
||||||
|
@ -443,8 +436,7 @@ actions.register(editMedia, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeMedia(request):
|
def removeMedia(request, data):
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
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)
|
||||||
|
@ -461,7 +453,7 @@ def removeMedia(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(removeMedia, cache=False)
|
actions.register(removeMedia, cache=False)
|
||||||
|
|
||||||
def getPath(request):
|
def getPath(request, data):
|
||||||
'''
|
'''
|
||||||
change file / item link
|
change file / item link
|
||||||
takes {
|
takes {
|
||||||
|
@ -472,7 +464,6 @@ def getPath(request):
|
||||||
id: path
|
id: path
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
ids = data['id']
|
ids = data['id']
|
||||||
if isinstance(ids, basestring):
|
if isinstance(ids, basestring):
|
||||||
|
@ -517,7 +508,7 @@ def _order_query(qs, sort, prefix=''):
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
|
|
||||||
def findMedia(request):
|
def findMedia(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
'query': query,
|
'query': query,
|
||||||
|
@ -591,7 +582,6 @@ Positions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if not data.get('sort'):
|
if not data.get('sort'):
|
||||||
data['sort'] = [{'key': 'path', 'operator': '+'}]
|
data['sort'] = [{'key': 'path', 'operator': '+'}]
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
@ -655,7 +645,7 @@ Positions
|
||||||
|
|
||||||
actions.register(findMedia)
|
actions.register(findMedia)
|
||||||
|
|
||||||
def parsePath(request): #parse path and return info
|
def parsePath(request, data): #parse path and return info
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
path: string
|
path: string
|
||||||
|
@ -664,12 +654,12 @@ def parsePath(request): #parse path and return info
|
||||||
imdb: string
|
imdb: string
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
path = json.loads(request.POST['data'])['path']
|
path = data['path']
|
||||||
response = json_response(ox.parse_movie_path(path))
|
response = json_response(ox.parse_movie_path(path))
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(parsePath)
|
actions.register(parsePath)
|
||||||
|
|
||||||
def getMediaInfo(request):
|
def getMediaInfo(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: oshash of stream file
|
id: oshash of stream file
|
||||||
|
@ -679,7 +669,6 @@ def getMediaInfo(request):
|
||||||
file: oshash of source file
|
file: oshash of source file
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
f = None
|
f = None
|
||||||
qs = models.Stream.objects.filter(oshash=data['id'])
|
qs = models.Stream.objects.filter(oshash=data['id'])
|
||||||
if qs.count() > 0:
|
if qs.count() > 0:
|
||||||
|
|
|
@ -71,7 +71,7 @@ def order_query(qs, sort):
|
||||||
qs = qs.order_by(*order_by, nulls_last=True)
|
qs = qs.order_by(*order_by, nulls_last=True)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def findClips(request):
|
def findClips(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -93,7 +93,6 @@ def findClips(request):
|
||||||
items: [object]
|
items: [object]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
|
|
@ -26,7 +26,7 @@ def get_document_or_404_json(id):
|
||||||
raise HttpErrorJson(response)
|
raise HttpErrorJson(response)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addDocument(request):
|
def addDocument(request, data):
|
||||||
'''
|
'''
|
||||||
add document(s) to item
|
add document(s) to item
|
||||||
takes {
|
takes {
|
||||||
|
@ -40,7 +40,6 @@ def addDocument(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if 'ids' in data:
|
if 'ids' in data:
|
||||||
ids = data['ids']
|
ids = data['ids']
|
||||||
else:
|
else:
|
||||||
|
@ -64,7 +63,7 @@ def addDocument(request):
|
||||||
actions.register(addDocument, cache=False)
|
actions.register(addDocument, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editDocument(request):
|
def editDocument(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string
|
id: string
|
||||||
|
@ -78,7 +77,6 @@ def editDocument(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
item = 'item' in data and Item.objects.get(public_id=data['item']) or None
|
item = 'item' in data and Item.objects.get(public_id=data['item']) or None
|
||||||
if data['id']:
|
if data['id']:
|
||||||
document = models.Document.get(data['id'])
|
document = models.Document.get(data['id'])
|
||||||
|
@ -136,7 +134,7 @@ def parse_query(data, user):
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|
||||||
def findDocuments(request):
|
def findDocuments(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -165,7 +163,6 @@ def findDocuments(request):
|
||||||
items: [object]
|
items: [object]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
|
||||||
#order
|
#order
|
||||||
|
@ -190,7 +187,7 @@ def findDocuments(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(findDocuments)
|
actions.register(findDocuments)
|
||||||
|
|
||||||
def getDocument(request):
|
def getDocument(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -201,7 +198,6 @@ def getDocument(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
data['keys'] = data.get('keys', [])
|
data['keys'] = data.get('keys', [])
|
||||||
document = get_document_or_404_json(data['id'])
|
document = get_document_or_404_json(data['id'])
|
||||||
response['data'] = document.json(keys=data['keys'], user=request.user)
|
response['data'] = document.json(keys=data['keys'], user=request.user)
|
||||||
|
@ -209,7 +205,7 @@ def getDocument(request):
|
||||||
actions.register(getDocument)
|
actions.register(getDocument)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeDocument(request):
|
def removeDocument(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -223,7 +219,6 @@ def removeDocument(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
|
||||||
if 'ids' in data:
|
if 'ids' in data:
|
||||||
|
@ -250,7 +245,7 @@ def removeDocument(request):
|
||||||
actions.register(removeDocument, cache=False)
|
actions.register(removeDocument, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def sortDocuments(request):
|
def sortDocuments(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
item: string
|
item: string
|
||||||
|
@ -259,7 +254,6 @@ def sortDocuments(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
index = 0
|
index = 0
|
||||||
item = Item.objects.get(public_id=data['item'])
|
item = Item.objects.get(public_id=data['item'])
|
||||||
ids = data['ids']
|
ids = data['ids']
|
||||||
|
|
|
@ -25,7 +25,7 @@ def get_edit_or_404_json(id):
|
||||||
return get_object_or_404_json(models.Edit, user__username=username, name=name)
|
return get_object_or_404_json(models.Edit, user__username=username, name=name)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addClips(request):
|
def addClips(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
edit: string,
|
edit: string,
|
||||||
|
@ -43,7 +43,6 @@ def addClips(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
edit = get_edit_or_404_json(data['edit'])
|
edit = get_edit_or_404_json(data['edit'])
|
||||||
clips = []
|
clips = []
|
||||||
if edit.editable(request.user):
|
if edit.editable(request.user):
|
||||||
|
@ -65,7 +64,7 @@ actions.register(addClips, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeClips(request):
|
def removeClips(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
edit: string
|
edit: string
|
||||||
|
@ -75,7 +74,6 @@ def removeClips(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
edit = get_edit_or_404_json(data['edit'])
|
edit = get_edit_or_404_json(data['edit'])
|
||||||
if 'id' in data:
|
if 'id' in data:
|
||||||
ids = [data['id']]
|
ids = [data['id']]
|
||||||
|
@ -92,7 +90,7 @@ def removeClips(request):
|
||||||
actions.register(removeClips, cache=False)
|
actions.register(removeClips, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editClip(request):
|
def editClip(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -103,7 +101,6 @@ def editClip(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
clip = get_object_or_404_json(models.Clip, pk=ox.fromAZ(data['id']))
|
clip = get_object_or_404_json(models.Clip, pk=ox.fromAZ(data['id']))
|
||||||
valid = True
|
valid = True
|
||||||
if clip.edit.editable(request.user):
|
if clip.edit.editable(request.user):
|
||||||
|
@ -129,7 +126,7 @@ def editClip(request):
|
||||||
actions.register(editClip, cache=False)
|
actions.register(editClip, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def orderClips(request):
|
def orderClips(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
edit: string
|
edit: string
|
||||||
|
@ -138,7 +135,6 @@ def orderClips(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
edit = get_edit_or_404_json(data['edit'])
|
edit = get_edit_or_404_json(data['edit'])
|
||||||
response = json_response()
|
response = json_response()
|
||||||
ids = map(ox.fromAZ, data['ids'])
|
ids = map(ox.fromAZ, data['ids'])
|
||||||
|
@ -187,7 +183,7 @@ def _order_clips(edit, sort):
|
||||||
qs = qs.distinct()
|
qs = qs.distinct()
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def sortClips(request):
|
def sortClips(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
edit: string
|
edit: string
|
||||||
|
@ -196,7 +192,6 @@ def sortClips(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
edit = get_edit_or_404_json(data['edit'])
|
edit = get_edit_or_404_json(data['edit'])
|
||||||
response = json_response()
|
response = json_response()
|
||||||
clips = _order_clips(edit, data['sort'])
|
clips = _order_clips(edit, data['sort'])
|
||||||
|
@ -204,7 +199,7 @@ def sortClips(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(sortClips, cache=False)
|
actions.register(sortClips, cache=False)
|
||||||
|
|
||||||
def getEdit(request):
|
def getEdit(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id:
|
id:
|
||||||
|
@ -215,7 +210,6 @@ def getEdit(request):
|
||||||
clips:
|
clips:
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if 'id' in data:
|
if 'id' in data:
|
||||||
response = json_response()
|
response = json_response()
|
||||||
edit = get_edit_or_404_json(data['id'])
|
edit = get_edit_or_404_json(data['id'])
|
||||||
|
@ -229,7 +223,7 @@ def getEdit(request):
|
||||||
actions.register(getEdit)
|
actions.register(getEdit)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addEdit(request):
|
def addEdit(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
[name],
|
[name],
|
||||||
|
@ -240,7 +234,6 @@ def addEdit(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
data['name'] = re.sub(' \[\d+\]$', '', data.get('name', 'Untitled')).strip()
|
data['name'] = re.sub(' \[\d+\]$', '', data.get('name', 'Untitled')).strip()
|
||||||
name = data['name']
|
name = data['name']
|
||||||
if not name:
|
if not name:
|
||||||
|
@ -284,7 +277,7 @@ def addEdit(request):
|
||||||
actions.register(addEdit, cache=False)
|
actions.register(addEdit, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editEdit(request):
|
def editEdit(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id
|
id
|
||||||
|
@ -293,7 +286,6 @@ def editEdit(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
edit = get_edit_or_404_json(data['id'])
|
edit = get_edit_or_404_json(data['id'])
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if edit.editable(request.user):
|
if edit.editable(request.user):
|
||||||
|
@ -309,7 +301,7 @@ def editEdit(request):
|
||||||
actions.register(editEdit, cache=False)
|
actions.register(editEdit, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeEdit(request):
|
def removeEdit(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
...
|
...
|
||||||
|
@ -318,7 +310,6 @@ def removeEdit(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
edit = get_edit_or_404_json(data['id'])
|
edit = get_edit_or_404_json(data['id'])
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if edit.editable(request.user):
|
if edit.editable(request.user):
|
||||||
|
@ -358,7 +349,7 @@ def parse_query(data, user):
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|
||||||
def findEdits(request):
|
def findEdits(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -387,7 +378,6 @@ def findEdits(request):
|
||||||
items: [object]
|
items: [object]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
|
||||||
#order
|
#order
|
||||||
|
@ -423,14 +413,13 @@ def findEdits(request):
|
||||||
actions.register(findEdits)
|
actions.register(findEdits)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def subscribeToEdit(request):
|
def subscribeToEdit(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
}
|
}
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
edit = get_edit_or_404_json(data['id'])
|
edit = get_edit_or_404_json(data['id'])
|
||||||
user = request.user
|
user = request.user
|
||||||
if edit.status == 'public' and \
|
if edit.status == 'public' and \
|
||||||
|
@ -447,7 +436,7 @@ actions.register(subscribeToEdit, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def unsubscribeFromEdit(request):
|
def unsubscribeFromEdit(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -455,7 +444,6 @@ def unsubscribeFromEdit(request):
|
||||||
}
|
}
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
edit = get_edit_or_404_json(data['id'])
|
edit = get_edit_or_404_json(data['id'])
|
||||||
user = request.user
|
user = request.user
|
||||||
edit.subscribed_users.remove(user)
|
edit.subscribed_users.remove(user)
|
||||||
|
@ -466,7 +454,7 @@ actions.register(unsubscribeFromEdit, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def sortEdits(request):
|
def sortEdits(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
section: 'personal',
|
section: 'personal',
|
||||||
|
@ -477,7 +465,6 @@ def sortEdits(request):
|
||||||
|
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
position = 0
|
position = 0
|
||||||
section = data['section']
|
section = data['section']
|
||||||
section = {
|
section = {
|
||||||
|
|
|
@ -16,7 +16,7 @@ from item import utils
|
||||||
import models
|
import models
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addEvent(request):
|
def addEvent(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -27,7 +27,6 @@ def addEvent(request):
|
||||||
id: string
|
id: string
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
existing_names = []
|
existing_names = []
|
||||||
exists = False
|
exists = False
|
||||||
names = [data['name']] + data.get('alternativeNames', [])
|
names = [data['name']] + data.get('alternativeNames', [])
|
||||||
|
@ -66,7 +65,7 @@ actions.register(addEvent, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editEvent(request):
|
def editEvent(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -79,7 +78,6 @@ def editEvent(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
event = get_object_or_404_json(models.Event, pk=ox.fromAZ(data['id']))
|
event = get_object_or_404_json(models.Event, pk=ox.fromAZ(data['id']))
|
||||||
if event.editable(request.user):
|
if event.editable(request.user):
|
||||||
conflict = False
|
conflict = False
|
||||||
|
@ -120,7 +118,7 @@ actions.register(editEvent, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeEvent(request):
|
def removeEvent(request, data):
|
||||||
'''
|
'''
|
||||||
remove Event with given id
|
remove Event with given id
|
||||||
takes {
|
takes {
|
||||||
|
@ -128,7 +126,6 @@ def removeEvent(request):
|
||||||
}
|
}
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
event = get_object_or_404_json(models.Event, pk=ox.fromAZ(data['id']))
|
event = get_object_or_404_json(models.Event, pk=ox.fromAZ(data['id']))
|
||||||
if event.editable(request.user):
|
if event.editable(request.user):
|
||||||
event.delete()
|
event.delete()
|
||||||
|
@ -166,7 +163,7 @@ def order_query(qs, sort):
|
||||||
qs = qs.order_by(*order_by, nulls_last=True)
|
qs = qs.order_by(*order_by, nulls_last=True)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def findEvents(request):
|
def findEvents(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: object,
|
query: object,
|
||||||
|
@ -208,8 +205,6 @@ Positions
|
||||||
ids: ids of events for which positions are required
|
ids: ids of events for which positions are required
|
||||||
'''
|
'''
|
||||||
response = json_response(status=200, text='ok')
|
response = json_response(status=200, text='ok')
|
||||||
|
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
qs = order_query(query['qs'], query['sort'])
|
qs = order_query(query['qs'], query['sort'])
|
||||||
qs = qs.distinct()
|
qs = qs.distinct()
|
||||||
|
@ -237,7 +232,7 @@ Positions
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(findEvents)
|
actions.register(findEvents)
|
||||||
|
|
||||||
def getEventNames(request):
|
def getEventNames(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,7 +97,7 @@ def parse_query(data, user):
|
||||||
#group by only allows sorting by name or number of itmes
|
#group by only allows sorting by name or number of itmes
|
||||||
return query
|
return query
|
||||||
|
|
||||||
def find(request):
|
def find(request, data):
|
||||||
'''
|
'''
|
||||||
Example:
|
Example:
|
||||||
find({
|
find({
|
||||||
|
@ -183,7 +183,6 @@ Positions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if settings.JSON_DEBUG:
|
if settings.JSON_DEBUG:
|
||||||
print json.dumps(data, indent=2)
|
print json.dumps(data, indent=2)
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
@ -305,7 +304,7 @@ Positions
|
||||||
actions.register(find)
|
actions.register(find)
|
||||||
|
|
||||||
|
|
||||||
def autocomplete(request):
|
def autocomplete(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
key: string,
|
key: string,
|
||||||
|
@ -318,7 +317,6 @@ def autocomplete(request):
|
||||||
items: [string, ...] //array of matching values
|
items: [string, ...] //array of matching values
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if not 'range' in data:
|
if not 'range' in data:
|
||||||
data['range'] = [0, 10]
|
data['range'] = [0, 10]
|
||||||
op = data.get('operator', '=')
|
op = data.get('operator', '=')
|
||||||
|
@ -369,7 +367,7 @@ def autocomplete(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(autocomplete)
|
actions.register(autocomplete)
|
||||||
|
|
||||||
def findId(request):
|
def findId(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
'id': string
|
'id': string
|
||||||
|
@ -378,7 +376,6 @@ def findId(request):
|
||||||
'year': int
|
'year': int
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
response['data']['items'] = []
|
response['data']['items'] = []
|
||||||
if 'id' in data:
|
if 'id' in data:
|
||||||
|
@ -398,7 +395,7 @@ def findId(request):
|
||||||
actions.register(findId)
|
actions.register(findId)
|
||||||
|
|
||||||
|
|
||||||
def getMetadata(request):
|
def getMetadata(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -411,7 +408,6 @@ def getMetadata(request):
|
||||||
}
|
}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
if settings.DATA_SERVICE:
|
if settings.DATA_SERVICE:
|
||||||
'''
|
'''
|
||||||
|
@ -431,7 +427,7 @@ def getMetadata(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(getMetadata)
|
actions.register(getMetadata)
|
||||||
|
|
||||||
def getIds(request):
|
def getIds(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
title: string,
|
title: string,
|
||||||
|
@ -448,7 +444,6 @@ def getIds(request):
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
if settings.DATA_SERVICE:
|
if settings.DATA_SERVICE:
|
||||||
r = models.external_data('getIds', data)
|
r = models.external_data('getIds', data)
|
||||||
|
@ -459,7 +454,7 @@ def getIds(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(getIds)
|
actions.register(getIds)
|
||||||
|
|
||||||
def get(request):
|
def get(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -470,7 +465,6 @@ def get(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
data['keys'] = data.get('keys', [])
|
data['keys'] = data.get('keys', [])
|
||||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||||
if item.access(request.user):
|
if item.access(request.user):
|
||||||
|
@ -501,7 +495,7 @@ def get(request):
|
||||||
actions.register(get)
|
actions.register(get)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def add(request):
|
def add(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
title: string, //(optional)
|
title: string, //(optional)
|
||||||
|
@ -516,7 +510,6 @@ def add(request):
|
||||||
if not request.user.get_profile().capability('canAddItems'):
|
if not request.user.get_profile().capability('canAddItems'):
|
||||||
response = json_response(status=403, text='permissino denied')
|
response = json_response(status=403, text='permissino denied')
|
||||||
else:
|
else:
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
data['title'] = data.get('title', 'Untitled')
|
data['title'] = data.get('title', 'Untitled')
|
||||||
i = models.Item()
|
i = models.Item()
|
||||||
i.data['title'] = data['title']
|
i.data['title'] = data['title']
|
||||||
|
@ -532,7 +525,7 @@ def add(request):
|
||||||
actions.register(add, cache=False)
|
actions.register(add, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def edit(request):
|
def edit(request, data):
|
||||||
'''
|
'''
|
||||||
edit item with id, you can pass one or many key/value pairs,
|
edit item with id, you can pass one or many key/value pairs,
|
||||||
returns all key/values for edited item.
|
returns all key/values for edited item.
|
||||||
|
@ -548,7 +541,6 @@ def edit(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
update_clips = False
|
update_clips = False
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||||
if item.editable(request.user):
|
if item.editable(request.user):
|
||||||
item.log()
|
item.log()
|
||||||
|
@ -579,7 +571,7 @@ def edit(request):
|
||||||
actions.register(edit, cache=False)
|
actions.register(edit, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def remove(request):
|
def remove(request, data):
|
||||||
'''
|
'''
|
||||||
remove item with id, return status is 200/removed on sucess or 403/permission deinied.
|
remove item with id, return status is 200/removed on sucess or 403/permission deinied.
|
||||||
takes {
|
takes {
|
||||||
|
@ -590,7 +582,6 @@ def remove(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||||
user = request.user
|
user = request.user
|
||||||
if user.get_profile().capability('canRemoveItems') == True or \
|
if user.get_profile().capability('canRemoveItems') == True or \
|
||||||
|
@ -606,7 +597,7 @@ def remove(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(remove, cache=False)
|
actions.register(remove, cache=False)
|
||||||
|
|
||||||
def setPosterFrame(request):
|
def setPosterFrame(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -615,7 +606,6 @@ def setPosterFrame(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||||
if item.editable(request.user):
|
if item.editable(request.user):
|
||||||
item.poster_frame = data['position']
|
item.poster_frame = data['position']
|
||||||
|
@ -628,7 +618,7 @@ def setPosterFrame(request):
|
||||||
actions.register(setPosterFrame, cache=False)
|
actions.register(setPosterFrame, cache=False)
|
||||||
|
|
||||||
|
|
||||||
def setPoster(request):
|
def setPoster(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -642,7 +632,6 @@ def setPoster(request):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if item.editable(request.user):
|
if item.editable(request.user):
|
||||||
|
@ -662,7 +651,7 @@ def setPoster(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(setPoster, cache=False)
|
actions.register(setPoster, cache=False)
|
||||||
|
|
||||||
def updateExternalData(request):
|
def updateExternalData(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -670,7 +659,6 @@ def updateExternalData(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
item = get_object_or_404_json(models.Item, public_id=data['id'])
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if item.editable(request.user):
|
if item.editable(request.user):
|
||||||
|
@ -680,7 +668,7 @@ def updateExternalData(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(updateExternalData, cache=False)
|
actions.register(updateExternalData, cache=False)
|
||||||
|
|
||||||
def lookup(request):
|
def lookup(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
title: string,
|
title: string,
|
||||||
|
@ -695,7 +683,6 @@ def lookup(request):
|
||||||
id: string
|
id: string
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if 'id' in data:
|
if 'id' in data:
|
||||||
i = models.Item.objects.get(public_id=data['id'])
|
i = models.Item.objects.get(public_id=data['id'])
|
||||||
r = {'id': i.public_id}
|
r = {'id': i.public_id}
|
||||||
|
|
|
@ -55,7 +55,7 @@ def parse_query(data, user):
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|
||||||
def findLists(request):
|
def findLists(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -84,7 +84,6 @@ def findLists(request):
|
||||||
items: [{name: string, user: string, featured: bool, public...}]
|
items: [{name: string, user: string, featured: bool, public...}]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
|
||||||
#order
|
#order
|
||||||
|
@ -119,7 +118,7 @@ def findLists(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(findLists)
|
actions.register(findLists)
|
||||||
|
|
||||||
def getList(request):
|
def getList(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: listid
|
id: listid
|
||||||
|
@ -130,7 +129,6 @@ def getList(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if 'id' in data:
|
if 'id' in data:
|
||||||
response = json_response()
|
response = json_response()
|
||||||
list = get_list_or_404_json(data['id'])
|
list = get_list_or_404_json(data['id'])
|
||||||
|
@ -144,7 +142,7 @@ def getList(request):
|
||||||
actions.register(getList)
|
actions.register(getList)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addListItems(request):
|
def addListItems(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
list: listId,
|
list: listId,
|
||||||
|
@ -154,7 +152,6 @@ def addListItems(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
list = get_list_or_404_json(data['list'])
|
list = get_list_or_404_json(data['list'])
|
||||||
if 'items' in data:
|
if 'items' in data:
|
||||||
if list.editable(request.user):
|
if list.editable(request.user):
|
||||||
|
@ -173,7 +170,7 @@ actions.register(addListItems, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeListItems(request):
|
def removeListItems(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
list: listId,
|
list: listId,
|
||||||
|
@ -183,7 +180,6 @@ def removeListItems(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
list = get_list_or_404_json(data['list'])
|
list = get_list_or_404_json(data['list'])
|
||||||
if 'items' in data:
|
if 'items' in data:
|
||||||
if list.editable(request.user):
|
if list.editable(request.user):
|
||||||
|
@ -200,7 +196,7 @@ def removeListItems(request):
|
||||||
actions.register(removeListItems, cache=False)
|
actions.register(removeListItems, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def orderListItems(request):
|
def orderListItems(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
list: string
|
list: string
|
||||||
|
@ -209,7 +205,6 @@ def orderListItems(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
list = get_list_or_404_json(data['list'])
|
list = get_list_or_404_json(data['list'])
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if list.editable(request.user) and list.type == 'static':
|
if list.editable(request.user) and list.type == 'static':
|
||||||
|
@ -225,7 +220,7 @@ actions.register(orderListItems, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addList(request):
|
def addList(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
name: value,
|
name: value,
|
||||||
|
@ -245,7 +240,6 @@ def addList(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
data['name'] = re.sub(' \[\d+\]$', '', data.get('name', 'Untitled')).strip()
|
data['name'] = re.sub(' \[\d+\]$', '', data.get('name', 'Untitled')).strip()
|
||||||
name = data['name']
|
name = data['name']
|
||||||
if not name:
|
if not name:
|
||||||
|
@ -285,7 +279,7 @@ actions.register(addList, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editList(request):
|
def editList(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: listId,
|
id: listId,
|
||||||
|
@ -301,7 +295,6 @@ def editList(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
list = get_list_or_404_json(data['id'])
|
list = get_list_or_404_json(data['id'])
|
||||||
if list.editable(request.user):
|
if list.editable(request.user):
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
@ -313,7 +306,7 @@ def editList(request):
|
||||||
actions.register(editList, cache=False)
|
actions.register(editList, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeList(request):
|
def removeList(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: listId,
|
id: listId,
|
||||||
|
@ -321,7 +314,6 @@ def removeList(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
list = get_list_or_404_json(data['id'])
|
list = get_list_or_404_json(data['id'])
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if list.editable(request.user):
|
if list.editable(request.user):
|
||||||
|
@ -334,7 +326,7 @@ actions.register(removeList, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def subscribeToList(request):
|
def subscribeToList(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: listId,
|
id: listId,
|
||||||
|
@ -342,7 +334,6 @@ def subscribeToList(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
list = get_list_or_404_json(data['id'])
|
list = get_list_or_404_json(data['id'])
|
||||||
user = request.user
|
user = request.user
|
||||||
if list.status == 'public' and \
|
if list.status == 'public' and \
|
||||||
|
@ -359,7 +350,7 @@ actions.register(subscribeToList, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def unsubscribeFromList(request):
|
def unsubscribeFromList(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: listId,
|
id: listId,
|
||||||
|
@ -368,7 +359,6 @@ def unsubscribeFromList(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
list = get_list_or_404_json(data['id'])
|
list = get_list_or_404_json(data['id'])
|
||||||
user = request.user
|
user = request.user
|
||||||
list.subscribed_users.remove(user)
|
list.subscribed_users.remove(user)
|
||||||
|
@ -379,7 +369,7 @@ actions.register(unsubscribeFromList, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def sortLists(request):
|
def sortLists(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
section: 'personal',
|
section: 'personal',
|
||||||
|
@ -390,7 +380,6 @@ def sortLists(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
position = 0
|
position = 0
|
||||||
section = data['section']
|
section = data['section']
|
||||||
section = {
|
section = {
|
||||||
|
|
|
@ -15,7 +15,7 @@ from item import utils
|
||||||
import models
|
import models
|
||||||
|
|
||||||
|
|
||||||
def log(request):
|
def log(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
url: string,
|
url: string,
|
||||||
|
@ -25,7 +25,6 @@ def log(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
user = request.user
|
user = request.user
|
||||||
else:
|
else:
|
||||||
|
@ -48,14 +47,13 @@ actions.register(log, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@admin_required_json
|
@admin_required_json
|
||||||
def removeLogs(request):
|
def removeLogs(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
ids: [string]
|
ids: [string]
|
||||||
}
|
}
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
models.Log.objects.filter(id__in=[ox.fromAZ(i) for i in data['ids']]).delete()
|
models.Log.objects.filter(id__in=[ox.fromAZ(i) for i in data['ids']]).delete()
|
||||||
response = json_response()
|
response = json_response()
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
@ -86,7 +84,7 @@ def order_query(qs, sort):
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
@admin_required_json
|
@admin_required_json
|
||||||
def findLogs(request):
|
def findLogs(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -108,7 +106,6 @@ def findLogs(request):
|
||||||
}
|
}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
|
|
@ -12,7 +12,7 @@ from ox.django.api import actions
|
||||||
|
|
||||||
import models
|
import models
|
||||||
|
|
||||||
def getNews(request):
|
def getNews(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string
|
id: string
|
||||||
|
@ -30,7 +30,6 @@ def getNews(request):
|
||||||
items: [object]
|
items: [object]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if 'id' in data:
|
if 'id' in data:
|
||||||
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']))
|
||||||
|
@ -42,7 +41,7 @@ def getNews(request):
|
||||||
actions.register(getNews)
|
actions.register(getNews)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addNews(request):
|
def addNews(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
title: string,
|
title: string,
|
||||||
|
@ -54,8 +53,6 @@ def addNews(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
|
|
||||||
news = models.News()
|
news = models.News()
|
||||||
for key in ('title', 'text', 'date'):
|
for key in ('title', 'text', 'date'):
|
||||||
if key in data:
|
if key in data:
|
||||||
|
@ -66,14 +63,13 @@ def addNews(request):
|
||||||
actions.register(addNews, cache=False)
|
actions.register(addNews, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeNews(request):
|
def removeNews(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
ids: []
|
ids: []
|
||||||
}
|
}
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
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']))
|
||||||
if news.editable(request.user):
|
if news.editable(request.user):
|
||||||
|
@ -85,7 +81,7 @@ def removeNews(request):
|
||||||
actions.register(removeNews, cache=False)
|
actions.register(removeNews, cache=False)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editNews(request):
|
def editNews(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -99,7 +95,6 @@ def editNews(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response({})
|
response = json_response({})
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
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']))
|
||||||
if n.editable(request.user):
|
if n.editable(request.user):
|
||||||
for key in ('title', 'text', 'date'):
|
for key in ('title', 'text', 'date'):
|
||||||
|
|
|
@ -15,7 +15,7 @@ import models
|
||||||
import tasks
|
import tasks
|
||||||
|
|
||||||
@admin_required_json
|
@admin_required_json
|
||||||
def editName(request):
|
def editName(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: id,
|
id: id,
|
||||||
|
@ -27,7 +27,6 @@ def editName(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
person = get_object_or_404_json(models.Person, pk=ox.fromAZ(data['id']))
|
person = get_object_or_404_json(models.Person, pk=ox.fromAZ(data['id']))
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if 'sortname' in data:
|
if 'sortname' in data:
|
||||||
|
@ -39,7 +38,7 @@ def editName(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(editName, cache=False)
|
actions.register(editName, cache=False)
|
||||||
|
|
||||||
def sortName(request):
|
def sortName(request, data):
|
||||||
'''
|
'''
|
||||||
get sort name(s) for given name or names
|
get sort name(s) for given name or names
|
||||||
takes {
|
takes {
|
||||||
|
@ -50,7 +49,6 @@ def sortName(request):
|
||||||
name: sortName
|
name: sortName
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
names = data.get('names', [])
|
names = data.get('names', [])
|
||||||
if 'name' in data:
|
if 'name' in data:
|
||||||
names.append(data['name'])
|
names.append(data['name'])
|
||||||
|
@ -89,7 +87,7 @@ def order_query(qs, sort):
|
||||||
qs = qs.order_by(*order_by, nulls_last=True)
|
qs = qs.order_by(*order_by, nulls_last=True)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def findNames(request):
|
def findNames(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -142,7 +140,6 @@ def findNames(request):
|
||||||
items: [string]
|
items: [string]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
|
|
@ -17,7 +17,7 @@ from item import utils
|
||||||
import models
|
import models
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addPlace(request):
|
def addPlace(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
name: "",
|
name: "",
|
||||||
|
@ -38,7 +38,6 @@ def addPlace(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
#FIXME: check permissions
|
#FIXME: check permissions
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
exists = False
|
exists = False
|
||||||
existing_names = []
|
existing_names = []
|
||||||
existing_geoname = ''
|
existing_geoname = ''
|
||||||
|
@ -96,7 +95,7 @@ actions.register(addPlace, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editPlace(request):
|
def editPlace(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -107,7 +106,6 @@ def editPlace(request):
|
||||||
names: []
|
names: []
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
place = get_object_or_404_json(models.Place, pk=ox.fromAZ(data['id']))
|
place = get_object_or_404_json(models.Place, pk=ox.fromAZ(data['id']))
|
||||||
names = data.get('name', [])
|
names = data.get('name', [])
|
||||||
if isinstance(names, basestring):
|
if isinstance(names, basestring):
|
||||||
|
@ -161,14 +159,13 @@ actions.register(editPlace, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removePlace(request):
|
def removePlace(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
}
|
}
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if isinstance(data, dict):
|
if isinstance(data, dict):
|
||||||
data = data['id']
|
data = data['id']
|
||||||
place = get_object_or_404_json(models.Place, pk=ox.fromAZ(data))
|
place = get_object_or_404_json(models.Place, pk=ox.fromAZ(data))
|
||||||
|
@ -209,7 +206,7 @@ def order_query(qs, sort):
|
||||||
qs = qs.order_by(*order_by, nulls_last=True)
|
qs = qs.order_by(*order_by, nulls_last=True)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def findPlaces(request):
|
def findPlaces(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -276,7 +273,6 @@ Positions
|
||||||
https://wiki.0x2620.org/wiki/pandora/QuerySyntax
|
https://wiki.0x2620.org/wiki/pandora/QuerySyntax
|
||||||
positions: ids of places for which positions are required
|
positions: ids of places for which positions are required
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
@ -311,7 +307,7 @@ Positions
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(findPlaces)
|
actions.register(findPlaces)
|
||||||
|
|
||||||
def getPlaceNames(request):
|
def getPlaceNames(request, data):
|
||||||
'''
|
'''
|
||||||
takes {}
|
takes {}
|
||||||
returns {
|
returns {
|
||||||
|
|
|
@ -48,7 +48,7 @@ def order_query(qs, sort):
|
||||||
qs = qs.order_by(*order_by, nulls_last=True)
|
qs = qs.order_by(*order_by, nulls_last=True)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def findSequences(request):
|
def findSequences(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: ...
|
query: ...
|
||||||
|
@ -61,7 +61,6 @@ def findSequences(request):
|
||||||
items: [object]
|
items: [object]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
@ -91,7 +90,7 @@ def findSequences(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(findSequences)
|
actions.register(findSequences)
|
||||||
|
|
||||||
def getSequence(request):
|
def getSequence(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id
|
id
|
||||||
|
@ -106,7 +105,6 @@ def getSequence(request):
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
position = float('%0.03f' % data['position'])
|
position = float('%0.03f' % data['position'])
|
||||||
i = Item.objects.get(public_id=data['id'])
|
i = Item.objects.get(public_id=data['id'])
|
||||||
|
|
|
@ -27,7 +27,7 @@ def get_text_or_404_json(id):
|
||||||
return get_object_or_404_json(models.Text, user__username=username, name=name)
|
return get_object_or_404_json(models.Text, user__username=username, name=name)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def addText(request):
|
def addText(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
name: value,
|
name: value,
|
||||||
|
@ -38,7 +38,6 @@ def addText(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
data['name'] = re.sub(' \[\d+\]$', '', data.get('name', 'Untitled')).strip()
|
data['name'] = re.sub(' \[\d+\]$', '', data.get('name', 'Untitled')).strip()
|
||||||
name = data['name']
|
name = data['name']
|
||||||
if not name:
|
if not name:
|
||||||
|
@ -71,7 +70,7 @@ def addText(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(addText, cache=False)
|
actions.register(addText, cache=False)
|
||||||
|
|
||||||
def getText(request):
|
def getText(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: textid,
|
id: textid,
|
||||||
|
@ -84,7 +83,6 @@ def getText(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
public_id = data['id']
|
public_id = data['id']
|
||||||
if public_id == '':
|
if public_id == '':
|
||||||
qs = models.Text.objects.filter(name='')
|
qs = models.Text.objects.filter(name='')
|
||||||
|
@ -111,7 +109,7 @@ actions.register(getText)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editText(request):
|
def editText(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id:
|
id:
|
||||||
|
@ -125,7 +123,6 @@ def editText(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if data['id']:
|
if data['id']:
|
||||||
public_id = data['id'].split(':')
|
public_id = data['id'].split(':')
|
||||||
username = public_id[0]
|
username = public_id[0]
|
||||||
|
@ -183,7 +180,7 @@ def parse_query(data, user):
|
||||||
return query
|
return query
|
||||||
|
|
||||||
|
|
||||||
def findTexts(request):
|
def findTexts(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -212,7 +209,6 @@ def findTexts(request):
|
||||||
items: [object]
|
items: [object]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
|
||||||
#order
|
#order
|
||||||
|
@ -249,7 +245,7 @@ actions.register(findTexts)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def removeText(request):
|
def removeText(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -257,7 +253,6 @@ def removeText(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
text = get_text_or_404_json(data['id'])
|
text = get_text_or_404_json(data['id'])
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if text.editable(request.user):
|
if text.editable(request.user):
|
||||||
|
@ -269,14 +264,13 @@ actions.register(removeText, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def subscribeToText(request):
|
def subscribeToText(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
}
|
}
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
text = get_text_or_404_json(data['id'])
|
text = get_text_or_404_json(data['id'])
|
||||||
user = request.user
|
user = request.user
|
||||||
if text.status == 'public' and \
|
if text.status == 'public' and \
|
||||||
|
@ -293,7 +287,7 @@ actions.register(subscribeToText, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def unsubscribeFromText(request):
|
def unsubscribeFromText(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -301,7 +295,6 @@ def unsubscribeFromText(request):
|
||||||
}
|
}
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
text = get_text_or_404_json(data['id'])
|
text = get_text_or_404_json(data['id'])
|
||||||
user = request.user
|
user = request.user
|
||||||
text.subscribed_users.remove(user)
|
text.subscribed_users.remove(user)
|
||||||
|
@ -312,7 +305,7 @@ actions.register(unsubscribeFromText, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def sortTexts(request):
|
def sortTexts(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
section: 'personal',
|
section: 'personal',
|
||||||
|
@ -323,7 +316,6 @@ def sortTexts(request):
|
||||||
|
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
position = 0
|
position = 0
|
||||||
section = data['section']
|
section = data['section']
|
||||||
section = {
|
section = {
|
||||||
|
|
|
@ -15,7 +15,7 @@ from item import utils
|
||||||
import models
|
import models
|
||||||
|
|
||||||
@admin_required_json
|
@admin_required_json
|
||||||
def editTitle(request):
|
def editTitle(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string
|
id: string
|
||||||
|
@ -26,7 +26,6 @@ def editTitle(request):
|
||||||
id: string
|
id: string
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
title = get_object_or_404_json(models.Title, pk=ox.fromAZ(data['id']))
|
title = get_object_or_404_json(models.Title, pk=ox.fromAZ(data['id']))
|
||||||
response = json_response()
|
response = json_response()
|
||||||
if 'sorttitle' in data:
|
if 'sorttitle' in data:
|
||||||
|
@ -66,7 +65,7 @@ def order_query(qs, sort):
|
||||||
qs = qs.order_by(*order_by, nulls_last=True)
|
qs = qs.order_by(*order_by, nulls_last=True)
|
||||||
return qs
|
return qs
|
||||||
|
|
||||||
def findTitles(request):
|
def findTitles(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -122,7 +121,6 @@ def findTitles(request):
|
||||||
returns {items: [object]}
|
returns {items: [object]}
|
||||||
|
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
|
|
|
@ -9,7 +9,7 @@ from ox.django.shortcuts import render_to_json_response, json_response
|
||||||
from itemlist.views import get_list_or_404_json
|
from itemlist.views import get_list_or_404_json
|
||||||
from ox.django.api import actions
|
from ox.django.api import actions
|
||||||
|
|
||||||
def tv(request):
|
def tv(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
list: string
|
list: string
|
||||||
|
@ -21,7 +21,6 @@ def tv(request):
|
||||||
...
|
...
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if 'list' in data and data['list']:
|
if 'list' in data and data['list']:
|
||||||
list = get_list_or_404_json(data['list'])
|
list = get_list_or_404_json(data['list'])
|
||||||
if list.accessible(request.user):
|
if list.accessible(request.user):
|
||||||
|
|
|
@ -18,8 +18,7 @@ import requests
|
||||||
import models
|
import models
|
||||||
|
|
||||||
|
|
||||||
def signin(request):
|
def signin(request, data):
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response({
|
response = json_response({
|
||||||
'errors': {
|
'errors': {
|
||||||
'email': 'Failed to verify email'
|
'email': 'Failed to verify email'
|
||||||
|
|
|
@ -43,7 +43,7 @@ def get_group_or_404(data):
|
||||||
return g
|
return g
|
||||||
|
|
||||||
|
|
||||||
def signin(request):
|
def signin(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
username: string,
|
username: string,
|
||||||
|
@ -60,7 +60,6 @@ def signin(request):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if 'assertion' in data:
|
if 'assertion' in data:
|
||||||
response = persona.signin(request)
|
response = persona.signin(request)
|
||||||
elif 'username' in data and 'password' in data:
|
elif 'username' in data and 'password' in data:
|
||||||
|
@ -106,7 +105,7 @@ def signin(request):
|
||||||
actions.register(signin, cache=False)
|
actions.register(signin, cache=False)
|
||||||
|
|
||||||
|
|
||||||
def signout(request):
|
def signout(request, data):
|
||||||
'''
|
'''
|
||||||
takes {}
|
takes {}
|
||||||
|
|
||||||
|
@ -130,7 +129,7 @@ def signout(request):
|
||||||
actions.register(signout, cache=False)
|
actions.register(signout, cache=False)
|
||||||
|
|
||||||
|
|
||||||
def signup(request):
|
def signup(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
username: string,
|
username: string,
|
||||||
|
@ -148,7 +147,6 @@ def signup(request):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if 'username' in data and 'password' in data:
|
if 'username' in data and 'password' in data:
|
||||||
data['username'] = data['username'].strip()
|
data['username'] = data['username'].strip()
|
||||||
if 'email' in data:
|
if 'email' in data:
|
||||||
|
@ -215,7 +213,7 @@ def signup(request):
|
||||||
actions.register(signup, cache=False)
|
actions.register(signup, cache=False)
|
||||||
|
|
||||||
|
|
||||||
def resetPassword(request):
|
def resetPassword(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
username: string,
|
username: string,
|
||||||
|
@ -231,7 +229,6 @@ def resetPassword(request):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if 'code' in data and 'password' in data:
|
if 'code' in data and 'password' in data:
|
||||||
if not data['password']:
|
if not data['password']:
|
||||||
response = json_response({
|
response = json_response({
|
||||||
|
@ -268,7 +265,7 @@ def resetPassword(request):
|
||||||
actions.register(resetPassword, cache=False)
|
actions.register(resetPassword, cache=False)
|
||||||
|
|
||||||
|
|
||||||
def requestToken(request):
|
def requestToken(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
username: string,
|
username: string,
|
||||||
|
@ -283,7 +280,6 @@ def requestToken(request):
|
||||||
username: user
|
username: user
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
user = None
|
user = None
|
||||||
if 'username' in data:
|
if 'username' in data:
|
||||||
try:
|
try:
|
||||||
|
@ -334,7 +330,7 @@ actions.register(requestToken, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@capability_required_json('canManageUsers')
|
@capability_required_json('canManageUsers')
|
||||||
def editUser(request):
|
def editUser(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
key: value
|
key: value
|
||||||
|
@ -346,7 +342,6 @@ def editUser(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
user = get_object_or_404_json(User, pk=ox.fromAZ(data['id']))
|
user = get_object_or_404_json(User, pk=ox.fromAZ(data['id']))
|
||||||
|
|
||||||
profile = user.get_profile()
|
profile = user.get_profile()
|
||||||
|
@ -390,7 +385,7 @@ actions.register(editUser, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@capability_required_json('canManageUsers')
|
@capability_required_json('canManageUsers')
|
||||||
def removeUser(request):
|
def removeUser(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
username: username
|
username: username
|
||||||
|
@ -398,14 +393,13 @@ def removeUser(request):
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.load(request.POST['data'])
|
|
||||||
u = get_user_or_404(data)
|
u = get_user_or_404(data)
|
||||||
u.delete()
|
u.delete()
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(removeUser, cache=False)
|
actions.register(removeUser, cache=False)
|
||||||
|
|
||||||
|
|
||||||
def findUser(request):
|
def findUser(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
key: string, //username, email
|
key: string, //username, email
|
||||||
|
@ -418,7 +412,6 @@ def findUser(request):
|
||||||
users: [object]
|
users: [object]
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response = json_response(status=200, text='ok')
|
response = json_response(status=200, text='ok')
|
||||||
#keys = data.get('keys')
|
#keys = data.get('keys')
|
||||||
#if not keys:
|
#if not keys:
|
||||||
|
@ -481,7 +474,7 @@ def order_query(qs, sort):
|
||||||
|
|
||||||
|
|
||||||
@capability_required_json('canManageUsers')
|
@capability_required_json('canManageUsers')
|
||||||
def findUsers(request):
|
def findUsers(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
query: {
|
query: {
|
||||||
|
@ -545,7 +538,6 @@ Positions
|
||||||
positions: ids of places for which positions are required
|
positions: ids of places for which positions are required
|
||||||
'''
|
'''
|
||||||
response = json_response(status=200, text='ok')
|
response = json_response(status=200, text='ok')
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
query = parse_query(data, request.user)
|
query = parse_query(data, request.user)
|
||||||
qs = order_query(query['qs'], query['sort'])
|
qs = order_query(query['qs'], query['sort'])
|
||||||
if 'keys' in data:
|
if 'keys' in data:
|
||||||
|
@ -575,7 +567,7 @@ actions.register(findUsers)
|
||||||
|
|
||||||
|
|
||||||
@capability_required_json('canManageUsers')
|
@capability_required_json('canManageUsers')
|
||||||
def getUser(request):
|
def getUser(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string or username: string,
|
id: string or username: string,
|
||||||
|
@ -587,14 +579,13 @@ def getUser(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
u = get_user_or_404(data)
|
u = get_user_or_404(data)
|
||||||
response['data'] = u.data.get().json(data.get('keys', []), request.user)
|
response['data'] = u.data.get().json(data.get('keys', []), request.user)
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(getUser)
|
actions.register(getUser)
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def mail(request):
|
def mail(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
to: [string], // array of usernames to send mail to
|
to: [string], // array of usernames to send mail to
|
||||||
|
@ -610,7 +601,6 @@ def mail(request):
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
p = request.user.get_profile()
|
p = request.user.get_profile()
|
||||||
if p.capability('canSendMail'):
|
if p.capability('canSendMail'):
|
||||||
email_from = '"%s" <%s>' % (settings.SITENAME, settings.CONFIG['site']['email']['system'])
|
email_from = '"%s" <%s>' % (settings.SITENAME, settings.CONFIG['site']['email']['system'])
|
||||||
|
@ -658,7 +648,7 @@ def mail(request):
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(mail, cache=False)
|
actions.register(mail, cache=False)
|
||||||
|
|
||||||
def contact(request):
|
def contact(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
email: string,
|
email: string,
|
||||||
|
@ -669,7 +659,6 @@ def contact(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
name = data.get('name', '')
|
name = data.get('name', '')
|
||||||
email = data.get('email', '')
|
email = data.get('email', '')
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
|
@ -731,7 +720,7 @@ def getPositionById(list, key):
|
||||||
|
|
||||||
|
|
||||||
@login_required_json
|
@login_required_json
|
||||||
def editPreferences(request):
|
def editPreferences(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
key: value
|
key: value
|
||||||
|
@ -739,7 +728,6 @@ def editPreferences(request):
|
||||||
keys: email, password
|
keys: email, password
|
||||||
returns {}
|
returns {}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
errors = {}
|
errors = {}
|
||||||
change = False
|
change = False
|
||||||
response = json_response()
|
response = json_response()
|
||||||
|
@ -775,7 +763,7 @@ def reset_ui(request):
|
||||||
return redirect('/')
|
return redirect('/')
|
||||||
|
|
||||||
|
|
||||||
def resetUI(request):
|
def resetUI(request, data):
|
||||||
'''
|
'''
|
||||||
reset user ui settings to defaults
|
reset user ui settings to defaults
|
||||||
takes {
|
takes {
|
||||||
|
@ -795,7 +783,7 @@ def resetUI(request):
|
||||||
actions.register(resetUI, cache=False)
|
actions.register(resetUI, cache=False)
|
||||||
|
|
||||||
|
|
||||||
def setUI(request):
|
def setUI(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
key.subkey: value
|
key.subkey: value
|
||||||
|
@ -806,7 +794,6 @@ def setUI(request):
|
||||||
returns {
|
returns {
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
if request.user.is_authenticated():
|
if request.user.is_authenticated():
|
||||||
profile = request.user.get_profile()
|
profile = request.user.get_profile()
|
||||||
ui = profile.ui
|
ui = profile.ui
|
||||||
|
@ -848,8 +835,12 @@ actions.register(setUI, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@capability_required_json('canManageUsers')
|
@capability_required_json('canManageUsers')
|
||||||
def statistics(request):
|
def statistics(request, data):
|
||||||
'''
|
'''
|
||||||
|
takes {}
|
||||||
|
returns {
|
||||||
|
...
|
||||||
|
}
|
||||||
'''
|
'''
|
||||||
response = json_response()
|
response = json_response()
|
||||||
from app.models import Settings
|
from app.models import Settings
|
||||||
|
@ -873,7 +864,7 @@ def group_json(g):
|
||||||
|
|
||||||
|
|
||||||
@capability_required_json('canManageUsers')
|
@capability_required_json('canManageUsers')
|
||||||
def getGroups(request):
|
def getGroups(request, data):
|
||||||
'''
|
'''
|
||||||
takes {}
|
takes {}
|
||||||
returns {
|
returns {
|
||||||
|
@ -884,7 +875,6 @@ def getGroups(request):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
response = json_response(status=200, text='ok')
|
response = json_response(status=200, text='ok')
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
response['data']['groups'] = []
|
response['data']['groups'] = []
|
||||||
for g in Group.objects.all().order_by('name'):
|
for g in Group.objects.all().order_by('name'):
|
||||||
response['data']['groups'].append(group_json(g))
|
response['data']['groups'].append(group_json(g))
|
||||||
|
@ -893,7 +883,7 @@ actions.register(getGroups)
|
||||||
|
|
||||||
|
|
||||||
@capability_required_json('canManageUsers')
|
@capability_required_json('canManageUsers')
|
||||||
def getGroup(request):
|
def getGroup(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string
|
id: string
|
||||||
|
@ -909,7 +899,6 @@ def getGroup(request):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
response = json_response(status=200, text='ok')
|
response = json_response(status=200, text='ok')
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
g = get_group_or_404(data)
|
g = get_group_or_404(data)
|
||||||
response['data'] = group_json(g)
|
response['data'] = group_json(g)
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
@ -917,7 +906,7 @@ actions.register(getGroup, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@capability_required_json('canManageUsers')
|
@capability_required_json('canManageUsers')
|
||||||
def addGroup(request):
|
def addGroup(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
name: string
|
name: string
|
||||||
|
@ -931,7 +920,6 @@ def addGroup(request):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
response = json_response(status=200, text='ok')
|
response = json_response(status=200, text='ok')
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
created = False
|
created = False
|
||||||
n = 1
|
n = 1
|
||||||
name = data['name']
|
name = data['name']
|
||||||
|
@ -946,7 +934,7 @@ actions.register(addGroup, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@capability_required_json('canManageUsers')
|
@capability_required_json('canManageUsers')
|
||||||
def editGroup(request):
|
def editGroup(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string,
|
id: string,
|
||||||
|
@ -960,7 +948,6 @@ def editGroup(request):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
response = json_response(status=200, text='ok')
|
response = json_response(status=200, text='ok')
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
g = Group.objects.get(id=ox.fromAZ(data['id']))
|
g = Group.objects.get(id=ox.fromAZ(data['id']))
|
||||||
g.name = data['name']
|
g.name = data['name']
|
||||||
g.save()
|
g.save()
|
||||||
|
@ -970,7 +957,7 @@ actions.register(editGroup, cache=False)
|
||||||
|
|
||||||
|
|
||||||
@capability_required_json('canManageUsers')
|
@capability_required_json('canManageUsers')
|
||||||
def removeGroup(request):
|
def removeGroup(request, data):
|
||||||
'''
|
'''
|
||||||
takes {
|
takes {
|
||||||
id: string
|
id: string
|
||||||
|
@ -980,7 +967,6 @@ def removeGroup(request):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
response = json_response(status=200, text='ok')
|
response = json_response(status=200, text='ok')
|
||||||
data = json.loads(request.POST['data'])
|
|
||||||
g = get_group_or_404(data)
|
g = get_group_or_404(data)
|
||||||
for i in g.items.all():
|
for i in g.items.all():
|
||||||
i.groups.remove(g)
|
i.groups.remove(g)
|
||||||
|
|
Loading…
Reference in a new issue