Exemplo n.º 1
0
import random
import datetime
import argparse
from math import floor

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "dashboard.settings")

    from dashboard.settings import REGIONAL_DATA

    from django.core.wsgi import get_wsgi_application

    application = get_wsgi_application()

    countries = []
    for region in REGIONAL_DATA.iterkeys():
        countries.extend(REGIONAL_DATA[region])
    random.shuffle(countries)

    traffic = ["exchange", "publisher"]
    type = ["banners", "video"]
    campaign_status = [True, False]
    budget = [500, 1000, 1500, 2000]
    revenue = [30, 50, 100, 500, 1200, 1800, 2300]
    margin = [10, 20, 100, 150, 350, 550, 650, 1200]
    base = datetime.datetime.today()
    date_list = [base - datetime.timedelta(days=x) for x in range(-2, 3)]
    _oses = ["iOS", "Android"]
    from sales.models import *
    from admin.models import *
    from django.db.models.aggregates import Max, Min
Exemplo n.º 2
0
from datetime import datetime, date, timedelta
from math import ceil
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.db.models import Sum
from isoweek import Week

from sales.models import UserPlan, StatAdvertiser
from dashboard.settings import REGIONAL_DATA
from admin.models import  Account, AuthUser

# Create your views here.

regions = REGIONAL_DATA.keys()

@login_required
def sales_commission(request):
    users = AuthUser.objects.all

    accounts = Account.objects.values('region').distinct()
    groups = Account.objects.values('business_unit').distinct()

    regions = [r['region'] for r in accounts]
    groups = [r['business_unit'] for r in groups]

    m = date.today().month
    c = int(ceil(m / 3.0))

    params = {
        'user': int(request.GET.get('user', request.user.id)),
        'region': request.GET.get('region', 'all'),