Ejemplo n.º 1
0
def tap_detail(request, meter_name_or_id):
    tap = get_tap_from_meter_name_or_404(meter_name_or_id)
    if request.method == 'POST':
        util.check_api_key(request)
        return _tap_detail_post(request, tap)
    elif request.method == 'GET':
        return _tap_detail_get(request, tap)
    else:
        raise kbapi.BadRequestError('Method not supported')
Ejemplo n.º 2
0
def tap_detail(request, meter_name_or_id):
    tap = get_tap_from_meter_name_or_404(meter_name_or_id)
    if request.method == 'POST':
        util.check_api_key(request)
        return _tap_detail_post(request, tap)
    elif request.method == 'GET':
        return _tap_detail_get(request, tap)
    else:
        raise kbapi.BadRequestError('Method not supported')
Ejemplo n.º 3
0
def tap_detail(request, meter_name_or_id):
    tap = get_tap_from_meter_name_or_404(meter_name_or_id)
    if request.method == "POST":
        util.check_api_key(request)
        return _tap_detail_post(request, tap)
    elif request.method == "GET":
        return _tap_detail_get(request, tap)
    elif request.method == "DELETE":
        util.check_api_key(request)
        tap.delete()
        return RESULT_OK

    raise kbapi.BadRequestError("Method not supported")
Ejemplo n.º 4
0
def tap_detail(request, meter_name_or_id):
    tap = get_tap_from_meter_name_or_404(meter_name_or_id)
    if request.method == "POST":
        util.check_api_key(request)
        return _tap_detail_post(request, tap)
    elif request.method == "GET":
        return _tap_detail_get(request, tap)
    elif request.method == "DELETE":
        util.check_api_key(request)
        tap.delete()
        return RESULT_OK

    raise kbapi.BadRequestError("Method not supported")
Ejemplo n.º 5
0
  def process_view(self, request, view_func, view_args, view_kwargs):
    if not hasattr(request, 'kbsite'):
      return None
    elif _path_allowed(request.path, request.kbsite):
      return None
    elif apiutil.request_is_authenticated(request):
      # This is an auth-required kb api view; no need to check privacy since API
      # keys are given staff-level access.
      return None

    privacy = request.kbsite.settings.privacy
    if privacy == 'public':
      return None

    # If non-public, apply the API key check.
    if apiutil.is_api_view(view_func):
      try:
        apiutil.check_api_key(request)
        return
      except Exception, e:
        return apiutil.wrap_exception(request, e)
Ejemplo n.º 6
0
    def process_view(self, request, view_func, view_args, view_kwargs):
        if not hasattr(request, 'kbsite'):
            return None
        elif _path_allowed(request.path, request.kbsite):
            return None
        elif apiutil.request_is_authenticated(request):
            # This is an auth-required kb api view; no need to check privacy since API
            # keys are given staff-level access.
            return None

        privacy = request.kbsite.settings.privacy
        if privacy == 'public':
            return None

        # If non-public, apply the API key check.
        if apiutil.is_api_view(view_func):
            try:
                apiutil.check_api_key(request)
                return
            except Exception, e:
                return apiutil.wrap_exception(request, e)
Ejemplo n.º 7
0
def all_taps(request):
    if request.method == 'POST':
        util.check_api_key(request)
        return create_tap(request)
    return models.KegTap.objects.all().order_by('name')
Ejemplo n.º 8
0
def all_taps(request):
    if request.method == "POST":
        util.check_api_key(request)
        return create_tap(request)
    return models.KegTap.objects.all().order_by("name")
Ejemplo n.º 9
0
 def new_function(*args, **kwargs):
   request = args[0]
   util.check_api_key(request)
   return viewfunc(*args, **kwargs)