def dispatch(self, request, *args, **kwargs): self.name = kwargs.get('name', 'pathway') self.pathway = Pathway.get(self.name)() self.is_modal = request.GET.get("is_modal", False) return super(PathwayTemplateView, self).dispatch( request, *args, **kwargs )
def create(self, request, **kwargs): # actually saves the pathway pathway = Pathway.get(self.name)() data = request.data before_patient = None before_episode = None if self.episode_id: before_episode = Episode.objects.get(id=self.episode_id) if self.patient_id: before_patient = Patient.objects.get(id=self.patient_id) patient, episode = pathway.save(data, user=request.user, patient=before_patient, episode=before_episode) redirect = pathway.redirect_url(user=request.user, patient=patient, episode=episode) episode_id = None if episode: episode_id = episode.id return json_response({ "episode_id": episode_id, "patient_id": patient.id, "redirect_url": redirect })
def create(self, request, **kwargs): # actually saves the pathway pathway = Pathway.get(self.name)() data = request.data before_patient = None before_episode = None if self.episode_id: before_episode = Episode.objects.get(id=self.episode_id) if self.patient_id: before_patient = Patient.objects.get(id=self.patient_id) patient, episode = pathway.save( data, user=request.user, patient=before_patient, episode=before_episode ) redirect = pathway.redirect_url( user=request.user, patient=patient, episode=episode ) episode_id = None if episode: episode_id = episode.id return json_response({ "episode_id": episode_id, "patient_id": patient.id, "redirect_url": redirect })
def retrieve(self, *args, **kwargs): # gets the pathways pathway_cls = Pathway.get(self.name) episode = None patient = None if self.episode_id: episode = Episode.objects.get(id=self.episode_id) if self.patient_id: patient = Patient.objects.get(id=self.patient_id) pathway = pathway_cls() is_modal = self.request.GET.get("is_modal", False) == "True" serialised = json_response( pathway.to_dict(is_modal, user=self.request.user, patient=patient, episode=episode)) return serialised
def retrieve(self, *args, **kwargs): # gets the pathways pathway_cls = Pathway.get(self.name) episode = None patient = None if self.episode_id: episode = Episode.objects.get(id=self.episode_id) if self.patient_id: patient = Patient.objects.get(id=self.patient_id) pathway = pathway_cls() is_modal = self.request.GET.get("is_modal", False) == "True" serialised = json_response( pathway.to_dict( is_modal, user=self.request.user, patient=patient, episode=episode ) ) return serialised
def test_get_by_hyphenated_slug(self): self.assertEqual(PathwayExample, Pathway.get('dog-owner'))
def test_get_by_hyphenated_slug(self): self.assertEqual(PathwayExample, Pathway.get('dog-owner'))
def dispatch(self, request, *args, **kwargs): self.name = kwargs.get('name', 'pathway') self.pathway = Pathway.get(self.name)() self.is_modal = request.GET.get("is_modal", False) return super(PathwayTemplateView, self).dispatch(request, *args, **kwargs)