示例#1
0
 class Meta:
     resource_name = 'receivers'
     queryset = Receiver.objects.all()
     filtering = {
         'id': ALL,
         'name': ALL,
         'address1': ALL,
         'address2': ALL,
         'address3': ALL,
         'city': ALL,
         'state': ALL,
         'zipcode': ALL,
         'country': ALL,
     }
     authentication = ApiKeyAuthentication()
     authorization = DjangoAuthorization()
     allowed_methods = ['get', ]
     always_return_data = True
示例#2
0
 class Meta:
     queryset = RegisteredNode.objects.all(
     )  # everything in the Techicians database - or use Entry.objects.all().filter(pub_date__year=2006) to restrict what is returned
     resource_name = 'register'  # when it is called its name will be called technicians
     excludes = []
     list_allowed_methods = ['get', 'post', 'put']
     filtering = {
         'UIC': ALL,
         'channel': ALL,
         'band': ALL,
         'mode': ALL,
     }  # can use the filtering options from django
     authorization = DjangoAuthorization()
     authentication = OAuth2ScopedAuthentication(
         post=("read write", ),
         get=("read", ),
         put=("read", "write"),
     )
示例#3
0
 class Meta:
     resource_name = 'purchase_order_line_items'
     queryset = PurchaseOrderLineItem.objects.all()
     filtering = {
         'id': ALL,
         'purchase_order': ALL_WITH_RELATIONS,
         'sku': ALL_WITH_RELATIONS,
         'quantity_received': ALL,
         'unit_cost': ALL,
         'discount_percent': ALL,
         'discount_dollar': ALL,
         'adjusted_unit_cost': ALL,
         'total_cost': ALL,
     }
     authentication = ApiKeyAuthentication()
     authorization = DjangoAuthorization()
     allowed_methods = ['get', ]
     always_return_data = True
示例#4
0
 class Meta:
     include_resource_uri = False
     queryset = TalkSession.objects.all()
     authorization = Authorization()
     paginator_class = Paginator
     serializer = PrettyJSONSerializer()
     authentication = CustomAuthentication()
     authorization = DjangoAuthorization()
     list_allowed_methods = ['get']
     """authentication = OAuth20Authentication()"""
     filtering = {
         'title': ALL,
         'time': (
             'exact',
             'startswith',
         ),
         'last_modified_date': ['gt']
     }
示例#5
0
    class Meta:

        list_allowed_methods = ['get']
        queryset = vioclient.objects.all()

        excludes = [
            'desired_procs_unit', 'latest_service_request_id',
            'manage_netcard', 'max_mem', 'max_procs', 'max_procs_unit',
            'min_mem', 'min_procs', 'min_procs_unit', 'password',
            'resource_uri', 'service_netcard', 'username',
            'virtual_eth_adapters', 'virtual_scsi_adapter'
        ]

        filtering = {'belong_to_username': ('exact', )}
        resource_name = 'vioclient'
        authentication = MultiAuthentication(
            CurrentUserVIOClientAuthorization())
        authorization = DjangoAuthorization()
示例#6
0
    class Meta:
        list_allowed_methods = ['get']
        queryset = RequestStatus.objects.all()

        filtering = {
            'request_status_id': (
                'lt',
                'tg',
                'exact',
                'startswith',
            )
        }
        resource_name = 'RequestStatus'
        authentication = MultiAuthentication(aix_user_Authentication(),
                                             vmware_user_Authentication(),
                                             common_admin_authentication(),
                                             sys_admin_authentication())
        authorization = DjangoAuthorization()
示例#7
0
文件: api.py 项目: shayanb/pootle
 class Meta:
     queryset = Language.objects.all()
     resource_name = 'languages'
     fields = [
         'code',
         'description',
         'fullname',
         'nplurals',
         'pluralequation',
         'specialchars',
         'translation_projects',
     ]
     filtering = {
         "code": TEXT_LOOKUPS,
     }
     # HTTP methods allowed for visiting /statistics/ URLs.
     statistics_allowed_methods = ['get']
     authorization = DjangoAuthorization()
     authentication = BasicAuthentication()
示例#8
0
文件: api.py 项目: JMassapina/pootle
 class Meta:
     queryset = Store.objects.all()
     resource_name = 'stores'
     fields = [
         'file',
         'name',
         'pending',
         'pootle_path',
         'state',
         'sync_time',
         'tm',
         'translation_project',
         'units',
     ]
     list_allowed_methods = ['post']
     # HTTP methods allowed for visiting /statistics/ URLs
     statistics_allowed_methods = ['get']
     authorization = DjangoAuthorization()
     authentication = BasicAuthentication()
