Exemplo n.º 1
0
def share_schedule(request):
    schedule_courses = Section.objects.filter(id__in=request.session.get('schedule_courses',[]))
    if request.method == "POST":
        s = Schedule()
        s.save()
        for course in schedule_courses:
            s.sections.add(course)
        s.save()

        return render(request, 'schedule/schedule_share.html', {'saved': True, 'schedule': s, 'schedule_courses': s.sections.all(),})
    else:
        return render(request, 'schedule/schedule_share.html', {'schedule_courses': schedule_courses,})
Exemplo n.º 2
0
def share_schedule(request):
    schedule_courses = Section.objects.filter(
        id__in=request.session.get('schedule_courses', []))
    if request.method == "POST":
        s = Schedule()
        if request.user.is_authenticated():
            s.user = request.user
        s.save()
        for course in schedule_courses:
            s.sections.add(course)

        return render(request, 'schedule/schedule_share.html', {
            'saved': True,
            'schedule': s,
            'schedule_courses': s.sections.all(),
        })
    else:
        return render(request, 'schedule/schedule_share.html', {
            'schedule_courses': schedule_courses,
        })