Beispiel #1
0
class ShowcaseApiAttrs(ObjectAttrs, HighlightObjectMixin):
    category = fields.Str()
    category_name = fields.Method('get_category_name')
    slug = TranslatedStr()
    title = TranslatedStr()
    notes = TranslatedStr()
    author = fields.Str(faker_type='firstname')
    url = fields.Str(faker_type='url')
    image_url = fields.Str(faker_type='image_url')
    image_thumb_url = fields.Str(faker_type='image_thumb_url')
    image_alt = TranslatedStr()
    illustrative_graphics_url = fields.Str()
    illustrative_graphics_alt = TranslatedStr()
    followed = fields.Boolean(faker_type='boolean')
    keywords = KeywordsList(TranslatedStr(), faker_type='tagslist')
    views_count = fields.Integer(faker_type='integer')
    modified = fields.Str(faker_type='datetime')
    created = fields.Str(faker_type='datetime')
    has_image_thumb = fields.Bool()
    main_page_position = fields.Int()
    external_datasets = fields.Nested(ExternalDataset, many=True)
    # application showcase fields:
    is_mobile_app = fields.Bool()
    is_mobile_app_name = fields.Method('get_is_mobile_app_name')
    is_desktop_app = fields.Bool()
    is_desktop_app_name = fields.Method('get_is_desktop_app_name')
    mobile_apple_url = fields.URL()
    mobile_google_url = fields.URL()
    desktop_linux_url = fields.URL()
    desktop_macos_url = fields.URL()
    desktop_windows_url = fields.URL()

    license_type = fields.Str()
    license_type_name = fields.Method('get_license_type_name')
    # api use showcase fields:
    file_url = fields.Str()

    class Meta:
        relationships_schema = ShowcaseApiRelationships
        object_type = 'showcase'
        url_template = '{api_url}/showcases/{ident}'
        model = 'showcases.Showcase'
        ordered = True

    def get_is_desktop_app_name(self, obj):
        return str(_('Desktop App')) if obj.is_desktop_app else ''

    def get_is_mobile_app_name(self, obj):
        return str(_('Mobile App')) if obj.is_mobile_app else ''

    def get_category_name(self, obj):
        return str(Showcase.CATEGORY_NAMES.get(obj.showcase_category, ''))

    def get_license_type_name(self, obj):
        return str(Showcase.LICENSE_TYPE_NAMES.get(obj.license_type, ''))
Beispiel #2
0
class SubmissionAttrs(ObjectAttrs):
    title = fields.Str()
    url = fields.URL()
    applicant_email = fields.Email()

    class Meta:
        object_type = 'application-submission'
        path = 'submissions'
        url_template = '{api_url}/applications/submissions/{ident}'
Beispiel #3
0
class ShowcaseProposalAttrs(ObjectAttrs):
    title = fields.Str()
    url = fields.URL()
    applicant_email = fields.Email()

    class Meta:
        object_type = 'showcaseproposal'
        path = 'showcases'
        url_template = '{api_url}/showcases/suggest'
class ExportUrlApiAttrs(ObjectAttrs):
    url = fields.URL()

    class Meta:
        object_type = 'export'
        ordered = True

    @staticmethod
    def self_api_url(data):
        return None
class CourseApiAttrs(ObjectAttrs, HighlightObjectMixin):
    title = fields.Str()
    notes = fields.Str()
    participants_number = fields.Int()
    venue = fields.Str()
    start = fields.Date()
    end = fields.Date()
    file_type = fields.Str()
    file_url = fields.URL()
    materials_file_type = fields.Str()
    materials_file_url = fields.URL()
    sessions = fields.Nested(CourseModuleSchema, many=True)
    state = fields.Str()
    state_name = fields.Str()

    class Meta:
        # relationships_schema = ApplicationApiRelationships
        object_type = 'course'
        url_template = '{api_url}/courses/{ident}'
        model = 'academy.Course'

    @pre_dump
    def prepare_data(self, data, **kwargs):
        if data.start and data.end:
            today = timezone.now().date()
            start_date = data.start.date()
            end_date = data.end.date()
            _state = None
            if start_date <= today <= end_date:
                _state = 'current'
            elif end_date < today:
                _state = 'finished'
            elif today < start_date:
                _state = 'planned'
            if _state:
                setattr(data, 'state', _state)
                setattr(data, 'state_name', Course.COURSE_STATES.get(_state))
        return data
Beispiel #6
0
class CreateDatasetSubmissionAttrs(ObjectAttrs):
    title = core_fields.String(description='Name',
                               example='Lorem Ipsum',
                               required=True)
    notes = core_fields.String(description='Description',
                               example='Lorem Ipsum',
                               required=True)
    organization_name = core_fields.String(description='Organization',
                                           example='ACME',
                                           required=False)
    data_link = core_fields.URL(description='Link to data',
                                example='https://dane.gov.pl',
                                required=False)
    potential_possibilities = core_fields.String(
        description='potential possibilities', example='none', required=False)

    class Meta:
        strict = True
        ordered = True
        object_type = 'submission'
class DataSourceAttr(ExtSchema):
    title = fields.Str()
    url = fields.URL()
    source_type = fields.Str()
Beispiel #8
0
class SourceXMLSchema(ExtSchema):
    title = fields.Str()
    url = fields.URL()
    update_frequency = TranslatedStr()
    last_import_timestamp = fields.DateTime()
Beispiel #9
0
class SourceSchema(ExtSchema):
    title = fields.Str()
    type = fields.Str(attribute='source_type')
    url = fields.URL()
    update_frequency = TranslatedStr()
    last_import_timestamp = fields.DateTime()
class RDFRegionSchema(DefaultRegionMixin, ExtSchema):
    geonames_url = fields.URL()
    centroid = fields.Str(attribute='wkt_centroid')