Ejemplo n.º 1
0
def track(request):
    if request.method == 'POST':
        orderId = request.POST.get('order_id')
        email = request.POST.get('email')
        print(orderId, email)
        try:
            orders = Orders.objects.filter(order_id=orderId, o_email=email)

            if (len(orders) > 0):
                update = OrderUpdate.objects.filter(order_id=orderId)
                updates = []
                for item in update:
                    updates.append({
                        'text': item.update_desc,
                        'time': item.timestamp
                    })
                    response = json.dumps([updates, orders[0].items_json],
                                          default=str)
                print(response)
                return hr(response)

            else:
                return hr("{}")
        except Exception as e:
            print(f"Exception {e}")
            return hr('{}')
    return render(request, 'shop/track.html')
Ejemplo n.º 2
0
 def put(self, request, *args, **kwargs):
     for a in self.data.get('assignment_changes', []):
         ass = self.__class__.objects.get(id=a['id'])
         ass.requirements = a['desc']
         ass.due_date = a['due_date']
         ass.save()
     for req in self.data.get('req_changes', []):
         ass = self.__class__.objects.get(id=req['id'])
         desc = json.loads(ass.requirements)
         users = UserAssignment.objects.filter(assignment_id=ass.pk)
         for u in users:
             u.reqs = json.loads(u.requirements)
         for i in req.get('remove_reqs', []):
             desc.pop(i)
             for u in users:
                 u.reqs.pop(i)
         for i in req.get('new_reqs', []):
             desc.append(i)
             for u in users:
                 u.reqs.append(i)
         for u in users:
             u.requirements = json.dumps(u.reqs)
             u.save()
         ass.requirements = json.dumps(desc)
         ass.save()
     return hr(content_type="text/plain", status=204)
Ejemplo n.º 3
0
def removepunc(request):
    res = request.POST.get('text', 'default')
    rm = request.POST.get('rm', 'off')
    capital = request.POST.get('capital', 'off')

    if rm == 'on':
        punc = '''!"#$%&'()*+, -./:;<=>?@[\]^_`{|}~'''
        purpose = 'Text after removing punctuations'
        text = ''
        for char in res:
            if char not in punc:
                text += char
        params = {'purpose': purpose, 'text': text}
        return render(request, 'show.html', params)

    elif capital == 'on':
        purpose = 'Capitalized Text'
        text = ''
        for char in res:
            text += char.upper()

        params = {'purpose': purpose, 'text': text}
        return render(request, 'show.html', params)

    else:
        return hr("error")
Ejemplo n.º 4
0
def Manage_Your_Connections(request, action, u_id):
    if not request.user.is_authenticated:
        return redirect("login")
    if action == "Send_Request":
        senderUser = User.objects.get(username=request.user.username)
        sender = UserData.objects.get(usr=senderUser)
        receiver = UserData.objects.get(id=u_id)
        Connections.objects.create(sender=sender, receiver=receiver)
        return redirect("UserProfile", receiver.usr.username)
    if action == "Accept_Request" or action == "Reject_Request":
        ReceiverUser = User.objects.get(username=request.user.username)
        receiver = UserData.objects.get(usr=ReceiverUser)
        sender = UserData.objects.get(id=u_id)
        connection = Connections.objects.filter(sender=sender,
                                                receiver=receiver)
        if connection:
            for c in connection:
                if action == "Accept_Request":
                    c.status = "friend"
                    c.save()
                if action == "Reject_Request":
                    c.status = "rejected"
                    c.save()

        return redirect("professionals", "all")

    return hr("you want" + str(action) + "for user" + str(u_id))
Ejemplo n.º 5
0
def Register(request):
    if request.method == "POST":
        form = AddUserForm(request.POST, request.FILES) #call the form for files differently
        if form.is_valid(): #check if ur form is valid
            data = form.save(commit=False) #saving ecerything in data
            un = request.POST["un"]
            ps = request.POST["ps"]
            email = data.email
            usr = User.objects.create_user(un, email, ps)
            data.usr = usr
            data.save()
            return redirect("login")

        return hr("get Registered")
Ejemplo n.º 6
0
def index(resp):
    recordIP(resp)
    index_refresh()
    con = {
        'cont': cont,
        'day': day,
        'month': month,
        'date': date,
        'today': today,
        'title': title,
        'cdate': cdate,
        'content': content,
        'img': img,
    }
    #print(con)
    return hr(rts('index.html', con))
Ejemplo n.º 7
0
def coment(request):
    return hr("<h1>validated</h1>")
Ejemplo n.º 8
0
def analyze(request):
    return hr("hello I am manav")
Ejemplo n.º 9
0
def index(request):
    return hr("shalom")
Ejemplo n.º 10
0
def page3(request):
    d1 = render_to_string("p3.html")
    return hr(d1)
Ejemplo n.º 11
0
def aboutfrc(resp):
    recordIP(resp)
    return hr(rts('intro.html'))
Ejemplo n.º 12
0
def page404(resp):
    recordIP(resp)
    return hr(rts('404.html'))
Ejemplo n.º 13
0
def aboutus(resp):
    recordIP(resp)
    return hr(rts('aboutus.html'))
Ejemplo n.º 14
0
def studentdetails(request, name):
    return hr("yu want details about: {}".format(name))
Ejemplo n.º 15
0
def songnumber(request, snum):
    return hr("Searching for song no {}".format(snum))
Ejemplo n.º 16
0
def page4(request):
    d2 = render_to_string("p4.html")
    return hr(d2)
Ejemplo n.º 17
0
def post(request):
    if (request.method == 'POST'):
        b = request.body
        print(b)
    return hr(100)
Ejemplo n.º 18
0
def Error_404(request, exception=True):
    return hr("My Error 404 Page")