Exemplo n.º 1
0
def core_frontpage_view(request,
                        template='core_frontpage_view.jade',
                        include_past_events=False):
    t = now()

    if include_past_events:
        past_events = events(public=True, end_time__lte=t)
    else:
        past_events = Event.objects.none()

    current_events = events(public=True, start_time__lte=t, end_time__gt=t)
    future_events = events((Q(start_time__gt=t) | Q(start_time__isnull=True))
                           & Q(public=True)).order_by('start_time')

    past_events_rows_by_year = [
        (year, list(groups_of_n(year_events, 4)))
        for (year, year_events) in groupby_strict(past_events, get_year)
    ]

    vars = dict(
        carousel_slides=CarouselSlide.get_active_slides(),
        current_events_rows=list(groups_of_n(current_events, 4)),
        future_events_rows=list(groups_of_n(future_events, 4)),
        past_events_rows_by_year=past_events_rows_by_year,
    )

    return render(request, template, vars)
Exemplo n.º 2
0
def core_organizations_view(request):
    organizations = Organization.objects.filter(public=True)

    vars = dict(
        organizations_rows=groups_of_n(organizations, 4),
    )

    return render(request, 'core_organizations_view.pug', vars)
Exemplo n.º 3
0
def core_frontpage_view(request):
    t = now()

    past_events = Event.objects.filter(public=True, end_time__lte=t).order_by('-start_time')
    current_events = Event.objects.filter(public=True, start_time__lte=t, end_time__gt=t).order_by('-start_time')
    future_events = Event.objects.filter((Q(start_time__gt=t) | Q(start_time__isnull=True)) & Q(public=True)).order_by('start_time')
    organizations = Organization.objects.filter(public=True)

    past_events_rows_by_year = [(year, list(groups_of_n(year_events, 4))) for (year, year_events) in groupby_strict(past_events, get_year)]

    vars = dict(
        future_events_rows=list(groups_of_n(future_events, 4)),
        current_events_rows=list(groups_of_n(current_events, 4)),
        past_events_rows_by_year=past_events_rows_by_year,
        organizations_rows = list(groups_of_n(organizations, 4)),
    )

    return render(request, 'core_frontpage_view.jade', vars)
Exemplo n.º 4
0
def core_frontpage_view(request, template='core_frontpage_view.pug', include_past_events=False):
    t = now()

    if include_past_events:
        past_events = events(public=True, end_time__lte=t)
    else:
        past_events = Event.objects.none()

    current_events = events(public=True, start_time__lte=t, end_time__gt=t)
    future_events = events((Q(start_time__gt=t) | Q(start_time__isnull=True)) & Q(public=True)).order_by('start_time')

    past_events_rows_by_year = [(year, list(groups_of_n(year_events, 4))) for (year, year_events) in groupby_strict(past_events, get_year)]

    vars = dict(
        carousel_slides=CarouselSlide.get_active_slides(),
        current_events_rows=list(groups_of_n(current_events, 4)),
        future_events_rows=list(groups_of_n(future_events, 4)),
        past_events_rows_by_year=past_events_rows_by_year,
    )

    return render(request, template, vars)
Exemplo n.º 5
0
def core_frontpage_view(request):
    t = now()

    past_events = events(public=True, end_time__lte=t)
    current_events = events(public=True, start_time__lte=t, end_time__gt=t)
    future_events = events((Q(start_time__gt=t) | Q(start_time__isnull=True))
                           & Q(public=True)).order_by('start_time')

    organizations = Organization.objects.filter(public=True)

    past_events_rows_by_year = [
        (year, list(groups_of_n(year_events, 4)))
        for (year, year_events) in groupby_strict(past_events, get_year)
    ]

    vars = dict(
        future_events_rows=list(groups_of_n(future_events, 4)),
        current_events_rows=list(groups_of_n(current_events, 4)),
        past_events_rows_by_year=past_events_rows_by_year,
        organizations_rows=list(groups_of_n(organizations, 4)),
    )

    return render(request, 'core_frontpage_view.jade', vars)
Exemplo n.º 6
0
def generate_machine_password(alphabet=PASSWORD_ALPHABET, num_chars=20, group_len=4):
    len_alphabet = len(PASSWORD_ALPHABET)
    chars = [alphabet[randint(0, len_alphabet - 1)] for _ in range(num_chars)]
    return "-".join("".join(part) for part in groups_of_n(chars, group_len))
Exemplo n.º 7
0
def core_organizations_view(request):
    organizations = Organization.objects.filter(public=True)

    vars = dict(organizations_rows=groups_of_n(organizations, 4), )

    return render(request, 'core_organizations_view.jade', vars)
Exemplo n.º 8
0
def generate_machine_password(alphabet=PASSWORD_ALPHABET,
                              num_chars=20,
                              group_len=4):
    len_alphabet = len(PASSWORD_ALPHABET)
    chars = [alphabet[randint(0, len_alphabet - 1)] for _ in range(num_chars)]
    return "-".join("".join(part) for part in groups_of_n(chars, group_len))