Exemplo n.º 1
0
 def get(self, *args, **kwargs):
     # while we manage transition lets allow a fall back to the old way
     name = kwargs['tag']
     if 'subtag' in kwargs:
         name += '-' + kwargs['subtag']
     patient_list = PatientList.get(name)()
     return _build_json_response(patient_list.to_dict(self.request.user))
Exemplo n.º 2
0
    def get_template_from_model(self):
        list_prefixes = None

        if self.list_slug:
            patient_list = PatientList.get(self.list_slug)()
            list_prefixes = patient_list.get_template_prefixes()
        return self.column.get_modal_template(prefixes=list_prefixes)
Exemplo n.º 3
0
 def retrieve(self, request, pk=None):
     try:
         patientlist = PatientList.get(pk)()
     except ValueError:
         return json_response({'error': 'List does not exist'},
                              status_code=status.HTTP_404_NOT_FOUND)
     return json_response(patientlist.to_dict(request.user))
Exemplo n.º 4
0
    def get_template_from_model(self):
        patient_list = None

        if self.list_slug:
            patient_list = PatientList.get(self.list_slug)()
        return self.column.get_modal_template(
            patient_list=patient_list
        )
Exemplo n.º 5
0
 def retrieve(self, request, pk=None):
     try:
         patientlist = PatientList.get(pk)()
     except ValueError:
         return json_response(
             {'error': 'List does not exist'},
             status_code=status.HTTP_404_NOT_FOUND
         )
     return json_response(patientlist.to_dict(request.user))
Exemplo n.º 6
0
    def get_template_from_model(self):
        list_prefixes = None

        if self.list_slug:
            patient_list = PatientList.get(self.list_slug)()
            list_prefixes = patient_list.get_template_prefixes()
        return self.column.get_modal_template(
            prefixes=list_prefixes
        )
Exemplo n.º 7
0
    def test_tagging_set_without_subtag(self):
        ''' given an episode with certain tags and the required request we should
            only return episodes with those tags
        '''
        self.episode_2.set_tag_names(["carnivore"], self.user)

        patient_list = PatientList.get("carnivore")()
        self.assertEqual([self.episode_2],
                         [i for i in patient_list.get_queryset()])
        serialized = patient_list.to_dict(self.user)
        self.assertEqual(len(serialized), 1)
        self.assertEqual(serialized[0]["id"], self.episode_2.id)
Exemplo n.º 8
0
    def test_tagging_set_without_subtag(self):
        ''' given an episode with certain tags and the required request we should
            only return episodes with those tags
        '''
        self.episode_2.set_tag_names(["carnivore"], self.user)

        patient_list = PatientList.get("carnivore")()
        self.assertEqual(
            [self.episode_2], [i for i in patient_list.get_queryset()]
        )
        serialized = patient_list.to_dict(self.user)
        self.assertEqual(len(serialized), 1)
        self.assertEqual(serialized[0]["id"], 2)
Exemplo n.º 9
0
    def test_mine(self):
        ''' given to episodes, calling mine should only return the one tagged with
            the user
        '''
        self.episode_1.set_tag_names(["mine"], self.user)
        self.assertIn(Mine, PatientList.list())

        mock_request = MagicMock(name='Mock request')
        mock_request.user = self.user

        patient_list = PatientList.get("mine")()
        self.assertEqual(
            [self.episode_1], [i for i in patient_list.get_queryset()]
        )
        serialized = patient_list.to_dict(self.user)
        self.assertEqual(len(serialized), 1)
        self.assertEqual(serialized[0]["id"], 1)
Exemplo n.º 10
0
 def dispatch(self, *args, **kwargs):
     try:
         self.patient_list = PatientList.get(kwargs['slug'])
     except ValueError:
         self.patient_list = None
     return super(PatientListTemplateView, self).dispatch(*args, **kwargs)
Exemplo n.º 11
0
 def dispatch(self, *args, **kwargs):
     try:
         self.patient_list = PatientList.get(kwargs['slug'])
     except ValueError:
         self.patient_list = None
     return super(PatientListTemplateView, self).dispatch(*args, **kwargs)