Пример #1
0
class PortTable(BootstrapTable):
    class Meta:
        table_args = {
            'data-sort-name': 'switchport_name',
        }

    def __init__(self, *a, switch_id=None, **kw):
        super().__init__(*a, **kw)
        self.switch_id = switch_id

    switchport_name = Column("Name",
                             width=2,
                             col_args={'data-sorter': 'table.sortPort'})
    patchport_name = Column("→ Patchport",
                            width=2,
                            col_args={'data-sorter': 'table.sortPatchPort'})
    room = LinkColumn("→ Raum", width=10)
    edit_link = BtnColumn('Editieren', hide_if=no_inf_change)
    delete_link = BtnColumn('Löschen', hide_if=no_inf_change)

    @property
    def toolbar(self):
        if no_inf_change():
            return
        href = url_for(".switch_port_create", switch_id=self.switch_id)
        return button_toolbar("Switch-Port", href)
Пример #2
0
class BankAccountActivityTable(BootstrapTable):
    """A table for displaying bank account activities """
    bank_account = Column("Bankkonto", width=1)
    name = Column("Name", width=2)
    valid_on = DateColumn("Gültig am", width=1)
    imported_at = DateColumn("Importiert am", hide_if=lambda: True)
    reference = Column("Verwendungszweck")
    iban = Column("IBAN", hide_if=lambda: True)
    amount = Column("Betrag", width=1, formatter="table.euroFormatter")
    actions = MultiBtnColumn("Aktionen", width=1)

    def __init__(self, *a, **kw):
        table_args = kw.pop('table_args', {})
        table_args.setdefault('data-detail-view', "true")
        table_args.setdefault('data-row-style', "table.financeRowFormatter")
        table_args.setdefault('data-detail-formatter',
                              "table.bankAccountActivitiesDetailFormatter")
        kw['table_args'] = table_args

        super().__init__(*a, **kw)

    class Meta:
        table_args = {
            'data-sort-order': 'desc',
            'data-sort-name': 'valid_on',
        }
Пример #3
0
    class Table(BootstrapTable):
        a = Column("Column 1")
        b = Column("Column 2", name='bar')

        def toolbar(self):
            yield "<span>"
            yield "Hasta la vista, baby!"
            yield "</span>"
Пример #4
0
class UsersDueTable(BootstrapTable):
    """A table for displaying the users that """
    user_id = Column("Nutzer-ID")
    user = LinkColumn("Name")
    valid_on = Column("Gültig am")
    description = Column("Beschreibung")
    fee_account_id = LinkColumn("Beitragskonto")
    amount = Column("Betrag", formatter="table.coloredFormatter")
Пример #5
0
class UnconfirmedTransactionsTable(BootstrapTable):
    """A table for displaying unconfirmed transactions """
    description = LinkColumn("Beschreibung")
    user = LinkColumn("Nutzer")
    room = Column("Wohnort")
    date = DateColumn("Datum")
    amount = Column("Wert")
    author = LinkColumn("Ersteller")
    actions = MultiBtnColumn("Aktionen")
Пример #6
0
class SwitchTable(BootstrapTable):
    id = Column("#")
    name = LinkColumn("Name")
    ip = Column("Management IP")
    edit_link = BtnColumn('Editieren', width=1, hide_if=no_inf_change)
    delete_link = BtnColumn('Löschen', width=1, hide_if=no_inf_change)

    @property
    def toolbar(self):
        if not current_user.has_property('infrastructure_change'):
            return

        return button_toolbar("Switch", url_for(".switch_create"))
Пример #7
0
class PreMemberTable(BootstrapTable):
    prm_id = Column("ID")
    name = Column("Name", formatter="table.textWithBooleanFormatter")
    login = Column("Login")
    email = Column("E-Mail Adresse",
                   formatter="table.textWithBooleanFormatter")
    move_in_date = DateColumn("Einzug am")
    actions = MultiBtnColumn("Aktionen", hide_if=no_membership_change, width=1)

    class Meta:
        table_args = {
            'data-row-style': 'table.membershipRequestRowFormatter',
        }
