Beispiel #1
0
class OrganizationForm(ModelForm):
    model_class = Organization

    name = fields.StringField(_('Name'), [validators.required()])
    acronym = fields.StringField(_('Acronym'),
                                 description=_('Shorter organization name'))
    description = fields.MarkdownField(
        _('Description'), [validators.required()],
        description=_('The details about your organization'))
    url = fields.URLField(_('Website'),
                          description=_('The organization website URL'))
    logo = fields.ImageField(_('Logo'), sizes=LOGO_SIZES)

    deleted = fields.DateTimeField()
    extras = fields.ExtrasField()

    def save(self, commit=True, **kwargs):
        '''Register the current user as admin on creation'''
        org = super(OrganizationForm, self).save(commit=False, **kwargs)

        if not org.id:
            user = current_user._get_current_object()
            member = Member(user=user, role='admin')
            org.members.append(member)

        if commit:
            org.save()

        return org
Beispiel #2
0
class DatasetForm(ModelForm):
    model_class = Dataset

    title = fields.StringField(_('Title'), [validators.required()])
    description = fields.MarkdownField(
        _('Description'), [validators.required()],
        description=_('The details about the dataset '
                      '(collection process, specifics...).'))
    license = fields.ModelSelectField(_('License'),
                                      model=License,
                                      allow_blank=True)
    frequency = fields.SelectField(
        _('Update frequency'),
        choices=UPDATE_FREQUENCIES.items(),
        default=DEFAULT_FREQUENCY,
        validators=[validators.optional()],
        description=_('The frequency at which data are updated.'))
    frequency_date = fields.DateTimeField(_('Expected frequency date'))
    temporal_coverage = fields.DateRangeField(
        _('Temporal coverage'),
        description=_('The period covered by the data'))
    spatial = SpatialCoverageField(
        _('Spatial coverage'),
        description=_('The geographical area covered by the data.'))
    tags = fields.TagField(_('Tags'), description=_('Some taxonomy keywords'))
    private = fields.BooleanField(
        _('Private'),
        description=_('Restrict the dataset visibility to you or '
                      'your organization only.'))

    owner = fields.CurrentUserField()
    organization = fields.PublishAsField(_('Publish as'))
    extras = fields.ExtrasField(extras=Dataset.extras)
    resources = fields.NestedModelList(ResourceForm)
Beispiel #3
0
class BaseResourceForm(ModelForm):
    title = fields.StringField(_('Title'), [validators.required()])
    description = fields.MarkdownField(_('Description'))
    filetype = fields.RadioField(
        _('File type'), [validators.required(), enforce_filetype_file],
        choices=RESOURCE_FILETYPES.items(), default='file',
        description=_('Whether the resource is an uploaded file, '
                      'a remote file or an API'))
    type = fields.RadioField(
        _('Type'), [validators.required()],
        choices=RESOURCE_TYPES.items(), default='other',
        description=_('Resource type (documentation, API...)'))
    url = fields.UploadableURLField(
        _('URL'), [validators.required()], storage=resources)
    format = fields.StringField(
        _('Format'),
        filters=[normalize_format],
    )
    checksum = fields.FormField(ChecksumForm)
    mime = fields.StringField(
        _('Mime type'),
        description=_('The mime type associated to the extension. '
                      '(ex: text/plain)'))
    filesize = fields.IntegerField(
        _('Size'), [validators.optional()],
        description=_('The file size in bytes'))
    published = fields.DateTimeField(
        _('Publication date'),
        description=_('The publication date of the resource'))
    extras = fields.ExtrasField()
Beispiel #4
0
class ResourceForm(ModelForm):
    model_class = Resource

    title = fields.StringField(_('Title'), [validators.required()])
    description = fields.MarkdownField(_('Description'))
    type = fields.RadioField(
        _('Type'), [validators.required()],
        choices=RESOURCE_TYPES.items(), default='file',
        description=_('Whether the resource is an uploaded file, '
                      'a remote file or an API'))
    url = fields.UploadableURLField(
        _('URL'), [validators.required()], storage=resources)
    format = fields.StringField(
        _('Format'), widget=widgets.FormatAutocompleter())
    checksum = ChecksumField(_('Checksum'))
    mime = fields.StringField(
        _('Mime type'),
        description=_('The mime type associated to the extension. '
                      '(ex: text/plain)'))
    size = fields.IntegerField(
        _('Size'), [validators.optional()],
        description=_('The file size in bytes'))
    published = fields.DateTimeField(
        _('Publication date'),
        description=_('The publication date of the resource'))
Beispiel #5
0
class DiscussionCreateForm(ModelForm):
    model_class = Discussion

    title = fields.StringField(_('Title'), [validators.required()])
    comment = fields.StringField(_('Comment'), [validators.required()])
    subject = fields.ModelField(_('Subject'), [validators.required()])
    extras = fields.ExtrasField()
