Exemplo n.º 1
0
def analytics(request):
    dates = utils.previous_days(5)
    records_converted = []
    # for date in dates:
    # 	element = {}
    # 	element['year'] = str(date)
    # 	element['value'] = Record.objects.filter(user=request.user,conversion=True,date__startswith=date).count()
    # 	records_converted.append(element)
    # print "============================"
    # for i in records_converted:
    # 	print i
    # print "============================"
    client = utils.user_to_client(request.user)

    count = {}
    count['no_show'] = Record.objects.filter(user=request.user,
                                             no_show=True).count()
    count['take_away'] = Record.objects.filter(user=request.user,
                                               take_away=True).count()
    count['conversion'] = Record.objects.filter(user=request.user,
                                                conversion=True).count()

    return render(request, 'clients/adminpanel/charts/morris.html', {
        'records_converted': records_converted,
        'client': client,
        'count': count
    })
Exemplo n.º 2
0
def dashboard(request):
    if request.user.is_authenticated():
        client = utils.user_to_client(request.user)
        if client.first_login:
            return HttpResponseRedirect('/firstLogin/')
        n_of_tables = table.objects.get(user=request.user)
        seated = len(utils.get_seated_guests(request.user))
        waiting = len(utils.get_waiting_guests(request.user))
        total_guests = utils.get_total_visitors(request.user)
        total_no_show = utils.get_total_no_show(request.user)
        feed_stats = utils.get_feedback_stats(request.user)

        return render(
            request, 'clients/adminpanel/index.html', {
                'client': client,
                'n_of_tables': n_of_tables.n_of_table,
                'status': n_of_tables.status,
                'seated': seated,
                'waiting': waiting,
                'total_guests': total_guests,
                'total_no_show': total_no_show,
                'feed_stats': feed_stats
            })
    else:
        return HttpResponseRedirect('/login?msg=%s' % _MSG_CODES['lap'])
Exemplo n.º 3
0
def feedback_display(request):
    feedbacks = FeedbackService.objects.filter(user=request.user).exclude(
        service__isnull=True)
    answers = Answers.objects.filter(user=request.user)
    client = utils.user_to_client(request.user)
    return render(request, 'clients/adminpanel/tables/feedback_display.html', {
        'feedbacks': feedbacks,
        'client': client
    })
Exemplo n.º 4
0
def feedbackManager(request):
    rating_texts = RatingTexts.objects.get(user=request.user)
    client = utils.user_to_client(request.user)
    questions = Questions.objects.filter(user=request.user)
    return render(request, 'clients/feedbackManager.html', {
        'rating_texts': rating_texts,
        'client': client,
        'questions': questions
    })
Exemplo n.º 5
0
def firstLogin(request):
    if request.user.is_authenticated():
        client = utils.user_to_client(request.user)
        if client.first_login:
            if request.method == 'POST':
                first_name = request.POST.get('firstName', '')
                last_name = request.POST.get('lastName', '')
                mobile = request.POST.get('mobile', '')
                email = request.POST.get('email', '')
                n_of_table = int(request.POST.get('n_of_table', ''))
                city = request.POST.get('city', '')
                password = request.POST.get('password', '')
                rest_name = request.POST.get('restName', '')
                u = request.user
                u.set_password(password)
                u.save()
                print first_name, last_name, mobile, email, n_of_table, city, password, "CUSTOM"
                client = utils.user_to_client(request.user)
                client.first_name = first_name
                client.last_name = last_name
                client.mobile = mobile
                client.n_of_table = n_of_table
                free = []
                for i in range(1, n_of_table + 1):
                    free.append(i)
                free.sort()
                client.status = {'booked': [], 'free': free}
                client.email = email
                client.city = city
                client.rest_name = rest_name
                client.first_login = False
                client.save(update_fields=[
                    'first_login', 'status', 'rest_name', 'first_name',
                    'last_name', 'mobile', 'n_of_table', 'email', 'city'
                ])
                user = auth.authenticate(username=request.user.username,
                                         password=password)
                auth.login(request, user)
                return HttpResponseRedirect('/dashboard/')
            return render(request, 'clients/adminpanel/first_login.html')
        else:
            return HttpResponseRedirect('/dashboard/')

    return HttpResponseRedirect('/login?msg=%s' % _MSG_CODES['lap'])
