Пример #1
0
    def _freeze_counts(request, context):
        if not (request.POST.get('sp_select') and request.POST.get('area_select')):
            raise ValidationError("Please fill all the fields carefully")

        a = Area.query(ar=request.POST.get('area_select'))
        if a is None:
            raise ValidationError("Are you tracking to hack me??!!")

        sp = SoftwareProduct.query(sp_id=request.POST.get('sp_select'))
        if sp is None:
            raise ValidationError("Invalid SP")

        sa = SubArea.query(fa_obj=a)
        if sa is None:
            raise ValidationError("No Sub Areas found under this Area")

        locs = Geo.objects.all()
        for lev in LEVELS:
            lev = str(lev.value)
            for s in sa:
                for l in locs:
                    k = s.subarea + "_" + l.geo + "_L" + str(lev)
                    if k in request.POST.keys():
                        cnt = request.POST.get(k)
                        if cnt == "":
                            cnt = 0
                        cc, created = CaseCount.get_or_create(
                            sp_obj=sp[0], sa_obj=s, lev=lev,
                            loc=l, cnt=cnt)
                        logger.info(cc)

        return ProductViewHelper._return_context(context=context,
                                                 created=created,
                                                 msgname='countsform_msg',
                                                 added_data=a.area + ' counts')
Пример #2
0
    def _get_report_bysp(context, sp, area, msg):
        sp = SoftwareProduct.query(sp_id=sp)
        if not sp is None:
            context[msg] = sp[0].sp_name

        ar = Area.query(ar=area)
        if not ar is None:
            context[msg] += ' ' + ar.area

        return context, sp[0].sp_name, ar.area
Пример #3
0
    def _query_by_spid(sp_id):
        sp = SoftwareProduct.query(sp_id=sp_id)
        if sp is None:
            return None

        return sp[0]