# Path: invenio_communities/proxies.py

# 
# Path: invenio_communities/fixtures/demo.py
# 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", "restricted"])
#         },
#         "id": faker.unique.domain_word(),
#         "metadata": {
#             "title": faker.sentence(nb_words=5, variable_nb_words=True),
#             "description": faker.text(max_nb_chars=2000),
#             "type": 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))
# 
# Path: invenio_communities/fixtures/tasks.py
# @shared_task
# def create_demo_community(data):
#     """Create a demo community."""
#     service = current_communities.service
#     try:
#         service.create(data=data, identity=system_identity)
#     except PIDAlreadyExists:
#         pass


import click
from faker import Faker
from flask.cli import with_appcontext
from invenio_access.permissions import system_identity
from invenio_communities.proxies import current_communities
from .fixtures.demo import create_fake_community
from .fixtures.tasks import create_demo_community
# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2016-2021 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Command-line tools for demo module."""




@click.group()
def communities():
    """Invenio communities commands."""


@communities.command('demo')
@with_appcontext
def demo():
    """Create 100 fake communities for demo purposes."""
    click.secho('Creating demo communities...', fg='green')
    faker = Faker()
    for _ in range(100):

# Path: invenio_communities/proxies.py

# 
# Path: invenio_communities/fixtures/demo.py
# 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", "restricted"])
#         },
#         "id": faker.unique.domain_word(),
#         "metadata": {
#             "title": faker.sentence(nb_words=5, variable_nb_words=True),
#             "description": faker.text(max_nb_chars=2000),
#             "type": 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))
# 
# Path: invenio_communities/fixtures/tasks.py
# @shared_task
# def create_demo_community(data):
#     """Create a demo community."""
#     service = current_communities.service
#     try:
#         service.create(data=data, identity=system_identity)
#     except PIDAlreadyExists:
#         pass


# Path: invenio_communities/cli.py
import click
from faker import Faker
from flask.cli import with_appcontext
from invenio_access.permissions import system_identity
from invenio_communities.proxies import current_communities
from .fixtures.demo import create_fake_community
from .fixtures.tasks import create_demo_community

# -*- coding: utf-8 -*-
#
# This file is part of Invenio.
# Copyright (C) 2016-2021 CERN.
#
# Invenio is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Command-line tools for demo module."""




@click.group()
def communities():
    """Invenio communities commands."""


@communities.command('demo')
@with_appcontext
def demo():
    """Create 100 fake communities for demo purposes."""
    click.secho('Creating demo communities...', fg='green')
    faker = Faker()
    for _ in range(100):

        fake_data = create_fake_community(faker)