示例#9
0
文件: api.py 项目: szaydel/ralph
 class Meta:
     queryset = Venture.objects.all()
     authentication = ApiKeyAuthentication()
     authorization = DjangoAuthorization()
     filtering = {
         'id': ALL,
         'name': ALL,
         'symbol': ALL,
         'data_center': ALL_WITH_RELATIONS,
         'show_in_ralph': ALL,
     }
     excludes = (
         'save_priorities',
         'max_save_priority',
     )
     cache = SimpleCache()
     throttle = CacheThrottle(throttle_at=THROTTLE_AT,
                              timeframe=TIMEFRAME,
                              expiration=EXPIRATION)
示例#10
0
 class Meta:
     queryset = Chance.objects.all()
     allowed_methods = ALL_METHODS
     resource_name = 'chance'
     authorization = DjangoAuthorization()
     authentication = MultiAuthentication(
         ApiKeyAuthentication(),
         SessionAuthentication()
     )
     ordering = {
         'date_created': ALL,
         'date_updated': ALL
     }
     filtering = {
         'id': ALL,
         'number': ALL,
         'date_created': ALL,
         'date_updated': ALL
     }
示例#11
0
文件: api.py 项目: arctelix/pinimatic
    class Meta:
        always_return_data = True
        queryset = Comment.objects.all()
        resource_name = 'cmnt'
        include_resource_uri = False
        allowed_methods = [
            'get', 'post', 'delete'
        ]  #TODO: I should be using put for comment edits....
        #fields, object_pk & content_type_id are REQUIRED for generic foreign key
        fields = ['id', 'comment', 'submit_date']
        #excludes = ["ip_address", "is_public", "is_removed", "user_email", "user_name", "user_url"]
        #other fields: "comment", "content_type_id", "id", "object_pk", "submit_date", "user_id", "username"

        filtering = {
            'object_pk': ALL_WITH_RELATIONS,
            'content_type': ALL_WITH_RELATIONS,
        }
        #authentication = BasicAuthentication()
        authorization = DjangoAuthorization()
示例#12
0
 class Meta:
     queryset = UserProfile.objects.all()
     allowed_methods = ['get', 'put', 'patch']
     resource_name = 'user-profile'
     authentication = BasicAuthentication()
     authorization = DjangoAuthorization()
     filtering = {
         'user': ALL_WITH_RELATIONS,
         'email_verified': ALL,
         'user_name': ALL,
         'full_name': ALL,
         'user_bio': ALL,
         'user_home_city': ALL,
         'zip_code': ALL,
         'longitude': ALL,
         'last_updated': ALL,
         'website': ALL,
         'interests': ALL_WITH_RELATIONS,
         'user_photo': ALL_WITH_RELATIONS,
     }
示例#13
0
    class Meta:
        resource_name = 'stub_findings'
        queryset = Stub_Finding.objects.select_related("test")
        # deleting of findings is not allowed via UI or API.
        # Admin interface can be used for this.
        list_allowed_methods = ['get', 'post']
        detail_allowed_methods = ['get', 'post', 'put']
        include_resource_uri = True
        filtering = {
            'id': ALL,
            'title': ALL,
            'date': ALL,
            'severity': ALL,
            'description': ALL,
        }

        authentication = DojoApiKeyAuthentication()
        authorization = DjangoAuthorization()
        serializer = Serializer(formats=['json'])
        validation = CleanedDataFormValidation(form_class=StubFindingForm)
示例#14
0
 class Meta:
     queryset = Project.objects.all()
     resource_name = 'projects'
     fields = [
         'checkstyle',
         'code',
         'description',
         'fullname',
         'ignoredfiles',
         'localfiletype',
         'source_language',
         'translation_projects',
         'treestyle',
     ]
     list_allowed_methods = ['get', 'post']
     detail_allowed_methods = ['get', 'put', 'delete', 'patch']
     # HTTP methods allowed for visiting /statistics/ URLs
     statistics_allowed_methods = ['get']
     authorization = DjangoAuthorization()
     authentication = BasicAuthentication()
