def CheckAsk(request):
    me = Medicine.objects.all()
    medi = []
    for i in me:
        medi.append(i.medicine_code)
        medi.append(i.medicine_name)

    check = request.POST['check']
    if Question.objects.filter(id=check).exists():
        ch = Question.objects.get(id=check)
        neww = Actions()
        neww.action = 'User check for a Medical Reply'
        neww.type = 'Medical_Reply'
        neww.save()
        return render(request, 'userhome.html', {
            'ch': ch,
            'check': check,
            'medi': json.dumps(medi)
        })
    else:
        tt = 'there is no question related to this id, add a question down'
        return render(request, 'userhome.html', {
            'tt': tt,
            'medi': json.dumps(medi)
        })
def Ask(request):
    me = Medicine.objects.all()
    medi = []
    for i in me:
        medi.append(i.medicine_code)
        medi.append(i.medicine_name)

    ask = request.POST['ask']
    new = Question()
    if request.user.is_authenticated:
        new.user = request.user.username
    else:
        new.user = '******'
    new.quest = ask
    new.save()
    n = new.id
    nu = new.user

    neww = Actions()
    neww.action = 'User ask a Medical Question'
    neww.type = 'Medical_Question'
    neww.save()
    return render(request, 'userhome.html', {
        'n': n,
        'nu': nu,
        'ask': ask,
        'medi': json.dumps(medi)
    })
def order_create(request):
    cart = Cart(request)
    if request.method == 'POST':
        form = OrderCreateForm(request.POST)
        if form.is_valid():
            order = form.save()
            for item in cart:
                OrderItem.objects.create(order=order,
                                         product=item['medicine'],
                                         price=item['medicine_price'],
                                         quantity=item['quantity'])

            cart.clear()
            neww = Actions()
            neww.action = 'New Order added'
            neww.type = 'Order'
            neww.save()
            context = {
                'order': order,
            }
            return render(request, 'order/orderdone.html', context)

    else:
        form = OrderCreateForm()
    context = {'cart': cart, 'form': form}
    return render(request, 'order/order.html', context)
def Contact(request):
    me = Medicine.objects.all()
    medi = []
    for i in me:
        medi.append(i.medicine_code)
        medi.append(i.medicine_name)

    name = request.POST['Ne']
    email = request.POST['El']
    message = request.POST['Me']
    new = Messages()
    new.name = name
    new.email = email
    new.message = message
    new.save()
    text = 'message sent successfully, we will send reply to your email soon'

    neww = Actions()
    neww.action = 'User send a specific message'
    neww.type = 'Contact'
    neww.save()
    return render(request, 'userhome.html', {
        'text': text,
        'medi': json.dumps(medi)
    })
Beispiel #5
0
def DeleteContact(request, id):
    c = Messages.objects.get(id=id)
    c.delete()
    neww = Actions()
    neww.action = 'Contact Message' + ' ' + str(id) + ' ' + 'deleted'
    neww.type = 'Contact'
    neww.save()
    return redirect('contact')
Beispiel #6
0
def DeleteMed(request, id):
    med_delete = Medicine.objects.get(id=id)
    med_delete.delete()
    neww = Actions()
    neww.action = 'Medicine' + ' ' + str(id) + ' ' + 'deleted'
    neww.type = 'Medicine'
    neww.save()
    return redirect('med')
Beispiel #7
0
def DeleteDeliver(request, id):
    uu = Delivery.objects.get(id=id).name
    deliver_delete = Delivery.objects.get(id=id)
    deliver_delete.delete()
    neww = Actions()
    neww.action = 'DeliveryMan' + ' ' + str(uu) + ' ' + 'deleted'
    neww.type = 'Delivery'
    neww.save()
    return redirect('user')
Beispiel #8
0
def DeleteAdmin(request, id):
    uu = User.objects.get(id=id).username
    admin_delete = User.objects.get(id=id)
    admin_delete.delete()
    neww = Actions()
    neww.action = 'Admin' + ' ' + str(uu) + ' ' + 'deleted'
    neww.type = 'Admin'
    neww.save()
    return redirect('user')
Beispiel #9
0
def PaidOrder(request, id):
    p = order.objects.get(id=id)
    if p.sent == True:
        p.paid = True
        p.save()
        neww = Actions()
        neww.action = 'Order' + ' ' + str(id) + ' ' + 'paid'
        neww.type = 'Order'
        neww.save()
        return redirect('orders')
    return redirect('orders')
Beispiel #10
0
def DeleteDep(request, id):
    dep_delete = Department(id=id)
    dep_delete.delete()
    d = Department.objects.all()
    depo = []
    for i in d:
        depo.append(i.department_code)
        depo.append(i.department_name)
    neww = Actions()
    neww.action = 'Department' + ' ' + str(id) + ' ' + 'deleted'
    neww.type = 'Department'
    neww.save()
    return render(request, 'dep.html', {'d': d, 'depo': json.dumps(depo)})
