Exemplo n.º 1
0
    def post(self, request, pk=None, category=None, **kwargs):
        old = models.Episode.objects.get(pk=pk)
        new = models.Episode(patient=old.patient,
                             category_name=category,
                             date_of_admission=old.date_of_admission)
        new.save()

        for sub in episode_subrecords():
            if sub._is_singleton or not sub._clonable:
                continue
            for item in sub.objects.filter(episode=old):
                item.id = None
                item.episode = new
                item.save()
        serialised = new.to_dict(self.request.user)
        return _build_json_response(serialised)
Exemplo n.º 2
0
 def test_init_sets_original_active_value(self):
     episode = models.Episode()
     self.assertEqual(episode.active, episode._Episode__original_active)