예제 #1
0
파일: views.py 프로젝트: CJS7070/liquid
def new(request):
  if request.method == 'POST': # If the form has been submitted...
      form = GroupForm(request.POST) # A form bound to the POST data
      if form.is_valid(): # All validation rules pass
          g = form.save()
          messages.add_message(request, messages.SUCCESS, 'Group created')
          return HttpResponseRedirect('/intranet/group/manage/%d'%g.id) # Redirect after POST
  else:
      form = GroupForm() # An unbound form

  return render_to_response('intranet/group_manager/form.html',{
      'form': form,
      "section":"intranet",
      "page":'group',
      "page_title":"Create new Group"
      },context_instance=RequestContext(request))
예제 #2
0
파일: views.py 프로젝트: CJS7070/liquid
def edit(request,id):
  g = Group.objects.get(id=id)
  forms = GroupMemberFormSet(instance=g)
  if request.method == 'POST': # If the form has been submitted...
      form = GroupForm(request.POST,instance=g) # A form bound to the POST data
      if form.is_valid(): # All validation rules pass
          form.save()
          messages.add_message(request, messages.SUCCESS, 'Group saved')
          return HttpResponseRedirect('/intranet/group') # Redirect after POST
  else:
    form = GroupForm(instance=g)


  return render_to_response('intranet/group_manager/form.html',{
    "form":form,
    "section":"intranet",
    "page":'group',
    "page_title":"Edit Group",
    },context_instance=RequestContext(request))
예제 #3
0
def edit(request, id):
    g = Group.objects.get(id=id)
    forms = GroupMemberFormSet(instance=g)
    if request.method == 'POST':  # If the form has been submitted...
        form = GroupForm(request.POST,
                         instance=g)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            form.save()
            messages.add_message(request, messages.SUCCESS, 'Group saved')
            return HttpResponseRedirect(
                '/intranet/group')  # Redirect after POST
    else:
        form = GroupForm(instance=g)

    return render_to_response('intranet/group_manager/form.html', {
        "form": form,
        "section": "intranet",
        "page": 'group',
        "page_title": "Edit Group",
    },
                              context_instance=RequestContext(request))
예제 #4
0
def new(request):
    if request.method == 'POST':  # If the form has been submitted...
        form = GroupForm(request.POST)  # A form bound to the POST data
        if form.is_valid():  # All validation rules pass
            g = form.save()
            messages.add_message(request, messages.SUCCESS, 'Group created')
            return HttpResponseRedirect('/intranet/group/manage/%d' %
                                        g.id)  # Redirect after POST
    else:
        form = GroupForm()  # An unbound form

    return render_to_response('intranet/group_manager/form.html', {
        'form': form,
        "section": "intranet",
        "page": 'group',
        "page_title": "Create new Group"
    },
                              context_instance=RequestContext(request))