Beispiel #1
0
    class Meta:
        model = List
        queryset = List.objects.order_by("kind", "-modified_time")
        fields = ['name', 'public', 'position', 'id', 'kind', 'count']

        allowed_methods = ['get', 'put', 'post', 'delete']
        always_return_data = True
        authentication = SessionAuthentication()
        authorization = ListAuthorization()
        validation = FormValidation(form_class=ListForm)
	class Meta:
		queryset = User.objects.all()
		resource_name = 'user'
		list_allowed_methods = ['get']
		fields = ['username', 'first_name', 'last_name', 'id']
		authentication = SessionAuthentication()
		authorization = Authorization()
		filtering = {
			'username': ALL,
		}
Beispiel #3
0
 class Meta(GenericMeta):
     queryset = User.objects.all()
     resource_name = 'user'
     authorization = UserAuthorization()
     authentication = MultiAuthentication(SessionAuthentication(),
                                          Authentication())
     fields = [
         'first_name', 'email', 'last_name', 'date_joined', 'image_profile',
         'id', 'number_projects', 'profile', 'projects', 'username'
     ]
Beispiel #4
0
 class Meta:
     max_limit = None
     queryset = Screening.objects.prefetch_related('village', 'animator', 'videoes_screened', 'farmer_groups_targeted',
                                                   'personmeetingattendance_set__person', 'personmeetingattendance_set__expressed_adoption_video', 'partner').filter(date__gte=datetime(2013,1,1))
     resource_name = 'screening'
     authentication = SessionAuthentication()
     authorization = VillagePartnerAuthorization('village__in')
     validation = ModelFormValidation(form_class = ScreeningForm)
     always_return_data = True
     excludes = ['location', 'time_created', 'time_modified','observation_status','screening_grade', 'observer']
	class Meta:
		queryset = CohortMembers.objects.all()
		resource_name = 'cohortmember'
		list_allowed_methods = ['get', 'post', 'delete']
		authentication = SessionAuthentication()
		authorization = CohortInstructorOrMemberAuthorization()
		filtering = {
			'cohort': ALL_WITH_RELATIONS,
			'member': ALL_WITH_RELATIONS,
		}
	class Meta:
		queryset = CommentaryEntryVoter.objects.all()
		resource_name = "voter"
		list_allowed_methods = ['get', 'post', 'delete']
		authentication = SessionAuthentication()
		authorization = UserObjectsUpdateOnlyReadAllAuthorization()
		filtering = {
			'entry': ALL_WITH_RELATIONS,
			'voter': ALL_WITH_RELATIONS,
		}
Beispiel #7
0
    class Meta:
        def filter_custom_query(url_args):
            """Build Custom filter that searches all relevant fields"""
            number_val = None
            string_val = None
            try:
                string_val = url_args.pop('custom_query')[0]

                if helpers.is_int_str(string_val):
                    number_val = int(string_val)
            except KeyError:
                return None

            custom_query = (
                Q(family_name__icontains=string_val) |
                Q(given_name__icontains=string_val) |
                Q(mothers_given_name__icontains=string_val) |
                Q(fathers_given_name__icontains=string_val) |
                Q(description__icontains=string_val) |
                Q(notes__icontains=string_val) |
                Q(shelter_id__exact=string_val) |
                Q(barcode__exact=string_val)
            )

            if number_val:
                custom_query = (
                    (
                        Q(age__gte=number_val-10) &
                        Q(age__lte=number_val+10)
                    ) |
                    Q(description__icontains=number_val) |
                    Q(notes__icontains=string_val) |
                    Q(shelter_id__exact=string_val) |
                    Q(barcode__exact=string_val) |
                    Q(id__exact=number_val)
                )
            return custom_query

        queryset = Person.objects.all()
        excludes = ['start_date', 'stop_date']
        authentication = MultiAuthentication(SessionAuthentication(), BasicAuthentication())
        authorization = Authorization()
        filtering = {
            'family_name': ALL,
            'given_name': ALL,
            'mothers_given_name': ALL,
            'fathers_given_name': ALL,
            'description': ALL,
            'notes': ALL,
            'barcode': ALL,
            'age': ALL,
            'shelter_id': ALL_WITH_RELATIONS,
            'slug': ALL,
        }
        custom_filters = {'custom_query': filter_custom_query}
Beispiel #8
0
 class Meta:
     queryset = Cred.objects.filter(is_deleted=False, latest=None)
     always_return_data = True
     resource_name = 'cred'
     excludes = ['username', 'is_deleted']
     authentication = MultiAuthentication(SessionAuthentication(), MultiApiKeyAuthentication())
     authorization = CredAuthorization()
     filtering = {
         'title': ('exact', 'contains', 'icontains'),
         'url': ('exact', 'startswith', ),
     }
Beispiel #9
0
 class Meta:
     queryset = TemporaryFile.objects.all()
     list_allowed_methods = ['get']
     detail_allowed_methods = ['get', 'delete']
     resource_name = 'temporary-files'
     authentication = MultiAuthentication(SessionAuthentication(),
                                          ApiKeyAuthentication())
     authorization = DjangoAuthorization()
     fields = ['uuid', 'date', 'filename']
     detail_uri_name = 'uuid'
     serializer = Serializer(formats=['json', 'jsonp'])