Exemplo n.º 6
0
def ShowRecords(request):
    records_converted = Record.objects.filter(user=request.user,
                                              conversion=True)
    records_total = Record.objects.filter(user=request.user)
    client = utils.user_to_client(request.user)
    return render(
        request, "clients/adminpanel/tables/data.html", {
            'records_converted': records_converted,
            'records_total': records_total,
            'client': client
        })
Exemplo n.º 7
0
def login(request):
    if request.method == 'POST':
        username = request.POST.get('username', '')
        password = request.POST.get('password', '')
        user = auth.authenticate(username=username, password=password)
        if user is not None and user.is_active:
            # Correct password, and the user is marked "active"
            auth.login(request, user)
            client = utils.user_to_client(user)
            if client.first_login:
                return HttpResponseRedirect("/firstLogin/")
            # Redirect to a success page.
            return HttpResponseRedirect("/dashboard/")

        else:
            # Show an error page
            return render(request, 'clients/adminpanel/login.html',
                          {'msg': _MSG_CODES['swg']})

    msg = request.GET.get('msg', '')

    return render(request, 'clients/adminpanel/login.html', {'msg': msg})
Exemplo n.º 8
0
def front(request):
    if request.user.is_authenticated():
        client = utils.user_to_client(request.user)
        if client.first_login:
            return HttpResponseRedirect('/firstLogin/')
        rest_name = table.objects.get(user=request.user).rest_name
        url = '%s/api/v1/table/%s/?format=json' % (settings.HOST,
                                                   request.user.username)
        print url
        # response = '{"city": "Lucknow", "email": "*****@*****.**", "first_login": "******", "first_name": "Vikas", "last_name": "Mishra", "mobile": "234", "n_of_table": 13, "resource_uri": "/api/v1/table/onque/", "rest_name": "Fake", "seated": "{useated": []}", "status": "{u"booked": [], u"free": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]}", "user": "******", "username": "******", "waiting_list": "{u"waiting_list": []}"}'
        response = urllib2.urlopen(url)
        # r = requests.get('http://localhost:8001/api/v1/table/onque/?format=json')
        # waiting_list = r.json()

        print response
        waiting_list = json.load(response)
        users = utils.get_user_details(waiting_list['waiting_list'])
        parties_waiting = len(users)

        #--table checkout starts
        t = table.objects.get(user=request.user)
        client = t
        seated = t.seated['seated']
        parties_seated = len(seated)
        checkout_table_nums = t.status['booked']
        free_tables = t.status['free']
        #--table checkout ends

        return render(
            request, 'clients/front.html', {
                'users': users,
                'client': client,
                'checkout_table_nums': checkout_table_nums,
                'free_tables': free_tables,
                'parties_seated': parties_seated,
                'parties_waiting': parties_waiting
            })
    return HttpResponseRedirect('/login?msg=%s' % _MSG_CODES['lap'])
