Exemplo n.º 1
0
def create_staff(request):
	if request.POST:
		form = StaffForm(request.POST,request.FILES)
		if form.is_valid():
			form.save()			
			return HttpResponseRedirect('/appwptn/all/staff')
	else:
		form = StaffForm()
	args = {}
	args.update(csrf(request))
	args['form'] = form
	return render_to_response('create_staff.html',args)	
Exemplo n.º 2
0
def edit_staff(request):
    """ Edit user profile. """
    staff = request.user.profile
    if request.method == 'POST':
        form = StaffForm(request.POST, instance=staff)
        if form.is_valid():
            form.save()
            data = form.cleaned_data
            if data['team']:
                try:
                    team = Group.objects.get(pk=data['team'])
                    request.user.groups.add(team)
                except:
                    pass
            return HttpResponseRedirect('/staff/%s'%staff.pk)
    else:
        form = StaffForm(instance=staff)
    return render(request, 'staff_edit', {'form':form}, 'staff/')
Exemplo n.º 3
0
 def post(self, request, *args, **kwargs):
     form = StaffForm(request.POST)
     staff = form.save(commit=False)
     user = User.objects.create_user(staff.emp_no, staff.email, '5555')
     user.first_name = staff.name
     user.save()
     group = Group.objects.get(name='staff')
     group.user_set.add(user)
     staff.save()
     return HttpResponseRedirect('/admin/staff')
Exemplo n.º 4
0
 def post(self, request, *args, **kwargs):
     form=StaffForm(request.POST)
     staff = form.save(commit=False)
     user = User.objects.create_user(staff.emp_no,staff.email,'5555')
     user.first_name=staff.name
     user.save()
     group = Group.objects.get(name='staff') 
     group.user_set.add(user)
     staff.save()
     return HttpResponseRedirect('/admin/staff')
Exemplo n.º 5
0
 def post(self, request, *args, **kwargs):
     try:
         instance = Staff.objects.get(emp_no=request.POST['uid']) #aka emp_no
         form=StaffForm(request.POST,instance=instance)
         staff = form.save(commit=False)
         #user = User.objects.create_user(student.admission_no,student.email, 'johnpassword')
         #user.first_name=student.name
         #user.save()
         staff.save()
         msg="Record saved"
     except:
         msg="Unable to process, Please check all values are present"
     return HttpResponse(json.dumps(dict(result=msg)), content_type="application/json")
Exemplo n.º 6
0
 def post(self, request, *args, **kwargs):
     try:
         instance = Staff.objects.get(
             emp_no=request.POST['uid'])  #aka emp_no
         form = StaffForm(request.POST, instance=instance)
         staff = form.save(commit=False)
         #user = User.objects.create_user(student.admission_no,student.email, 'johnpassword')
         #user.first_name=student.name
         #user.save()
         staff.save()
         msg = "Record saved"
     except:
         msg = "Unable to process, Please check all values are present"
     return HttpResponse(json.dumps(dict(result=msg)),
                         content_type="application/json")