def admin_of_domain(domain_identifier, user): """Returns true iff the user is a member and admin of the domain. Args: domain: The domain identifier user: Instance of the user model Returns: True if the user is a member and an admin of the domain. """ if not member_of_domain(domain_identifier, user): return False query = Domain.all(keys_only=True).\ filter('__key__ =', Domain.key_from_name(domain_identifier)).\ filter('admins =', user.identifier()) if not query.fetch(1): return False return True