Ejemplo n.º 1
0
 class Schema:
     owner_group = fields.Inline('group')
     owner_farmer = fields.Inline('farmer')
     certificate_start_date = fields.DateString()
     certificate_expiry_date = fields.DateString()
     certificate_expiry_date._schema = c.DATETIME_SCHEMA
     certificate_start_date._schema = c.DATETIME_SCHEMA
     owner_group_id = fields.String()
     owner_farmer_id = fields.String()
     _deleted_at = fields.DateString()
     _deleted_at._schema = c.DATETIME_SCHEMA
Ejemplo n.º 2
0
 class Schema:
     id = fields.Integer(io='r')
     due_date = fields.DateString()
     category = ToOneIntegerField(CategoryResource)
     user = ToOneIntegerField(UserResource)
     bids = ToManyIntegerField('bids')
     distance_in_meters = DistanceField(io='r', attribute='location')
Ejemplo n.º 3
0
 def test_inherited_filters(self):
     self.assertEqual(
         {
             'string': {
                 'eq': filters.EqualFilter
             },
             'email': {
                 None: filters.EqualFilter,
                 'eq': filters.EqualFilter,
                 'ne': filters.NotEqualFilter,
                 'in': filters.InFilter,
                 'contains': filters.StringContainsFilter,
                 'icontains': filters.StringIContainsFilter,
                 'endswith': filters.EndsWithFilter,
                 'iendswith': filters.IEndsWithFilter,
                 'startswith': filters.StartsWithFilter,
                 'istartswith': filters.IStartsWithFilter,
             },
             'uri': {
                 'eq': filters.EqualFilter,
                 'ne': filters.NotEqualFilter,
                 'endswith': filters.EndsWithFilter,
             },
             'date_string': {
                 None: filters.EqualFilter,
                 'eq': filters.EqualFilter,
                 'ne': filters.NotEqualFilter,
                 'in': filters.InFilter,
                 'lt': filters.LessThanFilter,
                 'lte': filters.LessThanEqualFilter,
                 'gt': filters.GreaterThanFilter,
                 'gte': filters.GreaterThanEqualFilter,
                 'between': filters.DateBetweenFilter,
             },
         },
         filters_for_fields(
             {
                 'string': fields.String(),
                 # inherit from String
                 'email': fields.Email(),
                 'uri': fields.Uri(),
                 # no filter defined for Raw
                 'raw': fields.Raw({}),
                 # inherits from String, but there is a filter for DateString
                 'date_string': fields.DateString(),
             },
             filter_names=FILTER_NAMES,
             filters_by_type=FILTERS_BY_TYPE,
             filters_expression={
                 'string': ['eq'],
                 'email': True,
                 'uri': ['eq', 'ne', 'endswith'],
                 '*': True,
             },
         ),
     )
Ejemplo n.º 4
0
 class Schema:
     province = fields.Inline('province')
     ward = fields.Inline('ward')
     district = fields.Inline('district')
     associate_group = fields.Inline('associate_group')
     province_id = fields.String()
     associate_group_id = fields.String()
     district_id = fields.String()
     ward_id = fields.String()
     _deleted_at = fields.DateString()
     _deleted_at._schema = c.DATETIME_SCHEMA
Ejemplo n.º 5
0
 def view_count(self, video, date: fields.DateString(nullable=True)) -> fields.Integer():
     return video.views.filter(models.View.created_at >= date).count() if date else video.count
Ejemplo n.º 6
0
 class Schema:
     published = fields.DateString()
     count = fields.Integer()
Ejemplo n.º 7
0
 class Schema:
     province = fields.Inline('province')
     id = fields.String()
     province_id = fields.String()
     _deleted_at = fields.DateString()
     _deleted_at._schema = c.DATETIME_SCHEMA
Ejemplo n.º 8
0
 class Schema:
     group = fields.Inline('group')
     group_id = fields.String()
     _deleted_at = fields.DateString()
     _deleted_at._schema = c.DATETIME_SCHEMA