示例#15
0
 class Meta:
     queryset = GamePlayer.objects.all()
     allowed_methods = ALL_METHODS
     resource_name = 'gameplayer'
     authorization = DjangoAuthorization()
     authentication = MultiAuthentication(
         ApiKeyAuthentication(),
         SessionAuthentication()
     )
     ordering = {
         'date_created': ALL,
         'date_updated': ALL
     }
     filtering = {
         'id': ALL,
         'player': ALL_WITH_RELATIONS,
         'game': ALL_WITH_RELATIONS,
         'date_created': ALL,
         'date_updated': ALL
     }
示例#16
0
 class Meta:
     resource_name = 'tests'
     list_allowed_methods = ['get', 'post']
     # disabled delete. Should not be allowed without fine authorization.
     detail_allowed_methods = ['get', 'post', 'put']
     queryset = Test.objects.all().order_by('target_end')
     include_resource_uri = True
     filtering = {
         'id': ALL,
         'test_type': ALL,
         'target_start': ALL,
         'target_end': ALL,
         'notes': ALL,
         'percent_complete': ALL,
         'actual_time': ALL
     }
     authentication = DojoApiKeyAuthentication()
     authorization = DjangoAuthorization()
     serializer = Serializer(formats=['json'])
     validation = CleanedDataFormValidation(form_class=TestForm)
示例#17
0
 class Meta:
     queryset = TourPoints.objects.all()
     resource_name = 'tour-points'
     authentication = BasicAuthentication()
     authorization = DjangoAuthorization()
     filtering = {
         'tour_point_id': ALL,
         'title': ALL,
         'address_1': ALL,
         'city': ALL,
         'region': ALL,
         'country_code': ALL,
         'latitude': ALL,
         'longitude': ALL,
         'last_updated': ALL,
         'postcode': ALL,
         'created_by': ALL_WITH_RELATIONS,
         'image_1_url': ALL,
         'image_2_url': ALL,
         'image_3_url': ALL,
         'image_4_url': ALL,
         'image_5_url': ALL,
         'audio_url': ALL,
         'audio_file': ALL,
         'video_url': ALL,
         'video_file': ALL,
         'sunday_open': ALL,
         'sunday_close': ALL,
         'monday_open': ALL,
         'monday_close': ALL,
         'tuesday_open': ALL,
         'tuesday_close': ALL,
         'wednesday_open': ALL,
         'wednesday_close': ALL,
         'thursday_open': ALL,
         'thursday_close': ALL,
         'friday_open': ALL,
         'friday_close': ALL,
         'saturday_open': ALL,
         'saturday_close': ALL,
     }
示例#18
0
    class Meta:
        resource_name = 'tests'
        list_allowed_methods = ['get', 'post']
        # disabled delete. Should not be allowed without fine authorization.
        detail_allowed_methods = ['get', 'post', 'put']
        queryset = Test.objects.all()
        include_resource_uri = True
        filtering = {
            'id': ALL,
            'test_type': ALL,
            'notes': ALL,
            'actual_time': ALL,
            'engagement': ALL,
        }
        authentication = DojoApiKeyAuthentication()
        authorization = DjangoAuthorization()
        serializer = Serializer(formats=['json'])

        @property
        def validation(self):
            return ModelFormValidation(form_class=TestForm, resource=TestResource)
示例#19
0
 class Meta:
     queryset = MakerScienceProfile.objects.all()
     allowed_methods = ['get']
     resource_name = 'makerscience/profilelight'
     authentication = AnonymousApiKeyAuthentication()
     authorization = DjangoAuthorization()
     always_return_data = True
     detail_uri_name = 'slug'
     excludes = ["bio", "facebook", "linkedin", "twitter", "website"]
     filtering = {
         'id': [
             'exact',
         ],
         'parent_id': [
             'exact',
         ],
         'slug': [
             'exact',
         ]
     }
     limit = 6
 class Meta:
     queryset = ManagedFilesystem.objects.all()
     resource_name = "filesystem"
     authorization = DjangoAuthorization()
     authentication = AnonymousAuthentication()
     excludes = ["not_deleted", "ost_next_index", "mdt_next_index"]
     ordering = ["name"]
     filtering = {"id": ["exact", "in"], "name": ["exact"]}
     list_allowed_methods = ["get", "post"]
     detail_allowed_methods = ["get", "delete", "put"]
     readonly = [
         "bytes_free",
         "bytes_total",
         "files_free",
         "files_total",
         "client_count",
         "mount_command",
         "mount_path",
     ]
     validation = FilesystemValidation()
     always_return_data = True
