def sign_in(request):
		if request.method == 'POST' and request.POST.get('sign_in'):
			loginUsername = request.POST.get('username')
			loginPassword = request.POST.get('password')

			userWhere     = Q_set(username=loginUsername)

			userExixtance = True
			if userDB.objects.filter(userWhere).exists():
				usernameExists = True
			else:
				usernameExists = True

			if userExixtance == True:
				where    = Q_set(username=loginUsername)
				userInfo = get_object_or_404(userDB, where)

				if userInfo:
					if userInfo.username == loginUsername and userInfo.confirmed_pass == loginPassword:
						request.session['username'] = loginUsername
						return redirect('home')
					else:
						return redirect('sign_up')
				else:
					pass
			else:
				return redirect('sign_up')
		elif request.method == 'GET':
			return render(request, 'sign_in.html')
    def add_order(request):
        if request.session.has_key('username'):

            # COMMON INFO FETCHING START
            sessionUsername = request.session['username']
            userWhere = Q_set(username=sessionUsername)
            menuInfo = userDB.objects.get(userWhere)

            foodWhere = Q_set(status='active', trash=False)
            foodInfo = foodDB.objects.filter(foodWhere)

            if request.method == 'POST' and request.POST.get('order_add'):

                orderId = hp.unique_custom_id(hp, 'O')

                # Data entry block start
                data = orderDB(
                    order_id=orderId,
                    bill=request.POST.get('bill'),
                    commission=request.POST.get('commission'),
                    remission=request.POST.get('remission'),
                    customer_name=request.POST.get('customer_name'),
                    customer_contact=request.POST.get('customer_contact'),
                    customer_address=request.POST.get('customer_address'),
                    customer_feedback=request.POST.get('customer_feedback'),
                    customer_rating=request.POST.get('customer_rating'),
                )
                status = data.save()
                where = Q_set(order_id=orderId, trash=False)
                addedInfo = orderDB.objects.get(where)

                for food in request.POST.get('food_id'):
                    oWhere = Q_set(id=food, status='active', trash=False)
                    oInfo = foodDB.objects.get(oWhere)
                    addedInfo.food_id.add(oInfo)

                return redirect('all_order')
            elif request.method == 'GET':
                return render(request, 'order_add.html', {
                    'menuData': menuInfo,
                    'foodData': foodInfo
                })

            return render(request, 'order_add.html', {
                'menuData': menuInfo,
                'foodData': foodInfo
            })
        else:
            return redirect('home')
Exemplo n.º 3
0
    def add_food(request):
        if request.session.has_key('username'):

            # COMMON INFO FETCHING START
            sessionUsername = request.session['username']
            userWhere = Q_set(username=sessionUsername)
            menuInfo = userDB.objects.get(userWhere)

            if request.method == 'POST' and request.POST.get('food_add'):

                # Data entry block start
                data = foodDB(
                    food_id=hp.unique_custom_id(hp, 'F'),
                    name=request.POST.get('name'),
                    regular_price=request.POST.get('regular_price'),
                    current_price=request.POST.get('current_price'),
                    delivery_charge=request.POST.get('delivery_charge'),
                    other_charge=request.POST.get('other_charge'),
                    image=hp.file_processor(hp, request.FILES.get('food_img'),
                                            'food', 'food/'))
                status = data.save()
                return redirect('all_food')
            elif request.method == 'GET':
                return render(request, 'food_add.html', {'menuData': menuInfo})

            return render(request, 'food_add.html', {'menuData': menuInfo})
        else:
            return redirect('home')
    def customer_report(request):
        if request.session.has_key('username'):

            # COMMON INFO FETCHING START
            sessionUsername = request.session['username']
            userWhere = Q_set(username=sessionUsername)
            menuInfo = userDB.objects.get(userWhere)

            orderWhere = Q_set(status='active', trash=False)
            orderInfo = orderDB.objects.filter(orderWhere)

            return render(request, 'customer_report.html', {
                'menuData': menuInfo,
                'orderData': orderInfo
            })
        else:
            return redirect('home')