Exemplo n.º 9
0
def feedback_service(request):
    if request.method == 'POST':
        print "POST-------------------"
        table_num = request.POST.get('tableno', '')
        rating_qof = request.POST.get('rating_qof', '')
        rating_qos = int(request.POST.get('rating_qos', ''))
        rating_sf = int(request.POST.get('rating_sf', ''))
        rating_ab = int(request.POST.get('rating_ab', ''))
        rating_oe = int(request.POST.get('rating_oe', ''))
        info_name = request.POST.get('info_name', '')
        dob_date = request.POST.get('dob_date', '')
        dob_month = request.POST.get('dob_month', '')
        dob_year = request.POST.get('dob_year', '')
        info_contact = request.POST.get('info_contact', '')
        comments = request.POST.get('comments', '')
        dob = dob_date + "/" + MONTH[dob_month] + "/" + dob_year
        print "lmalfmalfmlamf"
        if (info_contact and info_name):
            try:
                if utils.guest_exists(info_contact):
                    pass
                else:
                    g = Guest(name=info_name,
                              mobile=info_contact,
                              dob=datetime.datetime.strptime(dob, "%d/%m/%Y"),
                              created_at=utils.time_now())
                    g.save()
                print rating_qof, rating_qos, rating_sf, rating_ab, rating_oe, table_num, info_name, dob, info_contact, comments
                fs = FeedbackService(user=request.user,
                                     date=utils.time_now(),
                                     mobile=info_contact,
                                     name=info_name,
                                     table_num=table_num,
                                     food=rating_qof,
                                     service=rating_qos,
                                     staff_friend=rating_sf,
                                     ambience=rating_ab,
                                     overall_exp=rating_oe,
                                     dob=dob,
                                     comments=comments)
                fs.save()
                print "HHAHAHAHAHAH"
                questions = Questions.objects.filter(
                    user=request.user).exclude(show=0)
                for q in questions:
                    print q
                    answer = request.POST.get('question_%d' % q.id, '')
                    a = Answers.objects.create(user=request.user,
                                               question=q,
                                               answer=answer)

                print "SAVED"
            except:
                return HttpResponseRedirect('/feedback?msg=Invalid Input')

            return HttpResponseRedirect('/feedback?msg=thanks')
        return HttpResponseRedirect('/feedback?msg=required')
    client = utils.user_to_client(request.user)
    try:
        rating_texts = RatingTexts.objects.get(user=request.user)
    except RatingTexts.DoesNotExist:
        rating_texts = RatingTexts.objects.create(user=request.user)

    questions = Questions.objects.filter(user=request.user).exclude(show=0)
    return render(request, 'clients/feedback_service.html', {
        'client': client,
        'rating_texts': rating_texts,
        'questions': questions
    })
Exemplo n.º 10
0
def admin_settings(request):
    if request.user.is_authenticated():

        if request.method == "POST":
            ChangePassword = request.POST.get('ChangePassword', '')
            ChangeTables = request.POST.get('ChangeTables', '')
            Other = request.POST.get('Other', '')
            first_name = request.POST.get('firstName', '')
            last_name = request.POST.get('lastName', '')
            mobile = request.POST.get('mobile', '')
            n_of_table = request.POST.get('n_of_table', '')
            password = request.POST.get('password', '')
            rest_name = request.POST.get('restName', '')

            client = utils.user_to_client(request.user)
            if n_of_table:
                print "Chaning No of tables"
                client.n_of_table = int(n_of_table)
                free = []
                for i in range(1, int(n_of_table) + 1):
                    free.append(i)
                free.sort()
                client.status = {'booked': [], 'free': free}
                client.seated = {'seated': []}
                client.waiting_list = {'waiting_list': []}
                client.save(update_fields=[
                    'n_of_table', 'seated', 'waiting_list', 'status'
                ])

            if first_name:
                client.first_name = first_name
                client.save(update_fields=['first_name'])

            if last_name:
                client.last_name = last_name
                client.save(update_fields=['last_name'])

            if rest_name:
                client.rest_name = rest_name
                client.save(update_fields=['rest_name'])

            if mobile:
                client.mobile = mobile
                client.save(update_fields=['mobile'])

            if password:
                print "Changing Password"
                u = request.user
                u.set_password(password)
                u.save()
                user = auth.authenticate(username=request.user.username,
                                         password=password)
                auth.login(request, user)

            # t=table.objects.get(user=request.user)
            # n = int(request.POST.get('n_of_table'))
            # t.n_of_table = n

            return HttpResponseRedirect('/dashboard/')
        client = utils.user_to_client(request.user)
        return render(request, 'clients/adminpanel/settings.html',
                      {'client': client})

    return HttpResponseRedirect('/login?msg=%s' % _MSG_CODES['lap'])