import random
import json


def create_fake_community(faker):
    """Create fake communities for demo purposes."""
    data_to_use = {
        "access": {
            "visibility": random.choice(["public", "restricted"]),
            "member_policy": random.choice(["open", "closed"]),
            "record_policy": random.choice(["open", "closed"])
        },
        "slug": faker.unique.domain_word(),
        "metadata": {
            "title": faker.sentence(nb_words=5, variable_nb_words=True),
            "description": faker.text(max_nb_chars=2000),
            "type": {
                "id": random.choice(["organization", "event", "topic", "project"])
            },
            "curation_policy": faker.text(max_nb_chars=2000),
            "page": faker.text(max_nb_chars=2000),
            "website": "https://" + faker.domain_name(),  # fake.url()
            "organizations": [
                { "name": "CERN" }
            ],
        },
    }

    return json.loads(json.dumps(data_to_use))