Beispiel #6
0
class UserProfileForm(ModelForm):
    model_class = User

    first_name = fields.StringField(_('First name'), [validators.required()])
    last_name = fields.StringField(_('Last name'), [validators.required()])
    avatar = fields.ImageField(_('Avatar'), sizes=AVATAR_SIZES)
    website = fields.URLField(_('Website'))
    about = fields.MarkdownField(_('About'))
Beispiel #7
0
class HarvestSourceForm(Form):
    name = fields.StringField(_('Name'), [validators.required()])
    description = fields.MarkdownField(
        _('Description'),
        description=_('Some optionnal details about this harvester'))
    url = fields.URLField(_('URL'), [validators.required()])
    backend = fields.SelectField(_('Backend'), choices=backends)
    owner = fields.CurrentUserField()
    organization = fields.PublishAsField(_('Publish as'))
Beispiel #8
0
class TopicForm(UserModelForm):
    model_class = Topic

    name = fields.StringField(_('Name'), [validators.required()])
    description = fields.MarkdownField(_('Description'),
                                       [validators.required()])

    datasets = fields.DatasetListField(_('Associated datasets'))
    reuses = fields.ReuseListField(_('Associated reuses'))

    tags = fields.TagField(_('Tags'), [validators.required()])
    private = fields.BooleanField(_('Private'))
Beispiel #9
0
class HarvestSourceForm(Form):
    name = fields.StringField(_('Name'), [validators.required()])
    description = fields.MarkdownField(
        _('Description'),
        description=_('Some optionnal details about this harvester'))
    url = fields.URLField(_('URL'), [validators.required()])
    backend = fields.SelectField(_('Backend'),
                                 choices=lambda: [(b.name, b.display_name)
                                                  for b in list_backends()])
    owner = fields.CurrentUserField()
    organization = fields.PublishAsField(_('Publish as'))

    config = HarvestConfigField()
Beispiel #10
0
class SiteConfigForm(ModelForm):
    model_class = Site

    title = fields.StringField(_('Title'), [validators.required()])
    keywords = fields.TagField(_('Tags'), description=_('Some SEO keywords'))
    feed_size = fields.IntegerField(
        _('Feed size'), description=_('Number of elements in feeds'))
Beispiel #11
0
class BadgeForm(ModelForm):
    model_class = DatasetBadge

    kind = fields.RadioField(
        _('Kind'), [validators.required()],
        choices=DATASET_BADGE_KINDS.items(),
        description=_('Kind of badge (pivotal-data, etc)'))
Beispiel #12
0
    class BadgeForm(ModelForm):
        model_class = Badge

        kind = fields.RadioField(
            _('Kind'), [validators.required()],
            choices=model.__badges__.items(),
            description=_('Kind of badge (certified, etc)'))
Beispiel #13
0
class BadgeForm(ModelForm):
    model_class = OrganizationBadge

    kind = fields.RadioField(
        _('Kind'), [validators.required()],
        choices=ORG_BADGE_KINDS.items(),
        description=_('Kind of badge (public-service, etc)'))
Beispiel #14
0
class PeriodicTaskForm(ModelForm):
    model_class = PeriodicTask

    name = fields.StringField(_('Name'), [validators.required()])
    description = fields.StringField(_('Description'))
    task = fields.StringField(_('Tasks'))
    enabled = fields.BooleanField(_('Enabled'))
Beispiel #15
0
class MemberForm(ModelForm):
    model_class = Member

    role = fields.SelectField(_('Role'),
                              default='editor',
                              choices=ORG_ROLES.items(),
                              validators=[validators.required()])
Beispiel #16
0
class BadgeForm(ModelForm):
    model_class = ReuseBadge

    kind = fields.RadioField(
        _('Kind'), [validators.required()],
        choices=REUSE_BADGE_KINDS.items(),
        description=_('Kind of badge (dataconnexions, etc)'))
Beispiel #17
0
class PostForm(ModelForm):
    model_class = Post

    owner = fields.CurrentUserField()

    name = fields.StringField(_('Name'), [validators.required()])
    headline = fields.StringField(_('Headline'), widget=widgets.TextArea())
    content = fields.MarkdownField(_('Content'), [validators.required()])

    datasets = fields.DatasetListField(_('Associated datasets'))
    reuses = fields.ReuseListField(_('Associated reuses'))

    image = fields.ImageField(_('Image'), sizes=IMAGE_SIZES)
    credit_to = fields.StringField(_('Image credits'))
    credit_url = fields.URLField(_('Credit URL'))

    tags = fields.TagField(_('Tags'))
