Example #1
0
def project_controller(request):
    """
    Project all feature :
        GET: Get all project of user
        POST: Create new project , Choose project
        DELETE: Delete project with param project_code
    :param request: contains data of project
    :return: the message is successful if done feature, otherwise the error message.
    """
    if request.method == 'POST':
        result = ProjectProcess.create_project(request)
    if request.method == 'GET':
        if 'project_code' in request.GET:
            result = ProjectProcess.choose_project(request)
        else:
            result = ProjectProcess.get_all_project(request)
    if request.method == 'DELETE':
        result = ProjectProcess.delete_project(request)
    if result.is_success():
        return JsonResponse(Resp.success(
            message=result.get_message(),
            data=result.get_data()).to_dict(), safe=False)
    else:
        return JsonResponse(Resp.error(message=result.get_message()).to_dict(),
                            safe=False)
Example #2
0
def turn_on_camera(request):
    result = ResCameraProcess.turn_on_camera(request)
    if result.is_success():
        return JsonResponse(Resp.success(
            message=result.get_message(),
            data=result.get_data()).to_dict(), safe=False)
    else:
        return JsonResponse(Resp.error(message=result.get_message()).to_dict(),
                            safe=False)
Example #3
0
def get_process(request):
    result = ChannelProcess.get_process(request)
    if result.is_success():
        return JsonResponse(Resp.success(
            message=result.get_message(),
            data=result.get_data()).to_dict(), safe=False)
    else:
        return JsonResponse(Resp.error(message=result.get_message()).to_dict(),
                            safe=False)
Example #4
0
def people_group_list_people(request):
    """
        check camera url
        :param request:
        :return: the message is successful if the information of project , otherwise the error message.
    """
    result = ResPeopleProcess.people_group_list_people(request)
    if result.is_success():
        return JsonResponse(Resp.success(
            message=result.get_message(),
            data=result.get_data()).to_dict(), safe=False)
    else:
        return JsonResponse(Resp.error(message=result.get_message()).to_dict(),
                            safe=False)
Example #5
0
def delete_camera_from_group(request):
    """
        delete camera from group
        :param request:
        :return: the message is successful if the information of project , otherwise the error message.
    """
    result = ResCameraProcess.delete_camera_from_group(request)
    if result.is_success():
        return JsonResponse(Resp.success(
            message=result.get_message(),
            data=result.get_data()).to_dict(), safe=False)
    else:
        return JsonResponse(Resp.error(message=result.get_message()).to_dict(),
                            safe=False)
Example #6
0
def import_person(request):
    """
        import person
        :param request:
        :return: the message is successful if the information of project , otherwise the error message.
    """
    result = ResPeopleProcess.import_person(request)
    if result.is_success():
        return JsonResponse(Resp.success(
            message=result.get_message(),
            data=result.get_data()).to_dict(), safe=False)
    else:
        return JsonResponse(Resp.error(message=result.get_message()).to_dict(),
                            safe=False)
Example #7
0
def change_password(request):
    result_logout_user = Authen.change_password(request)

    if result_logout_user.is_success():
        return JsonResponse(
            Resp.success(message=result_logout_user.get_message(),
                         data=result_logout_user.get_data()).to_dict(),
            safe=False,
        )
    else:
        return JsonResponse(
            Resp.error(message=result_logout_user.get_message()).to_dict(),
            safe=False,
        )
Example #8
0
def person_controller(request):
    if request.method == 'POST':
        result = ResPeopleProcess.add_person(request)
    if request.method == 'GET':
        result = ResPeopleProcess.get_all_person(request)
    if request.method == 'DELETE':
        result = ResPeopleProcess.delete_person(request)
    if request.method == 'PUT':
        result = ResPeopleProcess.update_person(request)
    if result.is_success():
        return JsonResponse(Resp.success(
            message=result.get_message(),
            data=result.get_data()).to_dict(), safe=False)
    else:
        return JsonResponse(Resp.error(message=result.get_message()).to_dict(),
                            safe=False)
Example #9
0
def profile_controller(request):
    if request.method == 'GET':
        result = Authen.get_profile(request)
    if request.method == 'PUT':
        result = Authen.set_profile(request)
    if result.is_success():
        return JsonResponse(
            Resp.success(message=result.get_message(),
                         data=result.get_data()).to_dict(),
            safe=False,
        )
    else:
        return JsonResponse(
            Resp.error(message=result.get_message()).to_dict(),
            safe=False,
        )
Example #10
0
def function_controller(request):
    """
        Function Controller
            POST: add new function with data: project_id, function_id
        :param request: contains data of function
        :return: the message is successful if success, otherwise the error message.
    """
    if request.method == 'POST':
        result = ProjectProcess.add_function(request)
    if request.method == 'GET':
        result = ProjectProcess.get_function_project(request)
    if result.is_success():
        return JsonResponse(Resp.success(
            message=result.get_message(),
            data=result.get_data()).to_dict(), safe=False)
    else:
        return JsonResponse(Resp.error(message=result.get_message()).to_dict(),
                            safe=False)
Example #11
0
def camera_group_controller(request):
    if request.method == 'POST':
        result = ResCameraProcess.add_camera_group(request)
    if request.method == 'DELETE':
        result = ResCameraProcess.delete_camera_group(request)
    if request.method == 'PUT':
        result = ResCameraProcess.update_camera_group(request)
    if request.method == 'GET':
        if 'camera_group_id' in request.GET:
            result = ResCameraProcess.get_camera_group_data(request)
        else:
            result = ResCameraProcess.get_all_camera_group(request)
    if result.is_success():
        return JsonResponse(Resp.success(
            message=result.get_message(),
            data=result.get_data()).to_dict(), safe=False)
    else:
        return JsonResponse(Resp.error(message=result.get_message()).to_dict(),
                            safe=False)
Example #12
0
def login(request):
    """
    Login with user account
    :param request: contains information and data that the user sends
    :return: returns the token and user id if user login successfully,
    otherwise the error message.
    """

    result_login_user = Authen.login(request)

    if result_login_user.is_success():
        return JsonResponse(Resp.success(
            message=result_login_user.get_message(),
            data=result_login_user.get_data()).to_dict(),
                            safe=False)
    else:
        return JsonResponse(
            Resp.error(message=result_login_user.get_message()).to_dict(),
            safe=False)
Example #13
0
def signup(request):
    """
    Register a new administrator account
    :param request: contains information and data that the user sends
    :return: returns the token and user id if the new user was created
    successfully, otherwise return the error message.
    """

    result_create_user = Authen.create(request)

    if result_create_user.is_success():
        return JsonResponse(Resp.success(
            message=result_create_user.get_message(),
            data=result_create_user.get_data()).to_dict(),
                            safe=False)
    else:
        return JsonResponse(
            Resp.error(message=result_create_user.get_message()).to_dict(),
            safe=False)
Example #14
0
def logout(request):
    """
    Log out of user accounts
    :param request: contains information and data that the user sends
    :return: the message is successful if the user has logged out of
    the system, otherwise the error message.
    """

    result_logout_user = Authen.logout(request)

    if result_logout_user.is_success():
        return JsonResponse(
            Resp.success(message=result_logout_user.get_message(),
                         data=result_logout_user.get_data()).to_dict(),
            safe=False,
        )
    else:
        return JsonResponse(
            Resp.error(message=result_logout_user.get_message()).to_dict(),
            safe=False,
        )