Exemplo n.º 5
0
    def edit_food(request, id):
        if request.session.has_key('username'):

            # COMMON INFO FETCHING START
            sessionUsername = request.session['username']
            userWhere = Q_set(username=sessionUsername)
            menuInfo = userDB.objects.get(userWhere)

            foodWhere = Q_set(id=id, status='active', trash=False)
            foodInfo = foodDB.objects.get(foodWhere)

            # Update Profile Picture And Cover Picture Start Here ------------->
            if request.method == 'POST' and request.POST.get('food_edit'):

                if request.FILES.get('food_img') != None and request.FILES.get(
                        'food_img') != '':
                    foodFile = hp.file_processor(hp,
                                                 request.FILES.get('food_img'),
                                                 'food', 'food/')
                else:
                    foodFile = foodInfo.image

                # Data entry block start
                where = Q_set(id=id, status='active', trash=False)
                pre_update = foodDB.objects.select_related().filter(where)
                post_update = pre_update.update(
                    name=request.POST.get('name'),
                    regular_price=request.POST.get('regular_price'),
                    current_price=request.POST.get('current_price'),
                    delivery_charge=request.POST.get('delivery_charge'),
                    other_charge=request.POST.get('other_charge'),
                    status=request.POST.get('status'),
                    image=foodFile)
                # Data entry block end
                return redirect('all_food')
            elif request.method == 'GET':
                return render(request, 'food_edit.html', {
                    'menuData': menuInfo,
                    'foodData': foodInfo
                })
            return render(request, 'food_edit.html', {
                'menuData': menuInfo,
                'foodData': foodInfo
            })
        else:
            return redirect('home')
Exemplo n.º 6
0
    def all_food(request):
        if request.session.has_key('username'):

            # COMMON INFO FETCHING START
            sessionUsername = request.session['username']
            userWhere = Q_set(username=sessionUsername)
            menuInfo = userDB.objects.get(userWhere)

            foodWhere = Q_set(status='active', trash=False)
            foodInfo = foodDB.objects.filter(foodWhere)

            return render(request, 'food_all.html', {
                'menuData': menuInfo,
                'foodData': foodInfo
            })
        else:
            return redirect('home')
    def view_order(request, id):
        if request.session.has_key('username'):

            # COMMON INFO FETCHING START
            sessionUsername = request.session['username']
            userWhere = Q_set(username=sessionUsername)
            menuInfo = userDB.objects.get(userWhere)

            orderWhere = Q_set(id=id, status='active', trash=False)
            orderInfo = orderDB.objects.get(orderWhere)

            return render(request, 'order_view.html', {
                'menuData': menuInfo,
                'orderData': orderInfo
            })
        else:
            return redirect('sign_out')
