Example #1
0
def costbuckets(request):
    year, month = getmonthyear(request)
    kwargs = {"year": year,
              "month": month}
    if request.GET.get("team"):
        cbb = ActivityEntry.costbucket_count(group_for_team(request.GET["team"]), **kwargs)
    else:
        cbb = ActivityEntry.costbucket_count(MARKET_CHOICES_LIST, **kwargs)
    team = MARKET_CHOICES_MAP.get(request.GET["team"]) \
           if request.GET.get("team") else "All teams"
    if not team:
        raise Http404
    return render_to_response(
        "industrial_engineering_reports.html",
        {
            "teams": MARKET_CHOICES,
            "team": team,
            "year": year,
            "months": generate_month_box(id="month"),
            "selected_month": month,
            "selected_team": request.GET["team"] if request.GET.get("team") else "AD",
            "costbuckets": cbb,
            "current": " %s/%s" % (year, month)
        },
        RequestContext(request)
    )
Example #2
0
 def test_costbucket_count(self):
     ActivityEntry.objects.create(
         user=self.linked_user,
         activity=Activity.objects.all()[0],
         amount=1,
         creation_date=datetime.datetime.today()
     ).save()
     ActivityEntry.objects.create(
         user=self.linked_user,
         activity=Activity.objects.all()[0],
         amount=1,
         creation_date=datetime.datetime.today()
     ).save()
     ActivityEntry.objects.create(
         user=self.linked_user,
         activity=Activity.objects.all()[0],
         amount=1,
         creation_date=datetime.datetime.today()
     ).save()
     ActivityEntry.objects.create(
         user=self.linked_user,
         activity=Activity.objects.all()[0],
         amount=1,
         creation_date=datetime.datetime.today()
     ).save()
     self.assertEquals(ActivityEntry.costbucket_count(MARKET_CHOICES_LIST)[''], 4)
Example #3
0
def costbuckets(request):
    year, month = getmonthyear(request)
    kwargs = {"year": year, "month": month}
    if request.GET.get("team"):
        cbb = ActivityEntry.costbucket_count(
            group_for_team(request.GET["team"]), **kwargs)
    else:
        cbb = ActivityEntry.costbucket_count(MARKET_CHOICES_LIST, **kwargs)
    team = MARKET_CHOICES_MAP.get(request.GET["team"]) \
           if request.GET.get("team") else "All teams"
    if not team:
        raise Http404
    return render_to_response(
        "industrial_engineering_reports.html", {
            "teams": MARKET_CHOICES,
            "team": team,
            "year": year,
            "months": generate_month_box(id="month"),
            "selected_month": month,
            "selected_team":
            request.GET["team"] if request.GET.get("team") else "AD",
            "costbuckets": cbb,
            "current": " %s/%s" % (year, month)
        }, RequestContext(request))
Example #4
0
 def test_costbucket_count(self):
     ActivityEntry.objects.create(
         user=self.linked_user,
         activity=Activity.objects.all()[0],
         amount=1,
         creation_date=datetime.datetime.today()).save()
     ActivityEntry.objects.create(
         user=self.linked_user,
         activity=Activity.objects.all()[0],
         amount=1,
         creation_date=datetime.datetime.today()).save()
     ActivityEntry.objects.create(
         user=self.linked_user,
         activity=Activity.objects.all()[0],
         amount=1,
         creation_date=datetime.datetime.today()).save()
     ActivityEntry.objects.create(
         user=self.linked_user,
         activity=Activity.objects.all()[0],
         amount=1,
         creation_date=datetime.datetime.today()).save()
     self.assertEquals(
         ActivityEntry.costbucket_count(MARKET_CHOICES_LIST)[''], 4)