Beispiel #1
0
    def run(self, clear):
        if clear:
            clear_db()
            print(_('- db cleared'))

        model.load_db()
        print(_('- db loaded'))
Beispiel #2
0
    def run(self, clear):
        if clear:
            clear_db()
            print(_('- db cleared'))

        model.load_db()
        print(_('- db loaded'))
Beispiel #3
0
class ArrowCSVGrid(Grid):
    session_on = True
    allowed_export_targets = {'csv': CSV}
    DateTimeColumn(_('Created'), ArrowRecord.created_utc, DateTimeFilter)

    def query_prep(self, query, has_sort, has_filters):
        # default sort
        if not has_sort:
            query = query.order_by(ArrowRecord.id)

        return query
Beispiel #4
0
class ArrowGrid(Grid):
    session_on = True

    DateTimeColumn(_('Created'), ArrowRecord.created_utc, DateTimeFilter)

    def query_prep(self, query, has_sort, has_filters):
        # default sort
        if not has_sort:
            query = query.order_by(ArrowRecord.id)

        return query
Beispiel #5
0
class CreateDB(Command):
    """ create the DB and fill with data, optionally clear first """

    option_list = (Option('--clear',
                          default=False,
                          dest='clear',
                          action="store_true",
                          help=_('DROP all DB objects first')), )

    def run(self, clear):
        if clear:
            clear_db()
            print(_('- db cleared'))

        model.load_db()
        print(_('- db loaded'))
Beispiel #6
0
        Option('--clear', default=False, dest='clear', action="store_true",
               help=_('DROP all DB objects first')),
    )

    def run(self, clear):
        if clear:
            clear_db()
            print(_('- db cleared'))

        model.load_db()
        print(_('- db loaded'))


manager = Manager(create_app)
manager.add_option('-c', dest='config', default='Dev',
                   help=_('flask configuration to use'), required=False)
manager.add_command('create-db', CreateDB())


@manager.command
def list_routes(name='list-routes'):
    output = []
    for rule in flask.current_app.url_map.iter_rules():
        methods = ','.join(rule.methods)
        line = urllib.unquote("{:50s} {:20s} {}".format(rule.endpoint, methods, rule))
        output.append(line)

    for line in sorted(output):
        print(line)

Beispiel #7
0
class DefaultOpGrid(Grid):
    session_on = True

    FirstNameColumn(_('First Name'), Person.firstname,
                    TextFilter(Person.firstname, default_op=ops.eq))
Beispiel #8
0
class PeopleGrid(Grid):
    session_on = True

    FirstNameColumn(_('First Name'), Person.firstname, TextFilter)
    FullNameColumn(_('Full Name'))
    YesNoColumn(_('Active'), Person.inactive, reverse=True)
    EmailsColumn(_('Emails'))
    Column(_('Status'), Status.label.label('status'), StatusFilter(Status.id))
    DateTimeColumn(_('Created'), Person.createdts, DateTimeFilter)
    DateColumn(_('Due Date'), 'due_date')
    Column(_('Sort Order'), Person.sortorder, render_in='xls')
    Column(_('State'), Person.state, render_in='xlsx')
    NumericColumn(_('Number'), Person.numericcol, has_subtotal=True)
    EnumColumn(_('Account Type'), Person.account_type,
               OptionsEnumFilter(Person.account_type, enum_type=AccountType))

    def query_prep(self, query, has_sort, has_filters):
        query = query.add_columns(
            Person.id,
            Person.lastname,
            Person.due_date,
            Person.account_type,
        ).add_entity(Person).outerjoin(Person.status)

        # default sort
        if not has_sort:
            query = query.order_by(Person.id)

        return query
Beispiel #9
0
class StatusFilter(OptionsFilterBase):
    operators = (Operator('o', _('open'), None), ops.is_, ops.not_is,
                 Operator('c', _('closed'), None), ops.empty, ops.not_empty)
    options_from = Status.pairs
Beispiel #10
0
 def extract_data(self, record):
     return _('{record.firstname} {record.lastname}', record=record)
Beispiel #11
0
 class PeopleGrid(PGBase):
     CurrencyCol(_('Currency'), Person.numericcol, format_as='percent', places=5)
     CurrencyCol(_('C2'), Person.numericcol.label('n2'), format_as='accounting')
Beispiel #12
0
 def extract_data(self, record):
     return _('{record.firstname} {record.lastname}', record=record)
Beispiel #13
0
                          help=_('DROP all DB objects first')), )

    def run(self, clear):
        if clear:
            clear_db()
            print(_('- db cleared'))

        model.load_db()
        print(_('- db loaded'))


manager = Manager(create_app)
manager.add_option('-c',
                   dest='config',
                   default='Dev',
                   help=_('flask configuration to use'),
                   required=False)
manager.add_command('create-db', CreateDB())


@manager.command
def list_routes(name='list-routes'):
    output = []
    for rule in flask.current_app.url_map.iter_rules():
        methods = ','.join(rule.methods)
        line = urllib.unquote("{:50s} {:20s} {}".format(
            rule.endpoint, methods, rule))
        output.append(line)

    for line in sorted(output):
        print(line)