Exemplo n.º 1
0
def shift_week(request):
    shifts = Shift.objects.filter(date__in=week_dates()).order_by('date', 'category')
    rows_curr = []
    for cat in Shift.CATEGORIES:
        row = [cat[1]] + [shifts.filter(category=cat[0])]
        rows_curr.append(row)

    shifts = Shift.objects.filter(date__in=week_dates(week_offset=1)).order_by('date', 'category')
    rows_next = []
    if len(shifts):
        for cat in Shift.CATEGORIES:
            row = [cat[1]] + [shifts.filter(category=cat[0])]
            rows_next.append(row)

    return render(request, 'termini/week.html', {
        'rows_curr': rows_curr,
        'rows_next': rows_next,
    })
Exemplo n.º 2
0
def shift_week(request):
    shifts = Shift.objects.filter(date__in=week_dates()).order_by(
        'date', 'category')
    rows_curr = []
    for cat in Shift.CATEGORIES:
        row = [cat[1]] + [shifts.filter(category=cat[0])]
        rows_curr.append(row)

    shifts = Shift.objects.filter(date__in=week_dates(week_offset=1)).order_by(
        'date', 'category')
    rows_next = []
    if len(shifts):
        for cat in Shift.CATEGORIES:
            row = [cat[1]] + [shifts.filter(category=cat[0])]
            rows_next.append(row)

    return render(request, 'termini/week.html', {
        'rows_curr': rows_curr,
        'rows_next': rows_next,
    })
Exemplo n.º 3
0
 def create_next_week(self, request, queryset):
     for date in week_dates(week_offset=1):
         for cat in Shift.CATEGORIES:
             Shift.objects.get_or_create(date=date, category=cat[0])