示例#21
0
 class Meta:
     queryset = StationCapacity.objects.all()
     resource_name = 'stationcapacity'
     allowed_methods = ['get']
     ordering = [
         'id',
         'station',
         'day',
         'capacity',
     ]
     cache = SimpleCache()
     limit = 100
     # throttle = BaseThrottle(throttle_at=3600)
     authentication = ApiKeyAuthentication()
     authorization = DjangoAuthorization()
     filtering = {
         'id': ALL,
         'station': ALL,
         'day': ALL,
         'capacity': ALL,
     }
    class Meta:
        #  Join in these three models to dehydrate_kind without big penalties
        queryset = (
            Volume.objects.all()
            .select_related(
                "storage_resource",
                "storage_resource__resource_class",
                "storage_resource__resource_class__storage_plugin",
            )
            .prefetch_related("volumenode_set", "volumenode_set__host")
        )
        resource_name = "volume"
        authorization = DjangoAuthorization()
        authentication = AnonymousAuthentication()
        excludes = ["not_deleted"]
        ordering = ["label", "size"]
        list_allowed_methods = ["get"]
        detail_allowed_methods = ["get", "put"]
        always_return_data = True

        filtering = {"id": ["exact"], "label": ["exact", "endswith"]}
示例#23
0
    class Meta:
        queryset = ManagedHost.objects.select_related(
            'lnet_configuration').prefetch_related('lnet_configuration__nid_set')
        resource_name = 'host'
        excludes = ['not_deleted']
        authentication = AnonymousAuthentication()
        authorization = DjangoAuthorization()
        ordering = ['fqdn']
        list_allowed_methods = ['get', 'post', 'put']
        detail_allowed_methods = ['get', 'put', 'delete']
        readonly = ['nodename', 'fqdn', 'nids', 'member_of_active_filesystem',
                    'needs_update', 'boot_time',
                    'client_mounts']
        # HYD-2256: remove these fields when other auth schemes work
        readonly += ['root_pw', 'private_key_passphrase', 'private_key']
        validation = HostValidation()
        always_return_data = True

        filtering = {'id': ['exact'],
                     'fqdn': ['exact', 'startswith'],
                     'role': ['exact']}
示例#24
0
 class Meta:
     # tastypie doesn't allow null values in FK
     queryset = Trip.objects.filter(start_date__isnull=False,
                                    end_date__isnull=False)
     resource_name = 'trip'
     allowed_methods = ['get']
     ordering = [
         'id',
         'station',
         'start_date',
         'start_station',
         'end_date',
         'end_station',
         'bike_nr',
         'zip_code',
         'birth_date',
         'gender',
     ]
     cache = SimpleCache()
     limit = 100
     # throttle = BaseThrottle(throttle_at=3600)
     authentication = ApiKeyAuthentication()
     authorization = DjangoAuthorization()
     excludes = [
         'subscriber_id',
     ]
     filtering = {
         'id': ALL,
         'status': ALL,
         'duration': ALL,
         'start_date': ALL,
         'start_station': ALL,
         'end_date': ALL,
         'end_station': ALL,
         'bike_nr': ALL,
         'subscription_type': ALL,
         'zip_code': ALL,
         'birth_date': ALL,
         'gender': ALL,
     }
示例#25
0
 class Meta:
     resource_name = 'purchase_orders'
     queryset = PurchaseOrder.objects.all()
     filtering = {
         'id': ALL,
         'creator': ALL_WITH_RELATIONS,
         'deal': ALL,
         'supplier': ALL_WITH_RELATIONS,
         'contact': ALL_WITH_RELATIONS,
         'receiver': ALL_WITH_RELATIONS,
         'note': ALL,
         'created': ALL,
         'terms': ALL,
         'tracking_url': ALL,
         'total_cost': ALL,
         'shipping_cost': ALL,
         'sales_tax': ALL,
     }
     authentication = ApiKeyAuthentication()
     authorization = DjangoAuthorization()
     allowed_methods = ['get', ]
     always_return_data = True
