Beispiel #1
0
def group_add(request, classroom_id):
    if request.method == 'POST':
        classroom_name = Classroom.objects.get(id=classroom_id).name
        form = GroupForm(request.POST)
        if form.is_valid():
            group = EnrollGroup(name=form.cleaned_data['name'],
                                classroom_id=int(classroom_id))
            group.save()

            return redirect('/student/group/' + classroom_id)
    else:
        form = GroupForm()
    return render(request, 'form.html', {'form': form})
Beispiel #2
0
def group_add(request, classroom_id):
        if request.method == 'POST':
            classroom_name = Classroom.objects.get(id=classroom_id).name            
            form = GroupForm(request.POST)
            if form.is_valid():
                group = EnrollGroup(name=form.cleaned_data['name'],classroom_id=int(classroom_id))
                group.save()
                
                # 記錄系統事
                if is_event_open(request) :                  
                    log = Log(user_id=request.user.id, event=u'新增分組<'+classroom_name+'><'+form.cleaned_data['name']+'>')
                    log.save()        
        
                return redirect('/student/group/'+classroom_id)
        else:
            form = GroupForm()
        return render_to_response('form.html', {'form':form}, context_instance=RequestContext(request))
Beispiel #3
0
def group_add(request):
    group = Group()
    if request.method == 'POST':
        form = GroupForm(data=request.POST, instance=group)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/')
    else:
        form = GroupForm(instance=group)
    variables = RequestContext(request, {
        'type': 'group',
        'form': form,
    })
    return render_to_response(
        'group_add.html',
        variables
    )
Beispiel #4
0
def group_add(request, classroom_id):
        if request.method == 'POST':
            classroom_name = Classroom.objects.get(id=classroom_id).name            
            form = GroupForm(request.POST)
            if form.is_valid():
                group = EnrollGroup(name=form.cleaned_data['name'],classroom_id=int(classroom_id))
                group.save()
                
                # 記錄系統事
                if is_event_open(request) :                  
                    log = Log(user_id=request.user.id, event=u'新增分組<'+classroom_name+'><'+form.cleaned_data['name']+'>')
                    log.save()        
        
                return redirect('/student/group/'+classroom_id)
        else:
            form = GroupForm()
        return render_to_response('student/group_add.html', {'form':form}, context_instance=RequestContext(request))
Beispiel #5
0
def group_edit(request, group_id):
    group = get_object_or_404(Group, id=group_id)
    if request.method == 'POST':
        form = GroupForm(data=request.POST, instance=group)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect('/')#('/user/%s/blog/' % request.user.id)
    else:
        form = GroupForm(instance=group)
    variables = RequestContext(request, {
        'obj': group,
        'type': 'group',
        'form': form,
    })
    return render_to_response(
        'group_edit.html',
        variables
    )