예제 #1
0
def teacheradmin_info(request, course_slug):
    course = get_object_or_404(Course, slug=course_slug)
    is_enrolled = course.students.filter(id=request.user.id).exists()

    if request.method == 'POST':
        form = CourseForm(data=request.POST,
                          files=request.FILES,
                          instance=course)
        if form.is_valid():
            form.save()
            messages.success(request, _(u"Your changes were saved."))

            return HttpResponseRedirect(
                reverse('teacheradmin_info', args=[course_slug]))
        else:
            messages.error(
                request,
                _(u"There were problems with some data you introduced, please fix them and try again."
                  ))
    else:
        form = CourseForm(instance=course)

    return render_to_response('teacheradmin/info.html', {
        'course': course,
        'is_enrolled': is_enrolled,
        'form': form,
    },
                              context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: NoriVicJr/moocng
def teacheradmin_info(request, course_slug):
    course = get_object_or_404(Course, slug=course_slug)
    is_enrolled = course.students.filter(id=request.user.id).exists()
    external_apps = externalapps.all()

    if request.method == 'POST':
        form = CourseForm(data=request.POST, files=request.FILES, instance=course)
        static_page_form = StaticPageForm(data=request.POST, instance=course.static_page)
        if form.is_valid() and static_page_form.is_valid():
            static_page = static_page_form.save(commit=False)
            static_page.save()
            course = form.save(commit=False)
            course.static_page = static_page
            course.save()

            messages.success(request, _(u"Your changes were saved."))

            return HttpResponseRedirect(reverse('teacheradmin_info',
                                                args=[course_slug]))
        else:
            messages.error(request, _(u"There were problems with some data you introduced, please fix them and try again."))
    else:
        form = CourseForm(instance=course)
        static_page_form = StaticPageForm(instance=course.static_page)

    return render_to_response('teacheradmin/info.html', {
        'course': course,
        'is_enrolled': is_enrolled,
        'form': form,
        'static_page_form': static_page_form,
        'external_apps': external_apps,
    }, context_instance=RequestContext(request))
예제 #3
0
파일: views.py 프로젝트: CulturePlex/moocng
def teacheradmin_info(request, course_slug):
    course = get_object_or_404(Course, slug=course_slug)
    is_enrolled = course.students.filter(id=request.user.id).exists()
    errors = ''
    success = False

    if request.method == 'POST':
        form = CourseForm(data=request.POST, instance=course,
                          files=request.FILES)
        if form.is_valid():
            form.save()
            success = True
        else:
            errors = form.get_pretty_errors()

    return render_to_response('teacheradmin/info.html', {
        'course': course,
        'is_enrolled': is_enrolled,
        'errors': errors,
        'success': success,
    }, context_instance=RequestContext(request))
예제 #4
0
파일: views.py 프로젝트: CulturePlex/moocng
def teacheradmin_info(request, course_slug):
    course = get_object_or_404(Course, slug=course_slug)
    is_enrolled = course.students.filter(id=request.user.id).exists()
    errors = ''
    success = False

    if request.method == 'POST':
        form = CourseForm(data=request.POST,
                          instance=course,
                          files=request.FILES)
        if form.is_valid():
            form.save()
            success = True
        else:
            errors = form.get_pretty_errors()

    return render_to_response('teacheradmin/info.html', {
        'course': course,
        'is_enrolled': is_enrolled,
        'errors': errors,
        'success': success,
    },
                              context_instance=RequestContext(request))