예제 #1
0
def command():
    """Duplicates Django Girls event with a new date"""

    # Gather data
    (event, number, date, new_team) = gather_information()
    organizers = event.team.all()

    # Remove #{no} from name:
    name = event.name.split('#')[0].strip()
    number = int(number)

    # Change the name of previous event to {name} #{number-1}
    event.name = "{} #{}".format(name, number - 1)
    event.save()

    # Copy event with a name {name} #{number}, new date and empty stats
    new_event = Event.objects.get(id=event.id)
    new_event.pk = None
    new_event.name = "{} #{}".format(name, number)
    new_event.page_title = "{} #{}".format(name, number)
    new_event.date = date
    new_event.is_page_live = False
    new_event.attendees_count = None
    new_event.applicants_count = None
    new_event.save()

    # Edit team and previous email or keep them
    if new_team:
        # Create a new team with a new main organizer
        main_organizer = get_main_organizer()
        team = get_team(main_organizer)
        members = create_users(team, new_event)
        new_event.main_organizer = members[0]
        # Edit previous email account
        event.email = "{}{:02d}{}@ng-boat.pl".format(
            event.email.split('@')[0], event.date.month, event.date.year)
    else:
        new_event.team.set(organizers)

    # Change the title and url of previous event page
    event.page_title = "{} #{}".format(name, number - 1)
    event.page_url = "{}{}".format(event.page_url, number - 1)
    event.save()

    # Copy all EventPageContent objects
    for obj in event.content.all():
        new_content = obj
        new_content.id = None
        new_content.event = new_event
        new_content.save()

        new_content.coaches = obj.coaches.all()
        new_content.sponsors = obj.sponsors.all()

    # Copy all EventPageMenu objects
    for obj in event.menu.all():
        new_obj = obj
        new_obj.pk = None
        new_obj.event = new_event
        new_obj.save()

    # Brag on Slack
    brag_on_slack_bang(new_event.city, new_event.country, new_event.team.all())

    click.echo(
        click.style("Website is ready here: https://ng-boat.pl/{0}".format(
            new_event.page_url),
                    bold=True,
                    fg="green"))
    click.echo("Congrats on yet another event!")
예제 #2
0
def command(short):
    """Creates new Django Girls event"""
    # Basics
    (city, country, date, url, event_email) = get_basic_info()

    # Main organizer
    main_organizer = get_main_organizer()

    # Team
    team = get_team(main_organizer)

    click.echo("OK! That's it. Now I'll create your event.")

    # Event and EventPage objects
    name = 'Django Girls ' + city
    latlng = get_coordinates_for_city(city, country)
    email = event_email + '@djangogirls.org'
    form = EventForm({
        'city': city,
        'country': country,
        'date': date,
        'email': email,
        'latlng': latlng,
        'name': name,
        'page_title': name,
        'page_url': url})
    if not form.is_valid():
        click.secho(
            "OOPS! Something went wrong!", fg='red')
        for field, errors in form.errors.items():
            for error in errors:
                click.secho(
                    "    {field:10} {error}".format(error=error, field=field),
                    fg='red')
        return
    event = form.save()

    # Create users
    members = create_users(team, event)
    event.main_organizer = members[0]

    # Add random cover picture
    event.set_random_cover()

    event.save()

    click.secho(
        "Website is ready here: http://djangogirls.org/{0}".format(url),
        fg='green')
    click.echo(DELIMITER)

    click.secho("Ok, now follow this:", fg='black', bg='green')
    click.echo("1. Create an email account for the event.")
    click.echo("2. Send e-mail with instructions to a team!")
    click.echo(DELIMITER)
    click.secho(
        "This is a ready, filled out mail to sent to organizers:", fg='green')

    click.echo("SUBJECT: Django Girls {} setup".format(event.city))
    click.echo("TO: {}, {}, [email protected]".format(
        ', '.join([x.email for x in members]),
        event.email
    ))
    click.echo("BODY:")

    if short:
        click.echo(render_to_string('emails/setup-short.txt', {
            'event': event,
        }))
    else:
        click.echo(render_to_string('emails/setup.txt', {
            'event': event,
            'email_password': '******',
            'settings': settings
        }))

    brag_on_slack_bang(city, country, members)
