Example #1
0
def show_table_view(req, type, event=None, workshop=None):
    """
    Shows a given workshop or event
    This is not used in the URL conf, but called by other views
    """
    days = ''

    if settings.DEBUG:
        template = 'magnovite/table_view.html'
    else:
        template = 'magnovite/dist/table_view.html'

    if type == 'workshop':
        profiles = workshop.profile_set.all().prefetch_related('user').order_by('name')
    elif type == 'event':
        profiles = event.profile_set.all().prefetch_related('user')
    elif type == 'hospitality':
        profiles = Profile.objects.filter(hospitality_days__gt=0)
    elif type == 'on-spot':
        profiles = Profile.objects.filter(on_spot=True).order_by('id')

        days = 'Both'
        if 'day' in req.GET:
            if req.GET.get('day', '') == '1':
                days = 'First'
                profiles = profiles.filter(checked_in_first_day=True)
            else:
                days = 'Second'
                profiles = profiles.filter(checked_in_first_day=False)

        profiles = Profile.prefetch_all(profiles)
    elif type == 'checked-in':
        profiles = Profile.objects.filter(checked_in=True).order_by('id')

        days = 'Both'
        if 'day' in req.GET:
            if req.GET.get('day', '') == '1':
                days = 'First'
                profiles = profiles.filter(checked_in_first_day=True)
            else:
                days = 'Second'
                profiles = profiles.filter(checked_in_first_day=False)

        profiles = Profile.prefetch_all(profiles)
    elif type == 'colleges':
        profiles = Profile.objects.filter(checked_in=True).values('college').annotate(total=Count('college'))

        if req.GET.get('order', '') == 'college':
            profiles = profiles.order_by('college')
        else:
            profiles = profiles.order_by('-total')

    return render(req, template, {
        'type': type,
        'workshop': workshop,
        'event': event,
        'profiles': profiles,
        'now': timezone.now(),
        'days': days
    })
Example #2
0
def all_table_view(req):
    if not req.user.is_staff:
        raise PermissionDenied

    profiles = Profile.prefetch_all(Profile.objects.all())

    if settings.DEBUG:
        template = 'magnovite/fullTable.html'
    else:
        template = 'magnovite/dist/fullTable.html'

    return render(req, template, {
        'now': timezone.now(),
        'profiles': profiles
    })