コード例 #1
0
    def test_get_resource_types(self):
        # this is the api call we are testing
        res_types = hydroshare.get_resource_types()

        # test that each resource type is a subclass of BaseResource type
        for res_type in res_types:
            self.assertEqual(issubclass(res_type, BaseResource), True)
コード例 #2
0
ファイル: views.py プロジェクト: hydroshare/hs_metrics
    def get_all_resources(self):
        """Yield all resources in the system as a single generator"""

        resource_types = hydroshare.get_resource_types()
        for qs in (res_model.objects.all() for res_model in resource_types):
            for resource in qs:
                yield resource
コード例 #3
0
    def get_all_resources(self):
        """Yield all resources in the system as a single generator"""

        resource_types = hydroshare.get_resource_types()
        for qs in (res_model.objects.all() for res_model in resource_types):
            for resource in qs:
                yield resource
コード例 #4
0
    def test_get_resource_types(self):
        # this is the api call we are testing
        res_types = hydroshare.get_resource_types()

        # test that each resource type is a subclass of AbstractResource type
        for res_type in res_types:
            self.assertEqual(issubclass(res_type, AbstractResource), True)


        # not sure what else can be tested
コード例 #5
0
ファイル: views.py プロジェクト: kob-aha/hydroshare
    def get_context_data(self, **kwargs):
        if 'user' in kwargs:
            try:
                u = User.objects.get(pk=int(kwargs['user']))
            except:
                u = User.objects.get(username=kwargs['user'])

        else:
            try:
                u = User.objects.get(pk=int(self.request.GET['user']))
            except:
                u = User.objects.get(username=self.request.GET['user'])

        resource_types = get_resource_types()
        res = []
        for Resource in resource_types:
            res.extend([r for r in Resource.objects.filter(user=u)])

        return {
            'u' : u,
            'resources' :  res
        }
コード例 #6
0
class ResourceCreateRequestValidator(ResourceUpdateRequestValidator):
    resource_type = serializers.ChoiceField(
        choices=zip([x.__name__ for x in hydroshare.get_resource_types()],
                    [x.__name__ for x in hydroshare.get_resource_types()]),
        default='GenericResource')
コード例 #7
0
 class CreateResourceForm(UpdateResourceForm):
     resource_type = forms.ChoiceField(
         choices=zip([x.__name__ for x in hydroshare.get_resource_types()],
                     [x.__name__ for x in hydroshare.get_resource_types()]))