示例#26
0
class StudyGroupResource(ModelResource):
    def obj_create(self, bundle, request=None, **kwargs):
        request = bundle.request
        create_type = bundle.data.pop('type')
        key = request.GET.get('oauth_consumer_key')
        user = MyUser.objects.get(
            username=verify_access_token(key).user.username)

        if (create_type == 'create'):
            new_group = StudyGroup(description=bundle.data.pop('description'))
            new_group.save()
            self.add_user_to_group(user, new_group)

            raise ImmediateHttpResponse(http.HttpAccepted(t.user))

        elif (create_type == 'delete'):
            group = StudyGroup.objects.get(id=bundle.data.pop('id'))
            for m in Membership.objects.filter(group=group):
                m.delete()
            group.delete()
            raise ImmediateHttpResponse(http.HttpAccepted())
        elif create_type == "add_to_group":
            group = StudyGroup.objects.get(id=bundle.data.pop('id'))
            self.add_user_to_group(user, group)
        elif create_type == "quit_group":
            group = StudyGroup.objects.get(id=bundle.data.pop('id'))
            m = Membership.objects.get(person=user, group=group)

    def add_user_to_group(self, user, group):
        m = Membership(person=user, group=group)
        m.save()

    class Meta:
        queryset = StudyGroup.objects.all()
        resource_name = 'study_group'

    authorization = DjangoAuthorization()
    authentication = OAuth20Authentication()
示例#27
0
    class Meta:
        resource_name = 'findings'
        queryset = Finding.objects.select_related("test")
        # deleting of findings is not allowed via API.
        # Admin interface can be used for this.
        list_allowed_methods = ['get', 'post']
        detail_allowed_methods = ['get', 'post', 'put']
        include_resource_uri = True

        filtering = {
            'id': ALL,
            'title': ALL,
            'date': ALL,
            'severity': ALL,
            'description': ALL,
            'mitigated': ALL,
            'endpoint': ALL,
            'test': ALL_WITH_RELATIONS,
            'active': ALL,
            'verified': ALL,
            'false_p': ALL,
            'reporter': ALL,
            'url': ALL,
            'out_of_scope': ALL,
            'duplicate': ALL,
            'risk_acceptance': ALL_WITH_RELATIONS,
            'engagement': ALL_WITH_RELATIONS,
            'product': ALL_WITH_RELATIONS
            #'build_id': ALL
        }
        authentication = DojoApiKeyAuthentication()
        authorization = DjangoAuthorization()
        serializer = Serializer(formats=['json'])

        @property
        def validation(self):
            return ModelFormValidation(form_class=FindingForm,
                                       resource=FindingResource)
示例#28
0
 class Meta:
     queryset = PublicBody.objects.all()
     resource_name = 'publicbody'
     fields = [
         'id', 'name', 'slug', 'other_names', 'description', 'url',
         'parent', 'root', 'depth', 'classification', 'classification_slug',
         'email', 'contact', 'address', 'website_dump', 'request_note',
         'number_of_requests', 'laws', 'jurisdiction'
     ]
     filtering = {
         "other_names": ALL,
         "name": ALL,
         "slug": ALL,
         "number_of_requests": ALL,
         "jurisdiction": ALL_WITH_RELATIONS,
         # Technically possible, but API docs
         # generation currently crashes here
         # "root": ALL_WITH_RELATIONS,
         # "parent": ALL_WITH_RELATIONS
     }
     paginator_class = TastyPaginator
     authentication = AnonymousGetAuthentication()
     authorization = DjangoAuthorization()
示例#29
0
 class Meta:
     queryset = models.MoleculeDictionary.objects.all()
     serializer = CompoundTableSerializer()
     resource_name = 'compound'
     defaultIndex = 'pk'
     include_resource_uri = False
     fields = ['molregno', 'pref_name']
     ordering = ['molregno', 'pref_name', 'properties', 'structure']
     collection_name = 'compounds'
     allowed_methods = ['get']
     authentication = Authentication()
     authorization = DjangoAuthorization()
     throttle = BaseThrottle(throttle_at=100)
     paginator_class = Paginator
     filtering = {
         "properties": ALL_WITH_RELATIONS,
         "structure": ALL_WITH_RELATIONS,
         "molregno": ALL,
         "pref_name": ALL
     }
     ordering = [
         'chembl_id', 'molregno', 'pref_name', 'properties', 'structure'
     ]
示例#30
0
 class Meta:
     queryset = Rating.objects.all()
     resource_name = "rating"
     fields = [
         'id',
         'object_pk',
         'value',
     ]
     list_allowed_methods = [
         'get',
         'post',
     ]
     detail_allowed_methods = [
         'get',
     ]
     throttle = CacheDBThrottle()
     filtering = {
         'object_pk': ('exact', ),
     }
     serializer = CamelCaseJSONSerializer()
     authentication = ApiKeyAuthentication()
     authorization = DjangoAuthorization()
     limit = 0