コード例 #1
0
ファイル: das.py プロジェクト: open-aid/feelgood
def create(request):
     
    if request.method == 'POST':
        form = DailyActivityScheduleEntryFormSet(request.POST)
        if form.is_valid():
            instance = form.save(commit=False)
            instance.user = request.user
            instance.save()
            return HttpResponseRedirect(reverse('tools:das-view', args=[instance.id]))
    else:
        form = DailyActivityScheduleEntryFormSet(queryset=Author.objects.none())

    return HttpResponseRedirect(reverse('tools:das-view', args=[instance.id]))  
コード例 #2
0
ファイル: das.py プロジェクト: open-aid/feelgood
def view(request, year, month, day):

    schedule_date = date(int(year),int(month),int(day))
    das, created = DailyActivitySchedule.objects.get_or_create(user=request.user, date=schedule_date)

    if created:
        das.create_entries()

    if request.method == 'POST':
        formset = DailyActivityScheduleEntryFormSet(request.POST)
        if formset.is_valid():
            instances = formset.save(commit=False)
            for instance in instances:
                instance.schedule = das
                instance.save()
            return HttpResponseRedirect(reverse('tools:das-view', args=[year,month,day]))
    else:
        formset = DailyActivityScheduleEntryFormSet(queryset=das.entries.all().order_by('start'))

    return render_response(request, 'tools/das/view.html', {
        'das' : das,
        'formset' : formset,
    })