Ejemplo n.º 1
0
def operatingHours(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    weekhours_max = list_weekhours_majority(category=plan.category)
    weekhours_min = list_weekhours_minority(category=plan.category)
    class_css = [
        'bg-pink', "bg-cyan", "bg-orange", "bg-teal", "bg-purple",
        'bg-blue-grey', 'bg-indigo'
    ]
    for i, week in enumerate(weekhours_max):
        week.update({'class_css': class_css[i]})
    for i, week in enumerate(weekhours_min):
        week.update({'class_css': class_css[i]})
    vals = dict(
        dict_base(request), **{
            'item': 'operating',
            'subitem': 'operatinghours',
            'plan': plan,
            'weekhours_max': weekhours_max,
            'weekhours_min': weekhours_min
        })
    return render(request, 'operating-hours.html', vals)
Ejemplo n.º 2
0
def polarityTopics(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    topics = list_details_topics(category=plan.category)
    counts = list(map(lambda x: x['count'], topics))
    pos = list(map(lambda x: x['count_pos'], topics))
    neg = list(map(lambda x: x['count_neg'], topics))
    neu = list(map(lambda x: x['count_neu'], topics))
    nouns = list(map(lambda x: x['topic'].topic, topics))
    vals = dict(
        dict_base(request), **{
            'plan': plan,
            'topics': topics,
            'nouns': nouns,
            'item': 'topics',
            'subitem': 'polaritytopics',
            'topics_count': counts,
            'count_pos': pos,
            'count_neg': neg,
            'count_neu': neu
        })
    return render(request, 'polarity-topics.html', vals)
Ejemplo n.º 3
0
def dashboardDetails(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    rivals = Business.objects.filter(category=plan.category)
    reviews = Review.objects.filter(business__category=plan.category)
    topics = list_details_topics(category=plan.category)
    counts = list(map(lambda x: x['count'], topics))
    pos = list(map(lambda x: x['count_pos'], topics))
    neg = list(map(lambda x: x['count_neg'], topics))
    neu = list(map(lambda x: x['count_neu'], topics))
    nouns = list(map(lambda x: x['topic'].topic, topics))
    week_count = list_weekdays(category=plan.category)
    lng_lat = list_locations(category=plan.category)
    lng = list(map(lambda l: l[0], lng_lat))
    lat = list(map(lambda l: l[1], lng_lat))
    weekhours_max = list_weekhours_majority(category=plan.category)
    class_css = [
        'bg-pink', "bg-cyan", "bg-orange", "bg-teal", "bg-purple",
        'bg-blue-grey', 'bg-indigo'
    ]
    for i, week in enumerate(weekhours_max):
        week.update({'class_css': class_css[i]})
    ranking = ranking_business(plan.category)[0:6]
    sublocation, count_sub = list_sublocations_small(plan.category)
    opinions_pos, opinions_neg = prepare_opinions(plan.category)
    phone, site, face = percentage_means_contact(plan.category)
    vals = dict(
        dict_base(request), **{
            'item': 'all',
            'plan': plan,
            'rivals': rivals,
            'sublocation': sublocation,
            'count_sub': count_sub,
            'reviews': reviews,
            'nouns': nouns,
            'lngs': lng,
            'lats': lat,
            'topics_count': counts,
            'count_pos': pos,
            'count_neg': neg,
            'count_neu': neu,
            'week_count': week_count,
            'weekhours_max': weekhours_max,
            'ranking': ranking,
            'op_pos': opinions_pos[:2],
            'op_neg': opinions_neg[:2],
            'phone': phone,
            'site': site,
            'face': face,
        })
    return render(request, 'dashboard.html', vals)
Ejemplo n.º 4
0
def deletePlan(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    plan.status = 'cancelada'
    plan.save(force_update='True')
    Notification.objects.create(
        title='Análise de concorrentes cancelado',
        message=
        'Você cancelou o plano de negocio %d e não poderá mais análisar as informações.'
        % (plan.category.specialty),
        user=profileLoggedIn(request))
    return redirect('liseapp:index')
Ejemplo n.º 5
0
def rankingBusiness(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    ranking = ranking_business(plan.category)
    vals = dict(
        dict_base(request), **{
            'item': 'business',
            'subitem': 'rankingbusiness',
            'plan': plan,
            'ranking': ranking
        })
    return render(request, 'ranking-business.html', vals)
Ejemplo n.º 6
0
def competitorOpinions(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    opinions_pos, opinions_neg = prepare_opinions(plan.category)
    vals = dict(
        dict_base(request), **{
            'plan': plan,
            'item': 'review',
            'subitem': 'competitoropinions',
            'opinions_pos': opinions_pos,
            'opinions_neg': opinions_neg
        })
    return render(request, 'competitor-opinions.html', vals)
Ejemplo n.º 7
0
def sublocations(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    sublocation, count = list_sublocations(plan.category)
    vals = dict(
        dict_base(request), **{
            'plan': plan,
            'item': 'maps',
            'subitem': 'sublocations',
            'sublocation': sublocation,
            'count': count
        })
    return render(request, 'sublocations.html', vals)
Ejemplo n.º 8
0
def editPlan(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    branchs = CategoryBusiness.objects.filter(active=True).values_list(
        'branch__name', flat=True).distinct()
    categories = [(branch,
                   list(
                       CategoryBusiness.objects.filter(
                           active=True,
                           branch__name=branch).values_list('specialty',
                                                            flat=True)))
                  for branch in branchs]
    vals = dict(dict_base(request), **{'plan': plan, 'categories': categories})
    return render(request, 'edit-plan.html', vals)
Ejemplo n.º 9
0
def operatingDays(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    week_count = list_weekdays(category=plan.category)
    counts = list(map(lambda x: x[1], week_count))
    vals = dict(
        dict_base(request), **{
            'plan': plan,
            'item': 'operating',
            'subitem': 'operatingdays',
            'week_count': week_count,
            'counts': counts
        })
    return render(request, 'operating-days.html', vals)
Ejemplo n.º 10
0
def competitionRegions(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    lng_lat = list_locations(category=plan.category)
    lng = list(map(lambda l: l[0], lng_lat))
    lat = list(map(lambda l: l[1], lng_lat))
    vals = dict(
        dict_base(request), **{
            'plan': plan,
            'item': 'maps',
            'subitem': 'competitionregions',
            'lngs': lng,
            'lats': lat
        })
    return render(request, 'competition-regions.html', vals)
Ejemplo n.º 11
0
def meansContact(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    phone, site, face = percentage_means_contact(plan.category)
    mixture = mixture_percentage_means(plan.category)
    vals = dict(
        dict_base(request), **{
            'plan': plan,
            'item': 'contact',
            'subitem': 'means',
            'phone': phone,
            'site': site,
            'face': face,
            'mixture': mixture
        })
    return render(request, 'means-contact.html', vals)
Ejemplo n.º 12
0
def topTopics(request, plan_id):
    try:
        plan = BusinessPlan.objects.get(id=plan_id)
    except:
        return redirect('liseapp:no-access')
    if not permission_access_plan(request, plan):
        return redirect('liseapp:no-access')
    topics = Topic.objects.filter(
        opinion__review__business__category=plan.category).distinct()
    topics_list = list_details_topics(category=plan.category)
    counts = list(map(lambda x: x['count'], topics_list))
    nouns = list(map(lambda x: x['topic'].topic, topics_list))
    vals = dict(
        dict_base(request), **{
            'item': 'topics',
            'subitem': 'toptopics',
            'plan': plan,
            'topics': topics,
            'nouns': nouns,
            'counts': counts
        })
    return render(request, 'top-topics.html', vals)