Beispiel #10
0
 class Meta:
     object_class = FeatureServiceLayerRelations
     resource_name = 'featureservicelayerrelations'
     list_allowed_methods = ['get']
     detail_allowed_methods = ['get']
     serializer = Serializer(formats=['json', 'jsonp'])
     queryset = FeatureServiceLayerRelations.objects.select_related(
         'layer').all()
     authentication = MultiAuthentication(SessionAuthentication(),
                                          ApiKeyAuthentication())
     authorization = DjangoAuthorization()
Beispiel #11
0
 class Meta:
     queryset = WikiPage.objects.all()
     include_absolute_url = True
     resource_name = 'peach/wiki-page'
     allowed_methods = ['get', 'post', 'put', 'delete']
     filtering = {
         'namespace': ALL_WITH_RELATIONS,
     }
     validation = FormValidation(form_class=WikiPageForm)
     authentication = SessionAuthentication()
     authorization = WikiPageAuthorization()
Beispiel #12
0
 class Meta:
     resource_name = 'fileservice'
     object_class = FileItem
     fields = ['name']
     include_resource_uri = False
     allowed_methods = ['get', 'post', 'put']
     always_return_data = True
     authentication = MultiAuthentication(SessionAuthentication(),
                                          ApiKeyAuthentication(),
                                          BasicAuthentication())
     authorization = Authorization()
Beispiel #13
0
 class Meta(GenericMeta):
     queryset = File.objects.all()
     resource_name = 'file'
     filtering = {'project_part': ALL}
     authorization = ProjectPartElemAuthorization()
     authentication = MultiAuthentication(OAuth20Authentication(),
                                          SessionAuthentication(),
                                          Authentication())
     serializer = DatetimeSerializer()
     ordering = ['-original_name']
     allowed_methods = ['GET', 'DELETE']
Beispiel #14
0
 class Meta:
     resource_name = "maplayers"
     queryset = MapLayer.objects.all().distinct()
     filtering = {
         'id': ALL,
         'name': ALL,
         'map': ALL_WITH_RELATIONS
     }
     authorization = GeoNodeAuthorization()
     authentication = MultiAuthentication(
         SessionAuthentication(), GeonodeApiKeyAuthentication())
Beispiel #15
0
 class Meta:
     queryset = UserEx.objects.all()
     resource_name = 'user'
     fields = ['email', 'facebook_name', 'picture', 'extras', 'read_from']
     allowed_methods = ['get']
     include_resource_uri = False
     authentication = MultiAuthentication(OAuth20Authentication(),
                                          SessionAuthentication(),
                                          FacebookAuthentication())
     authorization = DjangoAuthorization()
     cache = NoCache()
Beispiel #16
0
 class Meta:
     queryset = User.objects.all()
     resource_name = 'users'
     fields = [
         'first_name', 'last_name', 'email', 'username', 'cars', 'coupons',
         'upcoming_events', 'id'
     ]
     resource_name = 'profile'
     include_resource_uri = False
     authentication = SessionAuthentication()
     authorization = UserAdminAuthorization()
Beispiel #17
0
 class Meta(GenericMeta):
     queryset = Post.objects.all()
     resource_name = 'post'
     filtering = {'project_part': ALL}
     authorization = ProjectPartElemAuthorization()
     authentication = MultiAuthentication(OAuth20Authentication(),
                                          SessionAuthentication(),
                                          Authentication())
     #ordering = ['created']
     serializer = DatetimeSerializer()
     validation = PostValidation()
Beispiel #18
0
 class Meta:
     Channel = apps.get_model('tv', 'Channel')
     queryset = Channel.objects.filter(enabled=True, source__isnull=False)
     # excludes = ['enabled', 'description', 'enabled', 'name']
     fields = ['id', 'channelid', 'number', 'buffer_size']
     allowed_methods = ['get']
     resource_name = 'userchannel'
     authorization = MyChannelResourceAuthorization()
     authentication = MultiAuthentication(
         BasicAuthentication(realm='cianet-middleware'),
         SessionAuthentication(), Authentication(), ApiKeyAuthentication())
Beispiel #19
0
    class Meta:
        queryset = Note.all_objects.all()  # Includes soft-deleted notes
        resource_name = 'note'

        list_allowed_methods = ['get', 'post', 'put', 'delete', 'patch']
        authentication = SessionAuthentication()
        authorization = UserNotesAuthorization()
        always_return_data = True
        filtering = {
            'deleted': 'exact'
        }
Beispiel #20
0
 class Meta:
     always_return_data = True
     queryset = ResourceFile.objects.all()
     resource_name = 'resource_file'
     filtering = {
         'id': 'exact',
     }
     authentication = MultiAuthentication(BasicAuthentication(),
                                          ApiKeyAuthentication(),
                                          SessionAuthentication())
     authorization = Authorization()