Пример #8
0
class BankAccountTable(BootstrapTable):
    """A table for displaying bank accounts

    :param bool create_account: An optional switch adding
        a “create bank account” button to the toolbar
    """
    name = Column("Name")
    bank = Column("Bank")
    ktonr = Column("Kontonummer")
    blz = Column("Bankleitzahl")
    iban = Column("IBAN")
    bic = Column("SWIFT-BIC")
    balance = Column("Saldo")
    last_imported_at = Column("Zuletzt importiert")
    kto = BtnColumn("Konto")

    def __init__(self, *a, create_account=False, **kw):
        self.create_account = create_account
        super().__init__(*a, **kw)

    @property
    def toolbar(self):
        """A “create bank account” button"""
        if not self.create_account:
            return
        href = url_for(".bank_accounts_create")
        return button_toolbar(gettext("Neues Bankkonto anlegen"), href)
Пример #9
0
class MembershipFeeTable(BootstrapTable):
    """A table for displaying the current membership fees"""
    name = Column("Name")
    regular_fee = Column("Regulär")
    payment_deadline = Column("Frist")
    payment_deadline_final = Column("Endgültige Frist")
    begins_on = DateColumn("Beginn")
    ends_on = DateColumn("Ende")
    actions = MultiBtnColumn("Aktionen")

    @property
    def toolbar(self):
        """An “add fee” button"""
        href = url_for(".membership_fee_create")
        return button_toolbar(gettext("Beitrag erstellen"), href)
Пример #10
0
class MembershipTable(BootstrapTable):
    """A table for displaying memberships

    In the toolbar, a “new membership” button is inserted if the
    :py:obj:`current_user` has the ``add_membership`` property.
    """
    group_name = Column("Gruppe")
    begins_at = DateColumn("Beginn")
    ends_at = DateColumn("Ende")
    actions = MultiBtnColumn("Aktionen", hide_if=no_membership_change)

    def __init__(self, *a, user_id=None, **kw):
        super().__init__(*a, **kw)
        self.user_id = user_id

    @property
    def toolbar(self):
        if self.user_id is None:
            return
        if no_membership_change():
            return

        href = url_for(".add_membership", user_id=self.user_id)
        return button_toolbar("Mitgliedschaft", href)

    class Meta:
        table_args = {
            'data-row-attributes': 'table.membershipRowAttributes',
            'data-row-style': 'table.membershipRowFormatter',
            'class': 'membership-table'
        }
Пример #11
0
 def test_instatiation_with_name_and_title_works(self):
     c = Column(title="Test Column", name="test_col")
     self.assertEqual(c.name, "test_col")
     self.assertEqual(c.title, "Test Column")
     self.assertEqual(c.width, 0)
     self.assertEqual(c.cell_style, False)
     self.assertEqual(repr(c), "<Column 'test_col' title='Test Column'>")
Пример #12
0
class PatchPortTable(BootstrapTable):
    class Meta:
        table_args = {
            'data-sort-name': 'name',
        }

    name = Column('Name',
                  width=2,
                  col_args={'data-sorter': 'table.sortPatchPort'})
    room = LinkColumn('→ Raum', width=5)
    switch_port = LinkColumn('→ Switch-Port',
                             width=3,
                             col_args={'data-sorter': 'table.sortPort'})
    edit_link = BtnColumn('Editieren', hide_if=no_inf_change)
    delete_link = BtnColumn('Löschen', hide_if=no_inf_change)

    def __init__(self, *a, room_id=None, **kw):
        super().__init__(*a, **kw)

        self.room_id = room_id

    @property
    def toolbar(self):
        if no_inf_change():
            return
        href = url_for(".patch_port_create", switch_room_id=self.room_id)
        return button_toolbar("Patch-Port", href)
Пример #13
0
class InterfaceTable(BootstrapTable):
    """A table for displaying interfaces
    """
    name = Column("Name")
    mac = Column("MAC")
    ips = Column("IPs")
    actions = MultiBtnColumn("Aktionen", hide_if=no_hosts_change)

    def __init__(self, *a, host_id=None, **kw):
        table_args = kw.pop('table_args', {})
        table_args.setdefault('data-hide-pagination-info', "true")
        table_args.setdefault('data-search', "false")
        kw['table_args'] = table_args

        super().__init__(*a, **kw)
        self.host_id = host_id
Пример #14
0
 def test_custom_arguments_set(self):
     rendered = str(
         Column(title="Test Column",
                name="test_col",
                width=3,
                cell_style="customCellStyle"))
     self.assertIn('data-cell-style="customCellStyle"', rendered)
     self.assertIn('class="col-sm-3"', rendered)
