def post(self,  *args, **kwargs):
        from pact.models import PactPatientCase, CDotWeeklySchedule

        pdoc = PactPatientCase.get(self.request.GET['case_id'])
        resp = HttpResponse()
        if self.method == "rm_schedule":
            if self.request.POST.has_key('rm_schedule'):
                #hacky remove schedule method
                pdoc.rm_last_schedule()
                pdoc.save()
                resp.status_code = 204
                return resp

        elif self.method == "schedule":
            form = ScheduleForm(data=self.request.POST)
            if form.is_valid():
                sched = CDotWeeklySchedule()
                for day in DAYS_OF_WEEK:
                    if form.cleaned_data[day] != 'None':
                        setattr(sched, day, form.cleaned_data[day])
                if form.cleaned_data['active_date'] == None:
                    sched.started = datetime.utcnow()
                else:
                    sched.started = datetime.combine(form.cleaned_data['active_date'], time.min)
                sched.comment = form.cleaned_data['comment']
                sched.created_by = self.request.user.username
                sched.deprecated = False
                pdoc.set_schedule(sched)
                pdoc.save()
                set_schedule_case_properties(pdoc)
                resp.status_code = 204
                return resp
            else:
                resp.write(str(form.errors))
                resp.status_code = 406
                return resp

        elif self.method == 'providers':
            try:
                submitted_provider_ids = json.loads(self.request.POST['selected_providers'])
                case_provider_ids = list(pdoc.get_provider_ids())

                if submitted_provider_ids != case_provider_ids:
                    try:
                        #len difference
                        submitted_len = len(submitted_provider_ids)
                        case_len = len(case_provider_ids)
                        if submitted_len < case_len:
                            for x in range(case_len-submitted_len):
                                submitted_provider_ids.append('')
                        pdoc.update_providers(self.request.couch_user, submitted_provider_ids)
                        resp.write("success")
                        resp.status_code=204
                    except Exception, ex:
                        resp.write(ex % "Error submitting: %s")
                        resp.status_code=500
                else:
                    resp.write("")
                    resp.status_code=304
            except Exception, ex:
                resp.write("Error submitting: %s" % ex)
                resp.status_code=500
            return resp



        elif self.method == "patient_edit":
            form = PactPatientForm(self.request, pdoc, data=self.request.POST)
            if form.is_valid():
                update_data = form.clean_changed_data
                submit_case_update_form(pdoc, update_data, self.request.couch_user)
                resp.status_code = 204
                return resp
            else:
                resp.write(str(form.errors))
                resp.status_code = 406
                return resp
dataset/ETHPy150Open dimagi/commcare-hq/custom/_legacy/pact/api.py/PactAPI.post/swapped operands of `%`