Esempio n. 1
0
class PaymentIntegrationForm(Form):
    """Payments integration"""

    gocardless = FormField(GoCardlessPaymentIntegrationForm)
    stripe = FormField(StripePaymentIntegrationForm)

    def __init__(self, formdata, obj=None, prefix='', **kwargs):
        super(PaymentIntegrationForm, self).__init__(formdata, obj, prefix,
                                                     **kwargs)

        if obj:
            self.models = obj
        else:
            self.models = None

    def save(self):

        # gocardless
        self.models.gocardless.merchant_id = self.gocardless.merchant_id.data
        self.models.gocardless.merchant_access_token = self.gocardless.merchant_access_token.data
        self.models.gocardless.app_secret = self.gocardless.app_secret.data
        self.models.gocardless.app_identifier = self.gocardless.app_identifier.data
        self.models.gocardless.enabled = self.gocardless.enabled.data

        # stripe payments
        self.models.stripe.public_key = self.stripe.public_key.data
        self.models.stripe.secret_key = self.stripe.secret_key.data
        self.models.stripe.enabled = self.stripe.enabled.data

        db.session.commit()
Esempio n. 2
0
class ToolForm(ToolFormBase):

    requirements = FieldList(FormField(ToolRequirementForm))
    command_line_interface = FormField(CommandLineInterfaceForm)

    field_set = {
        'general':
        ('name', 'description', 'owner', 'email', 'version', 'help'),
        'runtime': ('os', 'grid_access_type', 'grid_access_location')
    }
Esempio n. 3
0
class CompletedMatchRoundForm(Form):
    map_id = SelectField(u'Map',
                         coerce=int,
                         validators=[Required()],
                         choices=[])
    side_id = SelectField(u'Side',
                          coerce=int,
                          validators=[Required()],
                          choices=[])
    gametype_id = SelectField(u'Gametype',
                              coerce=int,
                              validators=[Required()],
                              choices=[])

    wins = IntegerField(u'Wins', validators=[NumberRange(min=0)], default=0)
    losses = IntegerField(u'Losses',
                          validators=[NumberRange(min=0)],
                          default=0)
    draws = IntegerField(u'Draws', validators=[NumberRange(min=0)], default=0)

    players = FieldList(FormField(CompletedMatchPlayerForm))

    def __init__(self, *args, **kwargs):
        kwargs.setdefault('csrf_enabled', False)
        super(CompletedMatchRoundForm, self).__init__(*args, **kwargs)
Esempio n. 4
0
class TaxRateContainerForm(Form):
    """Acts as a container for managing the custom field forms"""
    
    current_taxes = FieldList(FormField(TaxRateForm))
    new_tax_rate  = FormField(NewTaxRateForm)
    
    @classmethod
    def to_form_data(cls, tax_rates=[]):
        container = Struct(current_taxes=[])
        for model in tax_rates:
            obj = Struct(uid=model.id, rate_name=model.name, rate=model.rate)
            container.current_taxes.append(obj)
        return container

    def save(self):
        # save existing fields
        for tax_rate_form in self.current_taxes:
            tax_rate_form.save()
        
        self.new_tax_rate.save_if_data()
Esempio n. 5
0
class CustomFieldsManagementForm(Form):
    """Acts as a container for managing the custom field forms"""
    
    current_fields = FieldList(FormField(CustomFieldForm))
    new_field      = FormField(NewCustomFieldForm)
     
    @classmethod
    def transform(cls, custom_fields):
        container = Struct(current_fields=[])

        for model in custom_fields:
            obj = Struct(uid=model.id, field_name=model.name, field_value=model.value)
            container.current_fields.append(obj)
        return container
    
    def save(self):
        # save existing fields
        for custom_form in self.current_fields:
            custom_form.save()
        
        self.new_field.save_if_data()
Esempio n. 6
0
class MatchForm(Form):
    team_id = SelectField(u'Team', coerce=int, validators=[Required()])
    opponent_id = SelectField(u'Opponent',
                              coerce=int,
                              choices=[],
                              validators=[Required()])
    competition_id = SelectField(u'Competition',
                                 coerce=int,
                                 validators=[Required()])
    server_id = SelectField(u'Server', coerce=int, validators=[Required()])
    date = MatchDateTimeField(u'Date', validators=[Required()])
    password = TextField(u'Server Password', \
            validators=[Length(min=0,max=100), Optional()])
    comments = TextAreaField(u'Comments', validators=[Optional()])

    players = FieldList(FormField(MatchPlayerForm))
