예제 #1
0
파일: views.py 프로젝트: zeinfikri/frepple
def cockpit(request):
  return render(request, 'index.html',
    context= {
      'title': _('cockpit'),
      'bucketnames': Bucket.objects.order_by('-level').values_list('name', flat=True),
      'currency': json.dumps(getCurrency())
      }
    )
예제 #2
0
파일: views.py 프로젝트: frePPLe/frePPLe
def cockpit(request):
  return render(
    request, 'index.html',
    context={
      'title': _('cockpit'),
      'bucketnames': Bucket.objects.order_by('-level').values_list('name', flat=True),
      'currency': json.dumps(getCurrency())
      }
    )
예제 #3
0
파일: views.py 프로젝트: scsi110/frepple
def cockpit(request):
    return render(
        request,
        "index.html",
        context={
            "title": _("cockpit"),
            "bucketnames": Bucket.objects.order_by("-level").values_list(
                "name", flat=True
            ),
            "currency": json.dumps(getCurrency()),
        },
    )
예제 #4
0
 def render(cls, request=None):
     limit = int(request.GET.get("limit", cls.limit))
     orderby = request.GET.get("orderby", cls.orderby)
     currency = getCurrency()
     try:
         db = _thread_locals.request.database or DEFAULT_DB_ALIAS
     except Exception:
         db = DEFAULT_DB_ALIAS
     result = [
         '<div class="table-responsive"><table class="table table-condensed table-hover">',
         '<thead><tr><th class="alignleft">%s</th><th class="aligncenter">%s</th>'
         '<th class="aligncenter">%s</th><th class="aligncenter">%s</th></tr></thead>'
         % (
             capfirst(force_text(_("item"))),
             capfirst(force_text(_("value of late demands"))),
             capfirst(force_text(_("quantity of late demands"))),
             capfirst(force_text(_("number of late demands"))),
         ),
     ]
     if orderby == "latedemandcount":
         topitems = (
             Item.objects.all()
             .using(db)
             .order_by("-latedemandcount", "latedemandvalue", "-latedemandquantity")
             .filter(rght=F("lft") + 1, latedemandcount__gt=0)
             .only(
                 "name", "latedemandcount", "latedemandquantity", "latedemandvalue"
             )[:limit]
         )
     elif orderby == "latedemandquantity":
         topitems = (
             Item.objects.all()
             .using(db)
             .order_by("-latedemandquantity", "latedemandvalue", "-latedemandcount")
             .filter(rght=F("lft") + 1, latedemandcount__gt=0)
             .only(
                 "name", "latedemandcount", "latedemandquantity", "latedemandvalue"
             )[:limit]
         )
     else:
         topitems = (
             Item.objects.all()
             .using(db)
             .order_by("-latedemandvalue", "-latedemandquantity", "-latedemandcount")
             .filter(rght=F("lft") + 1, latedemandcount__gt=0)
             .only(
                 "name", "latedemandcount", "latedemandquantity", "latedemandvalue"
             )[:limit]
         )
     alt = False
     for rec in topitems:
         result.append(
             '<tr%s><td class="underline"><a href="%s/demand/%s/">%s</a></td>'
             '<td class="aligncenter">%s%s%s</td><td class="aligncenter">%s</td>'
             '<td class="aligncenter">%s</td></tr>'
             % (
                 alt and ' class="altRow"' or "",
                 request.prefix,
                 quote(rec.name),
                 escape(rec.name),
                 currency[0],
                 int(rec.latedemandvalue),
                 currency[1],
                 int(rec.latedemandquantity),
                 rec.latedemandcount,
             )
         )
         alt = not alt
     result.append("</table></div>")
     return HttpResponse("\n".join(result))