Exemplo n.º 8
0
    def delete_food(request, id):
        if request.session.has_key('username'):

            foodWhere = Q_set(id=id, status='active', trash=False)
            foodInfo = foodDB.objects.get(foodWhere)

            foodInfo.delete()
            return redirect('all_food')
        else:
            return redirect('home')
	def home(request):
		if request.session.has_key('username'):

			# COMMON INFO FETCHING START
			sessionUsername = request.session['username']
			userWhere       = Q_set(username=sessionUsername)
			menuInfo        = userDB.objects.get(userWhere)
			
			orderWhere      = Q_set(status='active', trash=False)
			orderInfo       = orderDB.objects.filter(orderWhere)
			order           = orderDB.objects.filter(orderWhere).count()
			
			foodWhere       = Q_set(status='active', trash=False)
			foodInfo        = foodDB.objects.filter(foodWhere)
			food            = foodDB.objects.filter(foodWhere).count()

			return render(request, 'home.html', {'menuData': menuInfo, 'orderData': orderInfo, 'order': order, 'food': food})
		else:
			return redirect('sign_out')
    def delete_order(request, id):
        if request.session.has_key('username'):

            orderWhere = Q_set(id=id, status='active', trash=False)
            orderInfo = orderDB.objects.get(orderWhere)

            orderInfo.delete()
            return redirect('all_order')
        else:
            return redirect('home')
	def view_profile(request):
		if request.session.has_key('username'):

			# COMMON INFO FETCHING START
			sessionUsername = request.session['username']
			userWhere       = Q_set(username=sessionUsername)
			menuInfo        = userDB.objects.get(userWhere)

			return render(request, 'view_profile.html', {'menuData': menuInfo})
		else:
			return redirect('sign_out')
	def sign_up(request):
		if request.method == 'POST' and request.POST.get('sign_up'):

			data = userDB(
				user_id        = hp.unique_custom_id(hp, 'U'),
				name           = request.POST.get('name'),
				username       = request.POST.get('username'),
				email          = request.POST.get('email'),
				password       = request.POST.get('password'),
				confirmed_pass = request.POST.get('confirmed_pass'),
				designation    = request.POST.get('designation'),
			)

			# Username and Email existance check start
			username     = request.POST.get('username')
			email        = request.POST.get('email')
			usernameCond = Q_set(username=username)
			usernameCond = Q_set(email=email)

			usernameExists = False
			emailExists    = False

			if userDB.objects.filter(usernameCond).exists():
				usernameExists = True
			else:
				usernameExists = False

			if userDB.objects.filter(usernameCond).exists():
				emailExists = True
			else:
				emailExists = False

			if usernameExists == False and emailExists == False:
				status = data.save()
				return redirect('sign_in')
			else:
				pass

		elif request.method == 'GET':
			return render(request, 'sign_up.html')
		return render(request, 'sign_up.html')
	def delete_profile(request, reUser):
		if request.session.has_key('username'):

			# COMMON INFO FETCHING START
			sessionUsername = request.session['username']
			userWhere       = Q_set(username=sessionUsername)
			menuInfo        = userDB.objects.get(userWhere)

			menuInfo.delete()
			return redirect('sign_out')
		else:
			return redirect('sign_out')
	def edit_profile(request):
		if request.session.has_key('username'):

			# COMMON INFO FETCHING START
			sessionUsername = request.session['username']
			userWhere       = Q_set(username=sessionUsername)
			menuInfo        = userDB.objects.get(userWhere)

			# Update Profile Picture And Cover Picture Start Here ------------->
			if request.method == 'POST' and request.POST.get('edit_profile'):

				username = request.session['username']

				if request.FILES.get('profile_picture') != None and request.FILES.get('profile_picture') != '':
					profileImage = hp.file_processor(hp, request.FILES.get('profile_picture'), 'pro_pic', 'profile_img/')
				else:
					profileImage = menuInfo.profile_picture

				# Data entry block start 
				where  = Q_set(username=username)
				pre_update = userDB.objects.select_related().filter(where)
				post_update = pre_update.update(
					name            = request.POST.get('name'),
					password        = request.POST.get('password'),
					confirmed_pass  = request.POST.get('confirmed_pass'),
					designation     = request.POST.get('designation'),
					profile_picture = profileImage
			    )
				# Data entry block end 

				return redirect('view_profile')
			elif request.method == 'GET':
				return render(request, 'edit_profile.html', {'menuData': menuInfo})
			# Update Profile Picture And Cover Picture End Here --------------->

			return render(request, 'edit_profile.html', {'menuData': menuInfo})
		else:
			return redirect('sign_out')
	def sign_out(request):
		if request.session.has_key('username'):
			try:
				sessionUsername = request.session['username']
				userWhere       = Q_set(username=sessionUsername)
				menuInfo        = userDB.objects.get(userWhere)

				del request.session['username']
				return redirect('sign_out')
			except:
				return redirect('sign_out')
		else:
			return redirect('sign_up')
		return render(request, 'sign_up.html')
    def edit_order(request, id):
        if request.session.has_key('username'):

            # COMMON INFO FETCHING START
            sessionUsername = request.session['username']
            userWhere = Q_set(username=sessionUsername)
            menuInfo = userDB.objects.get(userWhere)

            foodWhere = Q_set(status='active', trash=False)
            foodInfo = foodDB.objects.filter(foodWhere)

            orderWhere = Q_set(id=id, status='active', trash=False)
            orderInfo = orderDB.objects.get(orderWhere)

            # Update Profile Picture And Cover Picture Start Here ------------->
            if request.method == 'POST' and request.POST.get('order_edit'):

                # Data entry block start
                where = Q_set(id=id, status='active', trash=False)
                pre_update = orderDB.objects.select_related().filter(where)
                post_update = pre_update.update(
                    bill=request.POST.get('bill'),
                    commission=request.POST.get('commission'),
                    remission=request.POST.get('remission'),
                    customer_name=request.POST.get('customer_name'),
                    customer_contact=request.POST.get('customer_contact'),
                    customer_address=request.POST.get('customer_address'),
                    customer_feedback=request.POST.get('customer_feedback'),
                    customer_rating=request.POST.get('customer_rating'),
                    status=request.POST.get('status'),
                )
                where = Q_set(order_id=orderId, trash=False)
                addedInfo = orderDB.objects.get(where)

                for food in request.POST.get('food_id'):

                    cond = Q_set(id=food)
                    if orderDB.food_id.objects.filter(cond).exists():
                        oWhere = Q_set(id=food, status='active', trash=False)
                        oInfo = foodDB.objects.get(oWhere)
                        addedInfo.food_id.remove(oInfo)
                    else:
                        oWhere = Q_set(id=food, status='active', trash=False)
                        oInfo = foodDB.objects.get(oWhere)
                        addedInfo.food_id.add(oInfo)

                # Data entry block end
                return redirect('all_order')
            elif request.method == 'GET':
                return render(
                    request, 'order_edit.html', {
                        'menuData': menuInfo,
                        'foodData': foodInfo,
                        'orderData': orderInfo
                    })
            return render(request, 'order_edit.html', {
                'menuData': menuInfo,
                'foodData': foodInfo,
                'orderData': orderInfo
            })
        else:
            return redirect('home')