Esempio n. 7
0
class CompletedMatchForm(Form):
    team_id = SelectField(u'Team', coerce=int, validators=[Required()])
    match_id = HiddenIntegerField(u'Corresponding Match',
                                  validators=[NumberRange(min=1),
                                              Required()])
    opponent_id = SelectField(u'Opponent',
                              coerce=int,
                              choices=[],
                              validators=[Required()])
    competition_id = SelectField(u'Competition',
                                 coerce=int,
                                 validators=[Required()])
    server_id = SelectField(u'Server', coerce=int, validators=[Required()])
    date_played = MatchDateTimeField(u'Date', validators=[Required()])
    comments = TextAreaField(u'Comments', validators=[Optional()])

    final_result_method = SelectField(
        u'Final Result',
        coerce=int,
        validators=[Required()],
        choices=CompletedMatch.FinalResultChoices)

    rounds = FieldList(FormField(CompletedMatchRoundForm))
Esempio n. 8
0
class ViewForm(ModelForm, TranslatedForm):
    class Meta:
        model = View

    columns = ModelFieldList(FormField(ViewColumnForm))
    groupers = ModelFieldList(FormField(ViewGrouperForm))
    sorters = ModelFieldList(FormField(ViewSorterForm))
    columns_choices = None
    filters = ModelFormField(ViewFiltersForm)

    def set_columns(self, columns):
        for column in columns:
            self.columns.append_entry(column)
            self.columns[-1].column.choices = copy.copy(self.columns_choices)
            if ('', '') in self.columns[-1].column.choices:
                self.columns[-1].column.choices.remove(('', ''))

    def set_groupers(self, groupers):
        for grouper in groupers:
            self.groupers.append_entry(grouper)
            self.groupers[-1].column.choices = self.columns_choices

    def set_sorters(self, sorters):
        for sorter in sorters:
            self.sorters.append_entry(sorter)
            self.sorters[-1].column.choices = self.columns_choices

    def get_view(self):
        view = View()
        view.title = self.title.data
        view.link_name = self.link_name.data
        view.datasource = self.datasource.data
        view.buttontext = self.buttontext.data
        view.reload_intervall = self.reload_intervall.data
        view.layout_number_columns = self.layout_number_columns.data
        return view

    def set_columns_choices(self, choices, update=False):
        self.columns_choices = choices
        if update:
            for column_form in self.columns:
                column_form.column.choices = choices
            for sorter_form in self.sorters:
                sorter_form.column.choices = choices
            for grouper_form in self.groupers:
                grouper_form.column.choices = choices

    def get_columns(self, view_id):
        columns = []
        for column_form in self.columns:
            column = ViewColumn()
            column.column = column_form.column.data
            column.parent_id = view_id
            columns.append(column)
        return columns

    def get_groupers(self, view_id):
        groupers = []
        for grouper_form in self.groupers:
            grouper = ViewGrouper()
            grouper.column = grouper_form.column.data
            grouper.parent_id = view_id
            groupers.append(grouper)
        return groupers

    def get_sorters(self, view_id):
        sorters = []
        for sorter_form in self.sorters:
            sorter = ViewSorter()
            sorter.column = sorter_form.column.data
            sorter.sorter_option = sorter_form.sorter_option.data
            sorter.parent_id = view_id
            sorters.append(sorter)
        return sorters

    def get_filters(self):
        return self.filters.get_filters()
Esempio n. 9
0
class CommandLineInterfaceForm(CommandLineInterfaceFormBase):
    arguments = FieldList(FormField(ArgumentForm))

    field_set = {'general': ('command', 'interpreter')}
Esempio n. 10
0
class TeamPlayersForm(Form):
    players = FieldList(FormField(TeamPlayerForm))
Esempio n. 11
0
class RateCoForm(Form):
    value_ratings = FieldList(FormField(ValueRatingForm))
Esempio n. 12
0
class ReportConfigurationForm(Form):
    summary = TextAreaField('Summary', validators=[Length(max=4096)])
    charts = FormField(ChartConfigurationForm)
Esempio n. 13
0
class ChartConfigurationForm(Form):
    visitors_for_month = FormField(VisitorsConfigurationForm)

    def __init__(self, *args, **kwargs):
        kwargs['csrf_enabled'] = False
        super(ChartConfigurationForm, self).__init__(*args, **kwargs)