예제 #3
0
def command(short):
    """Creates new Django Girls event"""
    # Basics
    (city, country, date, url, event_email) = get_basic_info()

    # Main organizer
    main_organizer = get_main_organizer()

    # Team
    team = get_team(main_organizer)

    click.echo("OK! That's it. Now I'll create your event.")

    # Event and EventPage objects
    name = 'Django Girls ' + city
    latlng = get_coordinates_for_city(city, country)
    email = event_email + '@ng-boat.pl'
    form = EventForm({
        'city': city,
        'country': country,
        'date': date,
        'email': email,
        'latlng': latlng,
        'name': name,
        'page_title': name,
        'page_url': url
    })
    if not form.is_valid():
        click.secho("OOPS! Something went wrong!", fg='red')
        for field, errors in form.errors.items():
            for error in errors:
                click.secho("    {field:10} {error}".format(error=error,
                                                            field=field),
                            fg='red')
        return
    event = form.save()

    # Create users
    members = create_users(team, event)
    event.main_organizer = members[0]

    # Add random cover picture
    event.set_random_cover()

    event.save()

    click.secho("Website is ready here: http://ng-boat.pl/{0}".format(url),
                fg='green')
    click.echo(DELIMITER)

    click.secho("Ok, now follow this:", fg='black', bg='green')
    click.echo("1. Create an email account for the event.")
    click.echo("2. Send e-mail with instructions to a team!")
    click.echo(DELIMITER)
    click.secho("This is a ready, filled out mail to sent to organizers:",
                fg='green')

    click.echo("SUBJECT: Django Girls {} setup".format(event.city))
    click.echo("TO: {}, {}, [email protected]".format(
        ', '.join([x.email for x in members]), event.email))
    click.echo("BODY:")

    if short:
        click.echo(
            render_to_string('emails/setup-short.txt', {
                'event': event,
            }))
    else:
        click.echo(
            render_to_string(
                'emails/setup.txt', {
                    'event': event,
                    'email_password': '******',
                    'settings': settings
                }))

    brag_on_slack_bang(city, country, members)
예제 #4
0
def command():
    """Duplicates Django Girls event with a new date"""

    # Gather data
    (event, number, date, new_team) = gather_information()
    organizers = event.team.all()

    # Remove #{no} from name:
    name = event.name.split('#')[0].strip()
    number = int(number)

    # Change the name of previous event to {name} #{number-1}
    event.name = "{} #{}".format(name, number-1)
    event.save()

    # Copy event with a name {name} #{number}, new date and empty stats
    new_event = Event.objects.get(id=event.id)
    new_event.pk = None
    new_event.name = "{} #{}".format(name, number)
    new_event.page_title = "{} #{}".format(name, number)
    new_event.date = date
    new_event.is_page_live = False
    new_event.attendees_count = None
    new_event.applicants_count = None
    new_event.save()

    # Edit team and previous email or keep them
    if new_team:
        # Create a new team with a new main organizer
        main_organizer = get_main_organizer()
        team = get_team(main_organizer)
        members = create_users(team, new_event)
        new_event.main_organizer = members[0]
        # Edit previous email account
        event.email = "{}{:02d}{}@djangogirls.org".format(event.email.split('@')[0], event.date.month, event.date.year)
    else:
        new_event.team = organizers

    # Change the title and url of previous event page
    event.page_title = "{} #{}".format(name, number-1)
    event.page_url = "{}{}".format(event.page_url, number-1)
    event.save()

    # Copy all EventPageContent objects
    for obj in event.content.all():
        new_content = obj
        new_content.id = None
        new_content.event = new_event
        new_content.save()

        new_content.coaches = obj.coaches.all()
        new_content.sponsors = obj.sponsors.all()

    # Copy all EventPageMenu objects
    for obj in event.menu.all():
        new_obj = obj
        new_obj.pk = None
        new_obj.event = new_event
        new_obj.save()

    # Brag on Slack
    brag_on_slack_bang(new_event.city, new_event.country, new_event.team.all())

    click.echo(click.style("Website is ready here: https://djangogirls.org/{0}".format(new_event.page_url),
    bold=True, fg="green"))
    click.echo("Congrats on yet another event!")