|
|
@ -131,7 +131,7 @@ def add_business(request):
|
|
|
|
|
|
|
|
|
|
|
|
@staff_login_required
|
|
|
|
@staff_login_required
|
|
|
|
def add_staff(request):
|
|
|
|
def add_staff(request):
|
|
|
|
staffpositions = StaffPosition.objects.all().order_by('-id')
|
|
|
|
jobpositions = JobPosition.objects.all().order_by('-id')
|
|
|
|
if request.method == 'POST':
|
|
|
|
if request.method == 'POST':
|
|
|
|
email = request.POST.get('email').lower()
|
|
|
|
email = request.POST.get('email').lower()
|
|
|
|
first_name = request.POST.get('first_name')
|
|
|
|
first_name = request.POST.get('first_name')
|
|
|
@ -160,26 +160,41 @@ def add_staff(request):
|
|
|
|
user.last_name = last_name.lower().capitalize()
|
|
|
|
user.last_name = last_name.lower().capitalize()
|
|
|
|
user.save()
|
|
|
|
user.save()
|
|
|
|
|
|
|
|
|
|
|
|
staff_positionid = request.POST.get('staff_position')
|
|
|
|
|
|
|
|
staff_position = get_object_or_404(StaffPosition, id=staff_positionid)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if request.POST.get('intern'):
|
|
|
|
if request.POST.get('intern'):
|
|
|
|
intern = True
|
|
|
|
intern = True
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
intern = False
|
|
|
|
intern = False
|
|
|
|
|
|
|
|
|
|
|
|
StaffProfile.objects.create(
|
|
|
|
staff = StaffProfile.objects.create(
|
|
|
|
user=user,
|
|
|
|
user=user,
|
|
|
|
image=request.FILES.get('image'),
|
|
|
|
image=request.FILES.get('image'),
|
|
|
|
mobile_number=request.POST.get('mobile_number'),
|
|
|
|
mobile_number=request.POST.get('mobile_number'),
|
|
|
|
active=active,
|
|
|
|
active=active,
|
|
|
|
intern=intern,
|
|
|
|
intern=intern,
|
|
|
|
staff_position=staff_position,
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
position_ids = request.POST.getlist('position[]')
|
|
|
|
|
|
|
|
start_dates = request.POST.getlist('start_date[]')
|
|
|
|
|
|
|
|
end_dates = request.POST.getlist('end_date[]')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for position_id, start_date, end_date in zip(position_ids, start_dates, end_dates):
|
|
|
|
|
|
|
|
position = get_object_or_404(JobPosition, id=position_id)
|
|
|
|
|
|
|
|
if end_date:
|
|
|
|
|
|
|
|
end_date = end_date
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
end_date = None
|
|
|
|
|
|
|
|
StaffPosition.objects.create(
|
|
|
|
|
|
|
|
staff = staff,
|
|
|
|
|
|
|
|
position = position,
|
|
|
|
|
|
|
|
start_date = start_date,
|
|
|
|
|
|
|
|
end_date = end_date
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return redirect('users')
|
|
|
|
return redirect('users')
|
|
|
|
|
|
|
|
|
|
|
|
context = {
|
|
|
|
context = {
|
|
|
|
'staffpositions': staffpositions,
|
|
|
|
'jobpositions': jobpositions,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return render(request, 'add_templates/add-staff.html', context)
|
|
|
|
return render(request, 'add_templates/add-staff.html', context)
|
|
|
|
|
|
|
|
|
|
|
|