Ejemplo n.º 1
0
def facebookcharts_sums_companies_per_branch():

    print "From Facebook Charts. IP: " + str(request.remote_addr)

    template = "social_charts/facebookcharts_sums_companies_per_branch.html"

    branches = get_branches()

    branch = request.form.get('branch')

    action = request.form.get('param')
    since = request.form.get('since')
    until = request.form.get('until')
    # company = request.form.get('company')
    data = None

    if action:
        if not branch:
            flash("Please give a Branch")
            data = getData("deletecompany")
            template = "social_charts/facebookmorechartsform.html"
            return render_template(
                template,
                branches=branches,
                nocompany=1,
                qaction=action,
                fbs=data,
                since=since,
                until=until,
                msg="Give the dates (optional/experimental):",
                notlist=0,
                chart_type="facebookcharts_sums_per_branch",
                title="Companies sums per Branch")

        if not since or not until or str(since).strip() == '' or str(
                until).strip() == '':
            data = get_fb_sums_per_branch(None, None, branch, 1)
        else:
            data = get_fb_sums_per_branch(since, until, branch, 1)
    else:
        data = getData("deletecompany")
        template = "social_charts/facebookmorechartsform.html"

    return render_template(template,
                           branches=branches,
                           nocompany=1,
                           qaction=action,
                           fbs=data,
                           since=since,
                           until=until,
                           msg="Give the dates (optional/experimental):",
                           notlist=0,
                           chart_type="facebookcharts_sums_per_branch",
                           title="Companies sums per Branch")
Ejemplo n.º 2
0
def facebookdataform():
    print "From Facebook data. IP: " + str(request.remote_addr)
    if request.method == "POST":

        # company = request.form['company']
        company = request.form.get('company')
        # population = request.form['population']
        since = request.form['since']
        until = request.form['until']

        print "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
        print "Company: %s, Since: %s, Until: %s" % (company, since, until)
        print "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"

        if company:
            print "From Facebook data. IP: " + str(
                request.remote_addr) + " Company: " + company.strip(
                ) + ", Since:" + since + " Until:" + until
            # fbs=FBParser([company.strip()], population)
            fbs, company_name, followers, branch = get_fb_data(
                company.strip(), since, until)
            return render_template("facebookdata.html",
                                   fbs=fbs,
                                   company_name=company_name,
                                   followers=followers,
                                   branch=branch,
                                   title="Facebook Data Retrieval")
        else:
            flash("Please give a company name")
        # pass

    data = getData("deletecompany")
    return render_template("facebookdataform.html", fbs=data)
Ejemplo n.º 3
0
def deletecompany():
    company = request.args.get('company')

    if company:
        print "From Facebook Delete Company. IP: " + str(
            request.remote_addr) + " Company: " + company
        result = delete_existing(company)
        if int(result) >= 0:
            flash("Company %s deleted successfully!" % company)

    data = getData("deletecompany")
    return render_template("social_charts/facebookdeletecompany.html",
                           fbs=data,
                           title="Delete Facebook Company")
Ejemplo n.º 4
0
def facebookcharts_sums_per_weekday_weekend():

    print "From Facebook Charts. IP: " + str(request.remote_addr)

    template = "social_charts/facebookcharts_sums_per_weekday_weekend.html"

    branches = get_branches()

    branch = request.form.get('branch')

    action = request.form.get('param')
    since = request.form.get('since')
    until = request.form.get('until')
    company = request.form.get('company')

    data = None

    if action:
        if not since or not until or str(since).strip() == '' or str(
                until).strip() == '':
            data = get_fb_sums_per_weekdays_weekends(company, None, None,
                                                     branch)
        else:
            data = get_fb_sums_per_weekdays_weekends(company, since, until,
                                                     branch)
    else:
        data = getData("deletecompany")
        template = "social_charts/facebookmorechartsform.html"

    return render_template(
        template,
        company=company,
        branches=branches,
        qaction=action,
        fbs=data,
        since=since,
        until=until,
        msg="Give the dates (optional/experimental):",
        notlist=0,
        chart_type="facebookcharts_sums_per_weekday_weekend",
        title="Companies per weekday/weekend")