Esempio n. 1
0
def list(request):
    dataRequired = []
    if request.GET.get("forum"):
        dataRequired = ["forum"]
    if request.GET.get("thread"):
        if dataRequired:
            dataResponse = tools.getResponse(
                "INVALID REQUEST", "There are two or more entity required")
            return HttpResponse(dataResponse, content_type='application/json')
        dataRequired = ["thread"]
    if request.GET.get("user"):
        if dataRequired:
            dataResponse = tools.getResponse(
                "INVALID REQUEST", "There are two or more entity required")
            return HttpResponse(dataResponse, content_type='application/json')
        dataRequired = ["user"]
    if not dataRequired:
        dataResponse = tools.getResponse("INVALID REQUEST",
                                         "There aren't any entity required")
        return HttpResponse(dataResponse, content_type='application/json')
    dataPosible = ["since", "limit", "sort", "order"]
    dataRelated = []
    dataRequest = {}
    dataRequest = tools.getGetParametersDataRequest(request, dataRequired,
                                                    dataPosible, dataRelated)
    posts = api.dbOperations.post.list(dataRequest)
    dataResponse = tools.getResponse("OK", posts)
    return HttpResponse(dataResponse, content_type='application/json')
Esempio n. 2
0
def listPosts(request):
	dataRequired = ["user"]
	dataPosible = ["limit","order","since"]
	dataRelated = []
	dataRequest = {}
	dataRequest = tools.getGetParametersDataRequest(request,dataRequired,dataPosible,dataRelated)
	posts = api.dbOperations.user.listPosts(dataRequest)
	dataResponse = tools.getResponse("OK",posts)
	return HttpResponse(dataResponse, content_type='application/json')
Esempio n. 3
0
def details(request):
	dataRequired = ["user"]
	dataPosible = []
	dataRelated = []
	dataRequest = {}
	dataRequest = tools.getGetParametersDataRequest(request,dataRequired,dataPosible,dataRelated)
	user = api.dbOperations.user.details(dataRequest)
	dataResponse = tools.getResponse("OK",user)
	return HttpResponse(dataResponse, content_type='application/json')
Esempio n. 4
0
def listPosts(request):
	dataRequired = ["thread"]
	dataPosible = ["limit","order","since","sort"]
	dataRelated = []
	dataRequest = {}
	dataRequest = tools.getGetParametersDataRequest(request,dataRequired,dataPosible,dataRelated)
	posts = api.dbOperations.thread.listPosts(dataRequest)
	dataResponse = tools.getResponse("OK",posts)
	return HttpResponse(dataResponse, content_type='application/json')
Esempio n. 5
0
def details(request):
	dataRequired = ["thread"]
	dataPosible = ["related"]
	dataRelated = ["user","forum"]
	dataRequest = {}
	dataRequest = tools.getGetParametersDataRequest(request,dataRequired,dataPosible,dataRelated)
	thread = api.dbOperations.thread.details(dataRequest)
	dataResponse = tools.getResponse("OK",thread)
	return HttpResponse(dataResponse, content_type='application/json')
Esempio n. 6
0
def listUsers(request):
	dataRequired = ["forum"]
	dataPosible = ["since_id","limit","order"]
	dataRelated = []
	dataRequest = {}
	dataRequest = tools.getGetParametersDataRequest(request,dataRequired,dataPosible,dataRelated)
	users = api.dbOperations.forum.listUsers(dataRequest)
	dataResponse = tools.getResponse("OK",users)
	return HttpResponse(dataResponse, content_type='application/json')
Esempio n. 7
0
def details(request):
    dataRequired = ["thread"]
    dataPosible = ["related"]
    dataRelated = ["user", "forum"]
    dataRequest = {}
    dataRequest = tools.getGetParametersDataRequest(request, dataRequired,
                                                    dataPosible, dataRelated)
    thread = api.dbOperations.thread.details(dataRequest)
    dataResponse = tools.getResponse("OK", thread)
    return HttpResponse(dataResponse, content_type='application/json')
Esempio n. 8
0
def list(request):
	dataRequired = []
	if request.GET.get("forum"):
		dataRequired = ["forum"]
	if request.GET.get("user"):
		if dataRequired:
			dataResponse = tools.getResponse("INVALID REQUEST","There are two or more entity required")
			return HttpResponse(dataResponse, content_type='application/json')
		dataRequired = ["user"]
	if not dataRequired:
		dataResponse = tools.getResponse("INVALID REQUEST","There aren't any entity required")
		return HttpResponse(dataResponse, content_type='application/json')
	dataPosible = ["since","limit","order"]
	dataRelated = []
	dataRequest = {}
	dataRequest = tools.getGetParametersDataRequest(request,dataRequired,dataPosible,dataRelated)
	threads = api.dbOperations.thread.list(dataRequest)
	dataResponse = tools.getResponse("OK",threads)
	return HttpResponse(dataResponse, content_type='application/json')