Пример #1
0
def dash(request):
    u = request.user;
    if (inEmpGroup(u)):
        return render_to_response('dashboard/employee.html')
    elif (inManGroup(u)):
        return render_to_response('dashboard/manager.html')
    else:
        return render_to_response('dashboard/customer.html')
Пример #2
0
def log(request, event_id):
	app = get_object_or_404(KennellingAppointment, pk=event_id)
	if inEmpGroup(request.user) or inManGroup(request.user):
		return render_to_response('appointments/edit_log.html', {'app': app})
	elif app.customer_id == request.user:
		return render_to_response('appointments/log.html', {'app': app, 'back': request.META.get('HTTP_REFERER', '')})
	else:
		return HttpResponseForbidden()
Пример #3
0
def index(request):
	items = Item.objects.all()
	if (inEmpGroup(request.user)):
		return render_to_response('catalogue/emp.html', {'items': items, 'showActions': True });
	elif (inManGroup(request.user)):
		return render_to_response('catalogue/man.html', {'items': items, 'showActions': True });
	else:
		return render_to_response('catalogue/index.html', {'items': items });
Пример #4
0
def cam(request, event_id):
	app = get_object_or_404(KennellingAppointment, pk=event_id)
	if inEmpGroup(request.user) or inManGroup(request.user) or app.customer_id == request.user:
		if app.camera_id == -1:
			return HttpResponseNotFound()
		else:
			return render_to_response('appointments/cam.html', {'app': app, 'gifnum': app.camera_id, 'back': request.META.get('HTTP_REFERER', '')})
	else:
		return HttpResponseNotFound()
Пример #5
0
def detail(request, event_id):
	try:
		app = KennellingAppointment.objects.get(pk=event_id)
	except KennellingAppointment.DoesNotExist:
		try:
			app = Appointment.objects.get(pk=event_id)
		except Appointment.DoesNotExist:
			return HttpResponseNotFound()
	if inEmpGroup(request.user) or inManGroup(request.user):
		return render_to_response('appointments/employee_detail.html', {'app': app })
	elif inCusGroup(request.user) and app.customer_id == request.user:
		return render_to_response('appointments/detail.html', {'app': app})
	else:
		return HttpResponseForbidden()
Пример #6
0
def editsub(request, event_id):
	if request.method == 'POST':
		try:
			app = KennellingAppointment.objects.get(pk=event_id)
		except KennellingAppointment.DoesNotExist:
			try:
				app = Appointment.objects.get(pk=event_id)
			except Appointment.DoesNotExist:
				return HttpResponseNotFound()
		if not (inEmpGroup(request.user) or inManGroup(request.user)):
			if not app.customer_id == request.user:
				return HttpResponseForbidden()
		app.cat_name = request.POST.get('cat_name', '')
		app.cat_breed = request.POST.get('cat_breed', '')
		app.special_considerations = request.POST.get('special_considerations', '')
		app.start = request.POST.get('start_time', '')
		app.end = request.POST.get('end', '')
		app.camera_id = request.POST.get('camera_id', '')
		if (inEmpGroup(request.user) or inManGroup(request.user)) and not request.POST.get('user', '') == app.customer_id.id:
			app.customer_id = User.objects.filter(id=request.POST.get('user', ''))[0]
		app.save()
		return HttpResponseRedirect('/appointments/' + event_id)
	return HttpResponseForbidden();
Пример #7
0
def appointment_list(request):
	if inCusGroup(request.user):
		a = Appointment.objects.filter(customer_id=request.user).order_by('-start')
		apps = []
		kennels = []
		for app in a:
			try:
				k = app.kennellingappointment
				kennels.append(k)
			except KennellingAppointment.DoesNotExist:
				apps.append(app)
		return render_to_response('appointments/customer_list.html', {'apps': apps, 'kennels' : kennels })
	elif inEmpGroup(request.user) or inManGroup(request.user):
		apps = Appointment.objects.all().order_by('-start')
		return render_to_response('appointments/employee_list.html', {'apps': apps})
