Exemple #1
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)
Exemple #2
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")
Exemple #3
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")
Exemple #4
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)
Exemple #5
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',
        }
Exemple #6
0
class ArchivableMembersTable(RefreshableTableMixin, BootstrapTable):
    class Meta:
        table_args = {'data-escape': 'false', 'data-sort-stable': True}

    id = Column("#")
    user = LinkColumn("Mitglied")
    room_shortname = LinkColumn("<i class=\"fas fa-home\"></i>")
    num_hosts = Column("<i class=\"fas fa-laptop\"></i>")
    current_properties = Column("Props", formatter="table.propertiesFormatter")
    end_of_membership = DateColumn("EOM")

    if typing.TYPE_CHECKING:

        @classmethod
        def row(cls, id: int, user: dict, room_shortname: dict,
                current_properties: str, num_hosts: int,
                end_of_membership: dict) -> dict:
            ...
Exemple #7
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"))
Exemple #8
0
class BuildingLevelRoomTable(BootstrapTable):
    class Meta:
        table_args = {
            'data-sort-name': 'room',
            'data-query-params': 'perhaps_all_users_query_params',
        }

    room = LinkColumn("Raum")
    inhabitants = MultiBtnColumn('Bewohner')

    @property
    def toolbar(self):
        return toggle_button_toolbar("Display all users",
                                     id="rooms-toggle-all-users",
                                     icon="fa-user")
Exemple #9
0
class SiteTable(BootstrapTable):
    site = LinkColumn("Site")
    buildings = MultiBtnColumn("Buildings")
Exemple #10
0
class RoomOvercrowdedTable(BootstrapTable):
    room = LinkColumn("Raum")
    inhabitants = MultiBtnColumn("Bewohner")

    class Meta:
        table_args = {'data-sort-name': 'room'}
Exemple #11
0
class RoomLogTable(BootstrapTable):
    created_at = DateColumn("Erstellt um")
    user = LinkColumn("Nutzer")
    message = Column("Nachricht")
Exemple #12
0
class FinanceTable(BootstrapTable):
    class Meta:
        table_args = {
            'data-side-pagination': 'server',
            # 'data-search': 'true',
            'data-sort-order': 'desc',
            # 'data-sort-name': 'valid_on',
            'data-page-list': '[5, 10, 25, 50, 100]'
        }

    def __init__(self, *a, saldo=None, user_id=None, inverted=False, **kw):
        """Init

        :param int user_id: An optional user_id.  If set, this causes
            a “details” button to be rendered in the toolbar
            referencing the user.
        :param bool inverted: An optional switch adding
            `style=inverted` to the given `data_url`
        """

        self.saldo = saldo

        if inverted:
            self._enforced_url_params = frozenset({
                ('style', 'inverted')
            }.union(self._enforced_url_params))
            self.saldo = -saldo

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

        self.user_id = user_id
        self.table_footer_offset = 3

    posted_at = Column("Erstellt um")
    valid_on = Column("Gültig am")
    description = LinkColumn("Beschreibung")
    amount = ColoredColumn("Wert", cell_style='table.tdRelativeCellStyle')

    @property
    def toolbar(self):
        """Generate a toolbar with a details button

        If a user_id was passed in the constructor, this renders a
        “details” button reaching the finance overview of the user's account.
        """
        if self.user_id is None:
            return
        href = url_for("user.user_account", user_id=self.user_id)
        return button_toolbar("Details", href, icon="fa-chart-area")

    @property
    @lazy_join
    def table_footer(self):
        yield "<tfoot>"
        yield "<tr>"

        yield f"<td colspan=\"{self.table_footer_offset}\" class=\"text-right\">"
        yield "<strong>Saldo:</strong>"
        yield "</td>"

        yield "<td>"
        yield "{}".format(
            money_filter(self.saldo) if self.saldo is not None else "-")
        yield "</td>"

        yield "</tr>"
        yield "</tfoot>"
Exemple #13
0
class TenancyTable(BootstrapTable):
    room = LinkColumn("Zimmer")
    begins_at = DateColumn("Von")
    ends_at = DateColumn("Bis")
    status = Column("Status")
Exemple #14
0
class RoomHistoryTable(BootstrapTable):
    room = LinkColumn("Wohnort")
    begins_at = DateColumn("Von")
    ends_at = DateColumn("Bis")
Exemple #15
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')
Exemple #16
0
class SearchTable(BootstrapTable):
    """A table for displaying search results"""
    id = Column("ID")
    url = LinkColumn("Name")
    login = Column("Login")