Beispiel #18
0
class PostForm(UserModelForm):
    model_class = Post

    name = fields.StringField(_('Name'), [validators.required()])
    headline = fields.StringField(_('Headline'), widget=widgets.TextArea())
    content = fields.MarkdownField(_('Content'), [validators.required()])

    datasets = fields.DatasetListField(_('Associated datasets'))
    reuses = fields.ReuseListField(_('Associated reuses'))

    image = fields.ImageField(_('Image'), sizes=IMAGE_SIZES)
    # image_url = fields.UploadableURLField(_('Image URL'), description=_('The post thumbnail'),
    #     endpoint='storage.add_image')
    credit_to = fields.StringField(_('Image credits'))
    credit_url = fields.URLField(_('Credit URL'))

    tags = fields.TagField(_('Tags'))

    private = fields.BooleanField(_('Private'))
Beispiel #19
0
class ReuseForm(ModelForm):
    model_class = Reuse

    title = fields.StringField(_('Title'), [validators.required()])
    description = fields.MarkdownField(
        _('Description'), [validators.required()],
        description=_('The details about the reuse (build process, specifics, '
                      'self-critics...).'))
    type = fields.SelectField(_('Type'), choices=REUSE_TYPES.items())
    url = fields.URLField(_('URL'),
                          [validators.required(), check_url_does_not_exists])
    image = fields.ImageField(_('Image'),
                              sizes=IMAGE_SIZES,
                              placeholder='reuse')
    tags = fields.TagField(_('Tags'), description=_('Some taxonomy keywords'))
    datasets = fields.DatasetListField(_('Used datasets'))
    private = fields.BooleanField(
        _('Private'),
        description=_('Restrict the dataset visibility to you or '
                      'your organization only.'))

    owner = fields.CurrentUserField()
    organization = fields.PublishAsField(_('Publish as'))
Beispiel #20
0
class PeriodicTaskForm(ModelForm):
    model_class = PeriodicTask

    name = fields.StringField(_('Name'), [validators.required()])
    description = fields.StringField(_('Description'))
    task = fields.StringField(_('Tasks'))
    enabled = fields.BooleanField(_('Enabled'))

    def save(self, commit=True, **kwargs):
        '''
        PeriodicTask is dynamic and save behavior changed
        See: https://github.com/zakird/celerybeat-mongo/commit/dfbbd20edde91134b57f5406d0ce4eac59d6899b
        '''
        if not self.instance:
            self.instance = self.model_class()  # Force populate_obj in super()
        return super(PeriodicTaskForm, self).save(commit, **kwargs)
Beispiel #21
0
class IssueCreateForm(ModelForm):
    model_class = Issue

    title = fields.StringField(_('Title'), [validators.required()])
    comment = fields.StringField(_('Comment'), [validators.required()])
    subject = fields.ModelField(_('Subject'), [validators.required()])
Beispiel #22
0
class MembershipRefuseForm(Form):
    comment = fields.StringField(_('Comment'), [validators.required()])
Beispiel #23
0
class MembershipRequestForm(ModelForm):
    model_class = MembershipRequest

    user = fields.CurrentUserField()
    comment = fields.StringField(_('Comment'), [validators.required()])
Beispiel #24
0
class OrganizationMemberForm(ModelForm):
    model_class = Organization

    pk = fields.StringField(validators=[validators.required()])
    value = fields.StringField(default='editor')
Beispiel #25
0
class FakeForm(Form):
    required = fields.StringField(validators=[validators.required()])
    choices = fields.SelectField(choices=(('first', ''), ('second', '')))
    email = fields.StringField(validators=[validators.Email()])
Beispiel #26
0
class DiscussionCommentForm(Form):
    comment = fields.StringField(_('Comment'), [validators.required()])
    close = fields.BooleanField(default=False)
Beispiel #27
0
class MembershipRequestForm(UserModelForm):
    model_class = MembershipRequest
    user_field = 'user'

    comment = fields.StringField(_('Comment'), [validators.required()])
Beispiel #28
0
class IssueCreateForm(Form):
    title = fields.StringField(_('Title'), [validators.required()])
    comment = fields.StringField(_('Comment'), [validators.required()])
    subject = fields.DatasetOrReuseField(_('Subject'), [validators.required()])
Beispiel #29
0
class UserAPIKeyForm(ModelForm):
    model_class = User

    action = fields.SelectField(choices=(('generate', ''), ('clear', '')),
                                validators=[validators.required()])
Beispiel #30
0
class DatasetExtraForm(Form):
    key = fields.StringField(_('Key'), [validators.required()])
    value = fields.StringField(_('Value'), [validators.required()])
    old_key = fields.StringField(_('Old key'))