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')
 def _add_subarea(request, context):
     if not (request.POST.get('area_select') and request.POST.get('subarea')):
         raise ValidationError("Invalid Sub Area")
     a = Area.query(ar=request.POST.get('area_select'))
     if a is None:
         raise ValidationError("Are you tracking to hack me??!!")
     sa, created = SubArea.get_or_create(
         fa=a, subarea_data=request.POST.get('subarea'))
     return ProductViewHelper._return_context(context=context,
                                              created=created,
                                              msgname='subareaform_msg',
                                              added_data=sa.subarea)