Ejemplo n.º 1
0
    def contact_add(self, form_data):
        contact_id = str(a_random_id())

        contact_data = form_data.copy()
        contact_data["contact_id"] = contact_id
        self.data_store.contacts.append(contact_data)

        self.logger.info("Contact info added: {}".format(contact_data))

        return response(data=contact_id)
Ejemplo n.º 2
0
    def acl_admin_role_add(self, form_data):
        if self._does_role_name_exist(form_data.get('name')):
            return response(
                error_code=1,
                message="The specified Role Name is already in use")

        role_id = str(a_random_id())
        role_data = {}
        acls = collections.defaultdict(dict)
        for key, value in form_data.to_dict().items():
            if 'acls' in key:
                rule, level = list(filter(None, re.split(r"\[|\]", key)))[1:]
                acls[rule][level] = value
            else:
                role_data[key] = value
        role_data.update({'role_id': role_id, 'acls': acls})

        self.data_store.roles[role_id] = role_data
        return response(data=role_id)
Ejemplo n.º 3
0
    def client_add(self, form_data):
        client_id = str(a_random_id())

        client_data = form_data.copy()
        client_data["clientid"] = client_id
        client_data["contact_id"] = str(0)

        if client_data.get("uber_login"):
            client_data["login"] = client_data.get("uber_login")
            del client_data["uber_login"]

        self.logger.info("Adding client data: {}".format(client_data))

        self.data_store.clients.append(client_data)
        self.contact_add(
            dict(client_id=client_id,
                 description="Primary Contact",
                 login="******",
                 password="******"))

        return response(data=client_id)