Example #1
0
    def post(self, doc_type):
        acls_count = AclRulesPlus.get_by_area(doc_type).count()

        @required_admin_role(doc_type, acls_count)
        def inner():
            try:
                docs = self._get_doc_values(self.request)
                doc_values = self._flatten_doc_values(docs)
            except NotFound:
                return Response(status=404)

            acls = AclRulesPlus.get_by_area(doc_type)
            no_admin = self._has_admin(doc_values) is False
            if acls.count() == 0:
                if no_admin:
                    return self._400()
            else:
                if no_admin and self._members(doc_values) >= self._admins(acls):
                    return self._400()

            for key in doc_values.keys():
                AclRules.insert_or_update(doc_type, key, [doc_values[key]])
            result = {doc_type: AclRulesPlus.get_by_list(doc_type)}

            return render_escaped_json_response(result)
        return inner()
Example #2
0
        def inner():
            acls = AclRulesPlus.get_by_area(doc_type)
            if acls.count() == 0:
                return Response(status=404)

            return self.post(doc_type)