Example #1
0
 def render(self, request):
     # get the components in the path
     # why 3 onwards? the resource does not split the components
     parts = request.path.split("/")[3:]
     if not parts:
         return errors.no_resource_error(request)
         
     command, parts = parts[0], parts[1:]
     if command == 'create':
         return self.create_new_user(request)
     elif command == 'delete':
         return self.delete_user(request)
     elif command == 'passwd':
         return self.change_user_password(request)
     else:
         return errors.no_resource_error(request)
Example #2
0
    def render(self, request):
        # get the components in the path
        # why 3 onwards? the resource does not split the co
        parts = request.path.split("/")[3:]
        if not parts:
            return errors.no_resource_error(request)
            
        command, parts = parts[0], parts[1:]
        if command == 'create':
            return self.create_new_app(request)
        elif command == 'delete':
            return self.delete_app(request)
        elif command == 'certupload':
            return self.upload_app_certificate(request)

        return errors.no_resource_error(request)
Example #3
0
    def render(self, request):
        # get the components in the path
        # why 3 onwards? the resource does not split the components
        parts = request.path.split("/")[3:]
        if not parts:
            return errors.no_resource_error(request)

        command, parts = parts[0], parts[1:]
        if command == 'create':
            return self.create_new_user(request)
        elif command == 'delete':
            return self.delete_user(request)
        elif command == 'passwd':
            return self.change_user_password(request)
        else:
            return errors.no_resource_error(request)
Example #4
0
    def render(self, request):
        # get the components in the path
        # why 3 onwards? the resource does not split the co
        parts = request.path.split("/")[3:]
        if not parts:
            return errors.no_resource_error(request)

        command, parts = parts[0], parts[1:]
        if command == 'create':
            return self.create_new_app(request)
        elif command == 'delete':
            return self.delete_app(request)
        elif command == 'certupload':
            return self.upload_app_certificate(request)

        return errors.no_resource_error(request)
Example #5
0
    def render(self, request):
        """
        We handle GET or POST requests to this handler.  This will be of
        the form:
        /apps/<appname>/<device_token>/?args
        """
        parts = request.path.split("/")[2:]
        if len(parts) < 2:
            return errors.no_resource_error(request)

        appname     = parts[0]
        dev_token   = parts[1]
        username    = utils.get_reqvar(request, "username")
        content     = request.content.read()
        badge       = utils.get_reqvar(request, "badge")
        sound       = utils.get_reqvar(request, "sound")
        alert       = utils.get_reqvar(request, "alert")
        env         = utils.get_reqvar(request, "env")
        identifier  = utils.get_reqvar(request, "identifier")
        expiry      = utils.get_reqvar(request, "expiry")

        if content:
            payload = json_decode(content)
            if 'aps' not in payload:
                payload['aps'] = {}
        else:
            payload = {'aps': {}}

        if badge:
            payload['aps']['badge'] = int(badge)
        if sound:
            payload['aps']['sound'] = sound
        if alert:
            payload['aps']['alert'] = alert

        logging.debug("Payload: " + json_encode(payload))

        appkey = "%s$%s$%s" % (env, username, appname)
        self.apns_daemon.sendMessage(appname, dev_token, json_encode(payload), identifier, expiry)

        return json_response(request, 0, "OK")
Example #6
0
    def render(self, request):
        """
        We handle GET or POST requests to this handler.  This will be of
        the form:
        /apps/<appname>/<device_token>/?args
        """
        parts = request.path.split("/")[2:]
        if len(parts) < 2:
            return errors.no_resource_error(request)

        appname = parts[0]
        dev_token = parts[1]
        username = utils.get_reqvar(request, "username")
        content = request.content.read()
        badge = utils.get_reqvar(request, "badge")
        sound = utils.get_reqvar(request, "sound")
        alert = utils.get_reqvar(request, "alert")
        env = utils.get_reqvar(request, "env")
        identifier = utils.get_reqvar(request, "identifier")
        expiry = utils.get_reqvar(request, "expiry")

        if content:
            payload = json_decode(content)
            if "aps" not in payload:
                payload["aps"] = {}
        else:
            payload = {"aps": {}}

        if badge:
            payload["aps"]["badge"] = int(badge)
        if sound:
            payload["aps"]["sound"] = sound
        if alert:
            payload["aps"]["alert"] = alert

        logging.debug("Payload: " + json_encode(payload))

        appkey = "%s$%s$%s" % (env, username, appname)
        self.apns_daemon.sendMessage(appname, dev_token, json_encode(payload), identifier, expiry)

        return json_response(request, 0, "OK")