Пример #15
0
class InstantiatedColumnTestCase(TestCase):
    def setUp(self):
        super().setUp()
        self.column = Column(title="Test Column", name="test_col")

    def test_col_args(self):
        arg_string = self.column.build_col_args()
        self.assertIn('data-field="test_col"', arg_string)
        self.assertIn('data-sortable="true"', arg_string)

    def test_col_render(self):
        rendered = str(self.column)
        self.assertEqual(self.column.render(), rendered)
        self.assertTrue(rendered.startswith("<th"))
        self.assertTrue(rendered.endswith("</th>"))
        self.assertIn(self.column.build_col_args(), rendered)
        self.assertIn(self.column.title, rendered)
Пример #16
0
class TransactionTable(BootstrapTable):
    """A table for displaying bank account activities """
    account = LinkColumn("Konto")
    amount = Column("Wert")

    class Meta:
        table_args = {
            'data-row-style': 'table.financeRowFormatter',
        }
Пример #17
0
    def test_column_is_hidden(self):
        hide = False

        def hide_if():
            return hide

        c = Column("Test", name='test_col', hide_if=hide_if)
        self.assertNotEqual(str(c), "")
        hide = True
        self.assertEqual(str(c), "", "Column rendered in spite of hide_if")
Пример #18
0
class HostTable(BootstrapTable):
    """A table for displaying hosts
    """
    name = Column("Name")
    switch = Column("Switch")
    port = Column("SwitchPort")
    actions = MultiBtnColumn("Aktionen", hide_if=no_hosts_change, width=3)
    interfaces_table_link = Column("", hide_if=lambda: True)
    interface_create_link = Column("", hide_if=lambda: True)
    id = Column("", hide_if=lambda: True)

    def __init__(self, *a, user_id=None, **kw):
        table_args = kw.pop('table_args', {})
        table_args.setdefault('data-load-subtables', "true")
        table_args.setdefault('data-detail-view', "true")
        table_args.setdefault('data-detail-formatter',
                              "table.hostDetailFormatter")
        table_args.setdefault('data-response-handler',
                              "table.userHostResponseHandler")
        kw['table_args'] = table_args

        super().__init__(*a, **kw)
        self.user_id = user_id

    @property
    def toolbar(self):
        if self.user_id is None:
            return
        if no_hosts_change():
            return

        href = url_for("host.host_create", user_id=self.user_id)
        return button_toolbar("Host", href)
Пример #19
0
class SubnetTable(BootstrapTable):
    id = Column("#")
    description = Column("Beschreibung")
    address = Column("IP")
    gateway = Column("Gateway")
    reserved = Column("Reservierte Adressen",
                      formatter='table.listFormatter',
                      sortable=False)
    free_ips_formatted = Column("Freie IPs",
                                col_args={
                                    'data-sort-name': 'free_ips',
                                })
Пример #20
0
        class Table(BootstrapTable):
            class Meta:
                table_args = {'foo': "bar", 'data-cache': "true"}

            col1 = Column("Column 1")
            col2 = Column("Column 2")
Пример #21
0
class RoomLogTable(BootstrapTable):
    created_at = DateColumn("Erstellt um")
    user = LinkColumn("Nutzer")
    message = Column("Nachricht")
Пример #22
0
class SearchTable(BootstrapTable):
    """A table for displaying search results"""
    id = Column("ID")
    url = LinkColumn("Name")
    login = Column("Login")
Пример #23
0
 def test_init_requires_args(self):
     with self.assertRaises(TypeError):
         Column()  # pylint: disable=no-value-for-parameter
Пример #24
0
class TrafficTopTable(BootstrapTable):
    """A table for displaying the users with the highest traffic usage"""
    url = LinkColumn("Name")
    traffic_for_days = Column("Traffic", formatter='table.byteFormatterBinary')
Пример #25
0
 def setUp(self):
     super().setUp()
     self.column = Column(title="Test Column", name="test_col")
Пример #26
0
 class Table(SplittedTable):
     splits = (('split1', "Split 1"), ('split2', "Split 2"))
     foo = Column("Foo")
     bar = Column("Bar")
Пример #27
0
class TenancyTable(BootstrapTable):
    room = LinkColumn("Zimmer")
    begins_at = DateColumn("Von")
    ends_at = DateColumn("Bis")
    status = Column("Status")
Пример #28
0
 def test_instantiation_without_name(self):
     c = Column("Test Title")
     self.assertIsNone(c.name)
     self.assertEqual(c.title, "Test Title")
Пример #29
0
 class B(A):
     a = Column("Shizzle")
     c = Column("Baz")
Пример #30
0
 class A(BootstrapTable):
     a = Column("Foo")
     b = Column("Bar")