示例#1
0
文件: views.py 项目: samvitm/oasisreg
def addfaculty(request):
    target = reverse('add-f')
    if request.method == 'POST':
        i = request.session.get('id')
        u = User.objects.get(id = i )
        u = u.get_profile()
        coll = u.college
        p = Faculty(college = coll)
        form = FacultyForm(request.POST)
        if form.is_valid():
            form = FacultyForm(request.POST,instance = p)
            form.save()
            return HttpResponseRedirect(reverse('manage'))
        else:
            return render_to_response('addf.html',{'form' : form , 'action': target})
    else:
        form = FacultyForm()
        return render_to_response('addf.html',{'form' : form , 'action': target})
示例#2
0
文件: views.py 项目: samvitm/oasisreg
def editfac(request):
    i = request.session.get('fid')
    if request.method == 'POST':
        f  = Faculty.objects.get(pk = int(i))
        t = FacultyForm(request.POST,instance = f)
        if t.is_valid():
            t.save()
            del request.session['fid']
        else:
            target = reverse('editfac')
            return render_to_response('edit_p.html',{'form':t ,'action' : target})

    i = request.session.get('id')
    u = User.objects.get(id = i)
    u = u.get_profile()
    coll = u.college
    ps = Participant.objects.filter(college = coll)
    fs = Faculty.objects.filter(college = coll)
    message = "Faculty Edited!"
    return render_to_response('partcipants.html',{'participants':ps , 'faculty' : fs , 'message' : message})