Beispiel #11
0
def cart_add(request,medicine_id):
	cart = Cart(request)
	medicine = get_object_or_404(Medicine,id=medicine_id)
	form = CartAddProductForm(request.POST)
	if form.is_valid():
		cd = form.cleaned_data
		cart.add(
			medicine=medicine,
			quantity=cd['quantity'],
			update_quantity=cd['update']
			)
	neww = Actions()
	neww.action = medicine.medicine_name + ' ' + 'new buy'
	neww.type = 'Medicine_Buy'
	neww.save()
	return redirect('cart:cart_detail')
Beispiel #12
0
def AddDeliver(request):
    dl_name = request.POST['dl_name']
    dl_address = request.POST['dl_address']
    dl_nid = request.POST['dl_nid']
    dl_code = request.POST['dl_code']
    dl = Delivery()
    dl.name = dl_name
    dl.address = dl_address
    dl.NID = dl_nid
    dl.code = dl_code
    dl.save()
    neww = Actions()
    neww.action = 'New DeliveryMan' + ' ' + str(dl.name) + ' ' + 'added'
    neww.type = 'Delivery'
    neww.save()
    return redirect('user')
Beispiel #13
0
def Replying(request, id):
    repl = request.POST['repl']
    qu = request.POST['qu']
    us = request.POST['us']
    ad = request.POST['ad']
    new = Question.objects.get(id=id)
    new.reply = repl
    new.user = us
    new.quest = qu
    new.admin = ad
    new.save()
    q = Question.objects.all().order_by('-created')
    neww = Actions()
    neww.action = 'Admin reply to question ' + ' ' + str(id)
    neww.type = 'Medical_Reply'
    neww.save()
    return render(request, 'ask.html', {'q': q})
Beispiel #14
0
def AddAdmin(request):
    ad_name = request.POST['ad_name']
    ad_email = request.POST['ad_email']
    ad_pass = request.POST['ad_pass']
    ad = User()
    ad.username = ad_name
    ad.email = ad_email
    ad.password = ad_pass
    ad.first_name = ''
    ad.last_name = ''
    ad.is_staff = True
    ad.is_superuser = False
    ad.save()
    neww = Actions()
    neww.action = 'New Admin' + ' ' + str(ad.username) + ' ' + 'added'
    neww.type = 'Admin'
    neww.save()
    return redirect('user')
Beispiel #15
0
def SendOrder(request):
    Order_ID = request.POST['Order_ID']
    Admin_Username = request.POST['Admin_Username']
    DeliveryMan_Code = request.POST['DeliveryMan_Code']
    if Delivery.objects.filter(code=DeliveryMan_Code).exists() == True:
        dliver = OrderSent()
        dliver.order_id = Order_ID
        dliver.admin_uname = Admin_Username
        dliver.delivery_man = DeliveryMan_Code
        dliver.save()
        ord = order.objects.get(id=Order_ID)
        ord.sent = True
        ord.save()
        neww = Actions()
        neww.action = 'Order' + ' ' + str(
            Order_ID) + ' ' + 'sent by' + ' ' + str(DeliveryMan_Code)
        neww.type = 'Order'
        neww.save()
        return redirect('orders')
    return redirect('orders')
Beispiel #16
0
def SaveEditDep(request, id):
    dep_code = request.POST['dep_code']
    dep_name = request.POST['dep_name']
    dep_items = request.POST['dep_items']
    new = Department.objects.get(id=id)
    new.department_code = dep_code
    new.department_name = dep_name
    new.slug = dep_name
    new.department_items = dep_items
    new.save()
    d = Department.objects.all()
    depo = []
    for i in d:
        depo.append(i.department_code)
        depo.append(i.department_name)
    neww = Actions()
    neww.action = 'Department' + ' ' + str(id) + ' ' + 'updated'
    neww.type = 'Department'
    neww.save()
    return render(request, 'dep.html', {'d': d, 'depo': json.dumps(depo)})
def Search(request):
    me = Medicine.objects.all()
    medi = []
    for i in me:
        medi.append(i.medicine_code)
        medi.append(i.medicine_name)

    med = request.POST['med']
    m = Medicine.objects.filter(Q(medicine_code=med) | Q(medicine_name=med))
    cart_product_form = CartAddProductForm()
    neww = Actions()
    neww.action = 'User Search for' + ' ' + med + ' ' + 'Medicine'
    neww.type = 'Medicine_Search'
    neww.save()
    context = {
        'm': m,
        'med': med,
        'cart_product_form': cart_product_form,
        'medi': json.dumps(medi)
    }
    return render(request, 'userhome.html', context)
Beispiel #18
0
def SaveEditMed(request, id):
    dep_cod = request.POST['dep_code']
    depcode = Department.objects.get(department_code=dep_cod).id
    med_code = request.POST['med_code']
    med_name = request.POST['med_name']
    med_quant = request.POST['med_quant']
    med_price = request.POST['med_price']
    med_desc = request.POST['med_desc']
    new = Medicine.objects.get(id=id)
    new.department_id = depcode
    new.medicine_code = med_code
    new.medicine_name = med_name
    new.slug = med_name
    new.medicine_quantity = med_quant
    new.medicine_price = med_price
    new.medicine_desc = med_desc
    new.save()
    neww = Actions()
    neww.action = 'Medicine' + ' ' + str(new.id) + ' ' + 'updated'
    neww.type = 'Medicine'
    neww.save()
    return redirect('med')