Пример #8
0
def edit(request, event_id):
	try:
		app = KennellingAppointment.objects.get(pk=event_id)
	except KennellingAppointment.DoesNotExist:
		try:
			app = Appointment.objects.get(pk=event_id)
		except Appointment.DoesNotExist:
			return HttpResponseNotFound()
	if inEmpGroup(request.user) or inManGroup(request.user):
		users = User.objects.filter(groups__name='customer')
		return render_to_response('appointments/edit_form.html', {'app': app, 'users' : users, 'parent' : 'structure/base_employee.html' })
	elif (inCusGroup(request.user) and app.customer_id == request.user):
		return render_to_response('appointments/edit_form.html', {'app': app, 'parent' : 'structure/base_customer.html' })
	else:
		return HttpResponseForbidden()
Пример #9
0
def createnew(request):
	if request.method == 'POST':
		cat_name = request.POST.get('cat_name', '')
		cat_breed = request.POST.get('cat_breed', '')
		special_considerations = request.POST.get('special_considerations', '')
		start = request.POST.get('start_time', '')
		end = request.POST.get('end', '')
		# figure out what customer the appointment belongs to
		if inEmpGroup(request.user) or inManGroup(request.user):
			user = User.objects.filter(id=request.POST.get('user', ''))[0]
		else:
			user = request.user
		#make it a regular appointment or kennelling appointment based on type
		if request.POST.get('type') == 'kennel':
			appointment_obj = KennellingAppointment(cat_name=cat_name, cat_breed=cat_breed, special_considerations=special_considerations, start=start, end=end, customer_id=user, camera_id=-1)
		else:
			appointment_obj = Appointment(cat_name=cat_name, cat_breed=cat_breed, special_considerations=special_considerations, start=start, end=end, customer_id=user)
		appointment_obj.save()
		return HttpResponseRedirect('/appointments/')
	return HttpResponseForbidden();
Пример #10
0
def deleteConfirmed(request, event_id):
	app = get_object_or_404(Appointment, pk=event_id)
	if inEmpGroup(request.user) or inManGroup(request.user) or (inCusGroup(request.user) and app.customer_id == request.user):
		app.delete()
	return redirect('/appointments/')
Пример #11
0
def delete(request, event_id):
	app = get_object_or_404(Appointment, pk=event_id)
	if inEmpGroup(request.user) or inManGroup(request.user):
		return render_to_response('appointments/delete.html', { 'app' : app, 'parent' : 'structure/base_employee.html' });
	elif (inCusGroup(request.user) and app.customer_id == request.user):
		return render_to_response('appointments/delete.html', { 'app' : app, 'parent' : 'structure/base_customer.html' });
Пример #12
0
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required, user_passes_test
from django.template import RequestContext
from appointments.models import Appointment, KennellingAppointment
from scheduling.models import ScheduleManager
from itertools import chain
from users.views import inEmpGroup, inManGroup, inCusGroup
from django.forms import ModelForm
from django.core.context_processors import csrf
from django.views.decorators.csrf import csrf_exempt
from datetime import datetime, date, timedelta
from django.core.serializers import serialize
from random import randint

@login_required
@user_passes_test(lambda u: inEmpGroup(u) or inManGroup(u) or inCusGroup(u), login_url='/')
def appointment_list(request):
	if inCusGroup(request.user):
		a = Appointment.objects.filter(customer_id=request.user).order_by('-start')
		apps = []
		kennels = []
		for app in a:
			try:
				k = app.kennellingappointment
				kennels.append(k)
			except KennellingAppointment.DoesNotExist:
				apps.append(app)
		return render_to_response('appointments/customer_list.html', {'apps': apps, 'kennels' : kennels })
	elif inEmpGroup(request.user) or inManGroup(request.user):
		apps = Appointment.objects.all().order_by('-start')
		return render_to_response('appointments/employee_list.html', {'apps': apps})
Пример #13
0
def detail(request, event_id):
	shift = get_object_or_404(Shift, pk=event_id)
	return render_to_response('scheduling/detail.html', {'shift': shift, 'isMan': inManGroup(request.user)})
Пример #14
0
def schedule(request):
	shift_list = Shift.objects.all().order_by('-start')
	return render_to_response('scheduling/index.html', {'shift_list': shift_list, 'isManager': inManGroup(request.user) })