예제 #1
0
파일: course.py 프로젝트: elcoyaman/seal
def newcourse(request):
    if(len(request.user.teacher_set.all()) > 0): # if an authenticated user "accidentally" access this section, he doesn't get an exception
        if (request.method == 'POST'):
            form = CourseForm(request.POST)
            if (form.is_valid()):
                form.save()
                return HttpResponseRedirect('/')
        else:
            form = CourseForm()
        return render(request, 'course/newcourse.html', {'form': form, })
    else:
        return HTTP_401_UNAUTHORIZED_RESPONSE
예제 #2
0
파일: course.py 프로젝트: elcoyaman/seal
def editcourse(request, idcourse):
    if(len(request.user.teacher_set.all()) > 0): # if an authenticated user "accidentally" access this section, he doesn't get an exception
        course = Course.objects.get(pk=idcourse)     
        if (request.method == 'POST'):
            form = CourseForm(request.POST, instance=course)
            if (form.is_valid()):
                form_edit = form.save(commit=False)
                form_edit.save()
                return HttpResponseRedirect(PATHOKNEWCOURSE)
        else:
            form = CourseForm(instance=course)
        return render(request, 'course/editcourse.html',
                      {'form': form, 'course': course},
                      context_instance=RequestContext(request))
    
    else:
        return HTTP_401_UNAUTHORIZED_RESPONSE
예제 #3
0
파일: course.py 프로젝트: nicopaez/seal
def newcourse(request):
    if (
            len(request.user.teacher_set.all()) > 0
    ):  # if an authenticated user "accidentally" access this section, he doesn't get an exception
        if (request.method == 'POST'):
            form = CourseForm(request.POST)
            if (form.is_valid()):
                form.save()
                return HttpResponseRedirect('/')
        else:
            form = CourseForm()
        return render(request, 'course/newcourse.html', {
            'form': form,
        })
    else:
        return HTTP_401_UNAUTHORIZED_RESPONSE
예제 #4
0
파일: course.py 프로젝트: nicopaez/seal
def editcourse(request, idcourse):
    if (
            len(request.user.teacher_set.all()) > 0
    ):  # if an authenticated user "accidentally" access this section, he doesn't get an exception
        course = Course.objects.get(pk=idcourse)
        if (request.method == 'POST'):
            form = CourseForm(request.POST, instance=course)
            if (form.is_valid()):
                form_edit = form.save(commit=False)
                form_edit.save()
                return HttpResponseRedirect(PATHOKNEWCOURSE)
        else:
            form = CourseForm(instance=course)
        return render(request,
                      'course/editcourse.html', {
                          'form': form,
                          'course': course
                      },
                      context_instance=RequestContext(request))

    else:
        return HTTP_401_UNAUTHORIZED_RESPONSE