Пример #1
0
class ReleaseAPIForm(Form):
    ready = ThreeStateField('ready')
    complete = ThreeStateField('complete')
    # If the client sends us a really long status we'd rather truncate
    # it than complain, because it's purely informational.
    # Use the Column length directly rather than duplicating its value.
    status = StringField('status',
                         filters=[truncateFilter(Release.status.type.length)])
    shippedAt = DateTimeField('shippedAt', [validators.optional()])
    description = TextAreaField('description', [validators.optional()])
    isSecurityDriven = BooleanField('isSecurityDriven',
                                    [validators.optional()])
    release_eta = DateTimeField('release_eta', [validators.optional()])

    def validate(self, release, *args, **kwargs):
        valid = Form.validate(self, *args, **kwargs)

        # Completed releases shouldn't be altered in terms of readyness or
        # completeness. Status updates are OK though.
        if release.complete:
            if self.ready.data is False or self.complete.data is False:
                valid = False
                if 'ready' not in self.errors:
                    self.errors['ready'] = []
                self.errors['ready'].append(
                    'Cannot make a completed release not ready or incomplete.')

            if self.description.data:
                # We just want to update the description & isSecurityDriven
                valid = True
            else:
                # Check if there is an other product-version already shipped
                similar = getReleases(shipped=True,
                                      productFilter=release.product,
                                      versionFilter=release.version)
                if similar and self.status.data != "Started":
                    # In most of the cases, it is useless since bug 1121032 has been implemented but keeping it
                    # in case we change/revert in the future and because we cannot always trust the client
                    valid = False
                    if 'shipped' not in self.errors:
                        self.errors['shipped'] = []
                    self.errors['shipped'].append('Version ' +
                                                  release.version +
                                                  ' already marked as shipped')

        # If the release isn't complete, we can accept changes to readyness or
        # completeness, but marking a release as not ready *and* complete at
        # the same time is invalid.
        else:
            if self.ready.data is False and self.complete.data is True:
                valid = False
                if 'ready' not in self.errors:
                    self.errors['ready'] = []
                self.errors['ready'].append(
                    'A release cannot be made ready and complete at the same time'
                )

        return valid
Пример #2
0
class ServiceCouponForm(Form):
    code = TextField("Coupon Code", validators=[Required(), Length(max=10)])
    description = TextField("Description", validators=[Required()])
    discount = TextField("Discount",
                         validators=[Required()
                                     ])  #TODO Custom validator for discount
    per_guest_max_uses = IntegerField("Per Guest Max Uses")
    total_max_uses = IntegerField("Total Max Uses")
    active = BooleanField("Active")
    starts = DateTimeField("Starts On",
                           validators=[Required()],
                           default=datetime.now())
    expires = DateTimeField("Expires On",
                            validators=[Required()],
                            default=datetime.now())
    service_group_id = SelectField("Service Group", validators=[Required()])
Пример #3
0
class ReleaseEventsAPIForm(Form):
    sent = DateTimeField('Sent:', validators=[InputRequired('Sent is required.')])
    event_name = StringField('Event Name:', validators=[InputRequired('Event Name is required.'), Length(0, 150)])
    platform = StringField('Platform:')
    results = IntegerField('Results:', default=0, validators=[InputRequired('Results is required.')])
    chunkNum = IntegerField('Chunk Number:', default=1)
    chunkTotal = IntegerField('Chunk Total:', default=1)
    group = StringField('Group:', default='other')
Пример #4
0
class EditJam(Form):
    title = TextField("Jam title", validators=[Required(), Length(max=128)])
    theme = TextField("Theme", validators=[Required(), Length(max=128)])
    start_time = DateTimeField("Start time",
                               format="%Y-%m-%d %H:%M",
                               validators=[Required()])
    email = BooleanField("Send everyone an email about this change",
                         default=True)
Пример #5
0
class NewJam(Form):
    title = TextField("Jam title", validators=[Required(), Length(max=128)])
    theme = TextField("Theme", validators=[Required(), Length(max=128)])
    start_time = DateTimeField("Start time",
                               format="%Y-%m-%d %H:%M",
                               validators=[Required()])
    duration = IntegerField("Duration, in hours",
                            validators=[NumberRange(min=1),
                                        Required()],
                            default=48)
    team_jam = BooleanField("Team Jam", default=False)
Пример #6
0
class EntryForm(Form):

    title = TextField("Title", validators=[required(message="Title required")])

    slug = TextField("Slug")
    tags = TextField("Tags")
    pub_date = DateTimeField("Published On:",
                             id="date-input",
                             format='%Y-%m-%d')
    publish = BooleanField('Publish?')
    delete = BooleanField("Delete?")
    body = TextAreaField("Body",
                         id='text-editor',
                         validators=[required(message="Body required")])
    abstract = TextAreaField("Abstract")
Пример #7
0
class ExampleForm(Form):
    title = TextField(u'Título', validators=[Required()])
    content = TextAreaField(u'Conteúdo')
    date = DateTimeField(u'Data', format='%d/%m/%Y %H:%M')
Пример #8
0
class BlogPostForm(Form):
    title = TextField(u'Title', validators=[Required()])
    body = TextAreaField(u'Content')
    date = DateTimeField(u'Date', format='%Y-%m-%d')
    author = TextField(u'Author', validators=[Required()])