Пример #1
0
class DirectPeeringSessionTable(BaseTable):
    append_template = """
    {% load helpers %}
    {% if record.comments %}
    <button type="button" class="btn btn-xs btn-info popover-hover" data-toggle="popover" data-html="true" title="Peering Session Comments" data-content="{{ record.comments | markdown:True }}"><i class="fas fa-comment"></i></button>
    {% endif %}
    {% if record.autonomous_system.comments %}
    <button type="button" class="btn btn-xs btn-info popover-hover" data-toggle="popover" data-html="true" title="Autonomous System Comments" data-content="{{ record.autonomous_system.comments | markdown:True }}"><i class="fas fa-comments"></i></button>
    {% endif %}
    """

    pk = SelectColumn()
    local_autonomous_system = tables.Column(verbose_name="Local AS",
                                            linkify=True)
    autonomous_system = tables.Column(verbose_name="AS", linkify=True)
    ip_address = tables.Column(verbose_name="IP Address", linkify=True)
    bgp_group = tables.Column(verbose_name="BGP Group",
                              accessor="bgp_group",
                              linkify=True)
    relationship = tables.TemplateColumn(verbose_name="Relationship",
                                         template_code=BGP_RELATIONSHIP)
    enabled = BooleanColumn(verbose_name="Status")
    service_reference = tables.Column(verbose_name="Service ID", linkify=True)
    import_routing_policies = RoutingPolicyColumn(
        verbose_name="Import Policies")
    export_routing_policies = RoutingPolicyColumn(
        verbose_name="Export Policies")
    state = BGPSessionStateColumn(accessor="bgp_state")
    router = tables.Column(verbose_name="Router",
                           accessor="router",
                           linkify=True)
    tags = TagColumn(url_name="peering:directpeeringsession_list")
    actions = ButtonsColumn(DirectPeeringSession,
                            append_template=append_template)

    class Meta(BaseTable.Meta):
        model = DirectPeeringSession
        fields = (
            "pk",
            "service_reference",
            "local_autonomous_system",
            "autonomous_system",
            "ip_address",
            "bgp_group",
            "relationship",
            "enabled",
            "import_routing_policies",
            "export_routing_policies",
            "state",
            "last_established_state",
            "received_prefix_count",
            "advertised_prefix_count",
            "router",
            "tags",
            "actions",
        )
        default_columns = (
            "pk",
            "local_autonomous_system",
            "autonomous_system",
            "ip_address",
            "bgp_group",
            "relationship",
            "enabled",
            "router",
            "actions",
        )
Пример #2
0
class DeviceInterfaceTable(InterfaceTable):
    name = tables.TemplateColumn(
        template_code=
        '<i class="mdi mdi-{% if iface.mgmt_only %}wrench{% elif iface.is_lag %}drag-horizontal-variant'
        '{% elif iface.is_virtual %}circle{% elif iface.is_wireless %}wifi{% else %}ethernet'
        '{% endif %}"></i> <a href="{{ record.get_absolute_url }}">{{ value }}</a>',
        order_by=Accessor('_name'),
        attrs={'td': {
            'class': 'text-nowrap'
        }})
    parent = tables.Column(linkify=True, verbose_name='Parent')
    lag = tables.Column(linkify=True, verbose_name='LAG')
    actions = ButtonsColumn(model=Interface,
                            buttons=('edit', 'delete'),
                            prepend_template=INTERFACE_BUTTONS)

    class Meta(DeviceComponentTable.Meta):
        model = Interface
        fields = (
            'pk',
            'name',
            'label',
            'enabled',
            'type',
            'parent',
            'lag',
            'mgmt_only',
            'mtu',
            'mode',
            'mac_address',
            'description',
            'mark_connected',
            'cable',
            'cable_color',
            'cable_peer',
            'connection',
            'tags',
            'ip_addresses',
            'untagged_vlan',
            'tagged_vlans',
            'actions',
        )
        default_columns = (
            'pk',
            'name',
            'label',
            'enabled',
            'type',
            'parent',
            'lag',
            'mtu',
            'mode',
            'description',
            'ip_addresses',
            'cable',
            'connection',
            'actions',
        )
        row_attrs = {
            'class': get_cabletermination_row_class,
            'data-name': lambda record: record.name,
        }
Пример #3
0
class DeviceTable(LavaTable):
    def render_device_type(self, record):
        return pklink(record.device_type)

    def render_worker_host(self, record):
        if not record.worker_host and record.health == Device.HEALTH_RETIRED:
            return mark_safe("<i>...</i>")  # nosec - internal data
        if not record.worker_host and record.health != Device.HEALTH_RETIRED:
            return mark_safe(  # nosec - internal data
                '<span class="text-danger"><i>No worker</i> <span class="glyphicon glyphicon-fire"></span></span>'
            )
        if (record.worker_host.state == Worker.STATE_ONLINE
                and record.worker_host.health == Worker.HEALTH_ACTIVE):
            return mark_safe(  # nosec - internal data
                '<a href="%s">%s</a>' %
                (record.worker_host.get_absolute_url(), record.worker_host))
        elif record.worker_host.health == Worker.HEALTH_ACTIVE:
            return mark_safe(  # nosec - internal data
                '<a href="%s" class="text-danger">%s <span class="glyphicon glyphicon-fire"></span></a>'
                % (record.worker_host.get_absolute_url(), record.worker_host))
        else:
            return mark_safe(  # nosec - internal data
                '<a href="%s" class="text-warning">%s <span class="glyphicon glyphicon-minus-sign"></span></a>'
                % (record.worker_host.get_absolute_url(), record.worker_host))

    def render_health(self, record):
        if record.health == Device.HEALTH_GOOD:
            return mark_safe(  # nosec - internal data
                '<strong class="text-success">Good</strong>')
        elif record.health in [Device.HEALTH_UNKNOWN, Device.HEALTH_LOOPING]:
            return mark_safe(  # nosec - internal data
                '<span class="text-info">%s</span>' %
                record.get_health_display())
        elif record.health == Device.HEALTH_BAD:
            return mark_safe(  # nosec - internal data
                '<span class="text-danger">Bad</span>')
        elif record.health == Device.HEALTH_MAINTENANCE:
            return mark_safe(  # nosec - internal data
                '<span class="text-warning">Maintenance</span>')
        else:
            return mark_safe(  # nosec - internal data
                '<span class="text-muted">Retired</span>')

    hostname = tables.TemplateColumn("""
    <a href="{{ record.get_absolute_url }}">{{ record.hostname }}</a>
    """)
    worker_host = tables.TemplateColumn("""
    <a href="{{ record.worker_host.get_absolute_url }}">{{ record.worker_host }}</a>
    """)
    device_type = tables.Column()
    state = ExpandedStatusColumn("state")
    health = tables.Column(verbose_name="Health")
    tags = TagsColumn()

    class Meta(LavaTable.Meta):
        model = Device
        exclude = [
            "device_version",
            "physical_owner",
            "physical_group",
            "description",
            "current_job",
            "last_health_report_job",
        ]
        sequence = [
            "hostname", "worker_host", "device_type", "state", "health"
        ]
        searches = {"hostname": "contains"}
        queries = {
            "device_type_query": "device_type",
            "device_state_query": "state",
            "device_health_query": "health",
            "tags_query": "tags",
        }
Пример #4
0
class DeviceTable(BaseTable):
    pk = ToggleColumn()
    name = tables.TemplateColumn(order_by=('_name', ),
                                 template_code=DEVICE_LINK)
    status = tables.TemplateColumn(template_code=STATUS_LABEL)
    tenant = tables.TemplateColumn(template_code=COL_TENANT)
    site = tables.Column(linkify=True)
    rack = tables.Column(linkify=True)
    device_role = ColoredLabelColumn(verbose_name='Role')
    device_type = tables.LinkColumn(
        viewname='dcim:devicetype',
        args=[Accessor('device_type__pk')],
        verbose_name='Type',
        text=lambda record: record.device_type.display_name)
    primary_ip = tables.TemplateColumn(template_code=DEVICE_PRIMARY_IP,
                                       orderable=False,
                                       verbose_name='IP Address')
    primary_ip4 = tables.Column(linkify=True, verbose_name='IPv4 Address')
    primary_ip6 = tables.Column(linkify=True, verbose_name='IPv6 Address')
    cluster = tables.LinkColumn(viewname='virtualization:cluster',
                                args=[Accessor('cluster__pk')])
    virtual_chassis = tables.LinkColumn(viewname='dcim:virtualchassis',
                                        args=[Accessor('virtual_chassis__pk')])
    vc_position = tables.Column(verbose_name='VC Position')
    vc_priority = tables.Column(verbose_name='VC Priority')
    tags = TagColumn(url_name='dcim:device_list')

    class Meta(BaseTable.Meta):
        model = Device
        fields = (
            'pk',
            'name',
            'status',
            'tenant',
            'device_role',
            'device_type',
            'platform',
            'serial',
            'asset_tag',
            'site',
            'rack',
            'position',
            'face',
            'primary_ip',
            'primary_ip4',
            'primary_ip6',
            'cluster',
            'virtual_chassis',
            'vc_position',
            'vc_priority',
            'tags',
        )
        default_columns = (
            'pk',
            'name',
            'status',
            'tenant',
            'site',
            'rack',
            'device_role',
            'device_type',
            'primary_ip',
        )
Пример #5
0
class DeviceTable(BaseTable):
    pk = ToggleColumn()
    name = tables.TemplateColumn(order_by=('_name', ),
                                 template_code=DEVICE_LINK)
    status = ChoiceFieldColumn()
    tenant = TenantColumn()
    site = tables.Column(linkify=True)
    location = tables.Column(linkify=True)
    rack = tables.Column(linkify=True)
    device_role = ColoredLabelColumn(verbose_name='Role')
    manufacturer = tables.Column(
        accessor=Accessor('device_type__manufacturer'), linkify=True)
    device_type = tables.Column(linkify=True, verbose_name='Type')
    if settings.PREFER_IPV4:
        primary_ip = tables.Column(linkify=True,
                                   order_by=('primary_ip4', 'primary_ip6'),
                                   verbose_name='IP Address')
    else:
        primary_ip = tables.Column(linkify=True,
                                   order_by=('primary_ip6', 'primary_ip4'),
                                   verbose_name='IP Address')
    primary_ip4 = tables.Column(linkify=True, verbose_name='IPv4 Address')
    primary_ip6 = tables.Column(linkify=True, verbose_name='IPv6 Address')
    cluster = tables.Column(linkify=True)
    virtual_chassis = tables.Column(linkify=True)
    vc_position = tables.Column(verbose_name='VC Position')
    vc_priority = tables.Column(verbose_name='VC Priority')
    tags = TagColumn(url_name='dcim:device_list')

    class Meta(BaseTable.Meta):
        model = Device
        fields = (
            'pk',
            'name',
            'status',
            'tenant',
            'device_role',
            'manufacturer',
            'device_type',
            'platform',
            'serial',
            'asset_tag',
            'site',
            'location',
            'rack',
            'position',
            'face',
            'primary_ip',
            'primary_ip4',
            'primary_ip6',
            'cluster',
            'virtual_chassis',
            'vc_position',
            'vc_priority',
            'tags',
        )
        default_columns = (
            'pk',
            'name',
            'status',
            'tenant',
            'site',
            'location',
            'rack',
            'device_role',
            'manufacturer',
            'device_type',
            'primary_ip',
        )
Пример #6
0
class ResultsTable(LavaTable):
    """
    List of LAVA TestSuite results
    """
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

    def _check_job(self, record, table=None):  # pylint: disable=no-self-use
        """
        Slightly different purpose to RestrictedIDLinkColumn.render
        """
        user = table.context.get("request").user
        return bool(record.job.can_view(user))

    def render_submitter(self, record, table=None):
        if not self._check_job(record, table):
            return "Unavailable"
        return record.job.submitter

    def render_passes(self, record, table=None):
        if not self._check_job(record, table):
            return ""
        return record.testcase_count("pass")

    def render_fails(self, record, table=None):
        if not self._check_job(record, table):
            return ""
        return record.testcase_count("fail")

    def render_total(self, record, table=None):
        if not self._check_job(record, table):
            return ""
        return TestCase.objects.filter(suite__job=record.job,
                                       suite=record).count()

    def render_logged(self, record, table=None):
        if not self._check_job(record, table):
            return ""
        try:
            return TestCase.objects.filter(suite__job=record.job,
                                           suite=record)[0].logged
        except IndexError:
            return record.job.start_time

    def render_buglinks(self, record, table=None):

        suite_links_count = BugLink.objects.filter(
            content_type=ContentType.objects.get_for_model(TestSuite),
            object_id=record.id,
        ).count()
        case_links_count = BugLink.objects.filter(
            content_type=ContentType.objects.get_for_model(TestCase),
            object_id__in=TestCase.objects.filter(suite=record),
        ).count()

        user = table.context.get("request").user
        if not user.is_anonymous:
            return mark_safe(
                '<a href="#" class="buglink" id="buglink_%s" data-content-type="%s">[%s]</a> (%s)'
                % (
                    record.id,
                    ContentType.objects.get_for_model(TestSuite).id,
                    suite_links_count,
                    case_links_count,
                ))
        else:
            return mark_safe("[%s] (%s)" %
                             (suite_links_count, case_links_count))

    job_id = tables.Column(verbose_name="Job ID")
    actions = tables.TemplateColumn(
        template_name="lava_results_app/results_actions_field.html")
    actions.orderable = False
    submitter = tables.Column(accessor="job.submitter")
    name = tables.Column(verbose_name="Test Suite")
    passes = tables.Column(accessor="job", verbose_name="Passes")
    fails = tables.Column(accessor="job", verbose_name="Fails")
    total = tables.Column(accessor="job", verbose_name="Totals")
    logged = tables.Column(accessor="job", verbose_name="Logged")
    buglinks = tables.Column(accessor="job", verbose_name="Bug Links")
    buglinks.orderable = False

    class Meta(LavaTable.Meta):  # pylint: disable=no-init,too-few-public-methods
        searches = {"name": "contains"}
        sequence = {"job_id", "actions"}
Пример #7
0
class PrefixDetailTable(PrefixTable):
    utilization = tables.TemplateColumn(UTILIZATION_GRAPH, orderable=False)

    class Meta(PrefixTable.Meta):
        fields = ('pk', 'prefix', 'status', 'vrf', 'utilization', 'tenant',
                  'site', 'vlan', 'role', 'description')
 class Table(tables.Table):
     col = tables.TemplateColumn()
 class Table(tables.Table):
     track = tables.TemplateColumn('track: {{ value }}')
Пример #10
0
class AggregateDetailTable(AggregateTable):
    child_count = tables.Column(verbose_name='Prefixes')
    utilization = tables.TemplateColumn(UTILIZATION_GRAPH, orderable=False, verbose_name='Utilization')

    class Meta(AggregateTable.Meta):
        fields = ('pk', 'prefix', 'rir', 'child_count', 'utilization', 'date_added', 'description')
Пример #11
0
class VLANDetailTable(VLANTable):
    prefixes = tables.TemplateColumn(VLAN_PREFIXES, orderable=False, verbose_name='Prefixes')
    tenant = tables.TemplateColumn(template_code=COL_TENANT)

    class Meta(VLANTable.Meta):
        fields = ('pk', 'vid', 'site', 'group', 'name', 'prefixes', 'tenant', 'status', 'role', 'description')
Пример #12
0
class ManagedExpenseWorkflowTable(ExpenseWorkflowTable):
    description = tables.TemplateColumn("""{% load l10n %} <span id="managed_expense_{{record.id|unlocalize }}">{{ record.description }}</span>""")
    class Meta:
        attrs = {"class": "pydici-tables2 table table-hover table-striped table-condensed", "id": "managed_expense_workflow_table"}
        prefix = "managed_expense_workflow_table"
        orderable = False
Пример #13
0
class UserFiltersTable(LavaTable):

    name = tables.TemplateColumn('''
    <a href="{{ record.get_absolute_url }}">{{ record.name }}</a>
    ''')

    bundle_streams = tables.TemplateColumn('''
    {% for r in record.bundle_streams.all %}
        {{r.pathname}} <br />
    {% endfor %}
    ''')

    build_number_attribute = tables.Column()

    def render_build_number_attribute(self, value):
        if not value:
            return ''
        return value

    attributes = tables.TemplateColumn('''
    {% for a in record.attributes.all %}
    {{ a }}  <br />
    {% endfor %}
    ''')

    test = tables.TemplateColumn('''
      <table style="border-collapse: collapse">
        <tbody>
          {% for trftest in record.tests.all %}
          <tr>
            <td>
              {{ trftest.test }}
            </td>
            <td>
              {% for trftest_case in trftest.cases.all %}
              {{ trftest_case.test_case.test_case_id }}
              {% empty %}
              <i>any</i>
              {% endfor %}
            </td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    ''')
    test.orderable = False

    subscription = tables.Column()
    subscription.orderable = False

    def render_subscription(self, record):
        try:
            sub = TestRunFilterSubscription.objects.get(user=self.user,
                                                        filter=record)
        except TestRunFilterSubscription.DoesNotExist:
            return "None"
        else:
            return sub.get_level_display()

    public = tables.Column()

    class Meta(LavaTable.Meta):
        exclude = ('subscription')
        searches = {
            'name': 'contains',
        }
        queries = {
            'stream_query': 'bundle_streams',
        }
Пример #14
0
class ApplicationTable(BaseTable):
    pk = ToggleColumn()
    '''
    device_count = tables.TemplateColumn(    
        template_code=APPLICATION_DEVICE_COUNT,
        accessor=Accessor('devices.pk'),
        orderable=False,
        verbose_name='Devices'
    )
    
    device_count = tables.Column(
        verbose_name='Devices'
    )
    '''
    vm_count = tables.TemplateColumn(
        template_code=APPLICATION_VM_COUNT,
        accessor=Accessor('virtual_machines.count'),
        orderable=False,
        verbose_name='Virtual Machines'
        
    )
    actions = tables.TemplateColumn(
        template_code=APPLICATION_ACTIONS,
        attrs={'td': {'class': 'text-right noprint'}},
        verbose_name=''
    )
    
    
    #application_type = tables.LinkColumn('dcim:application_list', args=[Accessor('pk')])
    
    environnement=tables.TemplateColumn(template_code=ENVIRONNEMENT_TEMPLATE, verbose_name='environnement')
    
    version=tables.TemplateColumn(
        template_code=VERSION_TEMPLATE,
        verbose_name='Version'
        
    )
    application_team=tables.TemplateColumn(
        template_code=APPLICATION_TEAM_TEMPLATE,
        verbose_name='Application Team'
    )
    link=tables.TemplateColumn(
        template_code=LINK_TEMPLATE,
        verbose_name='Link'
    )
    
    application_maintainer=tables.TemplateColumn(
        template_code=APPLICATION_MAINTAINER_TEMPLATE,
        verbose_name='Main Maintainer'
    )
    scope=tables.TemplateColumn(
         template_code=SCOPE_TEMPLATE,
        verbose_name='Scope'
    )
    undersystem=tables.TemplateColumn(
          template_code=UNDERSYSTEM_TEMPLATE,
        verbose_name='Undersystem'
    )
    status=tables.TemplateColumn(
         template_code=STATUS_TEMPLATE,
        verbose_name='Scope'
    )
    tenant=tables.TemplateColumn(
          template_code=TENANT_TEMPLATE,
        verbose_name='Tenant'
    )
    
    ip_adress=tables.TemplateColumn(
          template_code=IPAM_TEMPLATE,
        verbose_name='IPADRESS'
    )
    





    class Meta(BaseTable.Meta):
        model = Application
        fields = ('pk','name','platform','database','application_type','environnement','version','application_team','link','application_maintainer','scope','undersystem','status','tenant','ip_adress')
Пример #15
0
class SnapsTable(tables.Table):
    id = tables.Column(verbose_name='ID')
    date = tables.TemplateColumn('<a href="/snaps/{{record.code}}">{{record.date}}</a>', verbose_name='Дата снапшота')
    status = tables.TemplateColumn('<img src="{{record.imagelink}}" height="16" width="16">', verbose_name='')
 class Table(tables.Table):
     track = tables.TemplateColumn('<span>{{ value }}</span>')
Пример #17
0
class SnapErrorMessagesTable(tables.Table):
    status = tables.TemplateColumn('<img src="./../../static/warning_sign.png" height="16" width="16">',
                                   verbose_name='')
    reason = tables.Column(verbose_name='Описание')
 class Table(tables.Table):
     foo = tables.TemplateColumn('default={{ default }}', default='bar')
Пример #19
0
 class TestTable(tables.Table):
     col_code = tables.TemplateColumn(
         template_code="code:{{ record.col }}{{ STATIC_URL }}")
     col_name = tables.TemplateColumn(
         template_name="test_template_column.html")
 class Table(tables.Table):
     foo = tables.TemplateColumn('value={{ value }}')
Пример #21
0
class Table2_Actuacions(tables.Table):

    moment_actuacio = tables.TemplateColumn(
        template_code=
        u"""{{record.moment_actuacio}} ( fa {{ record.getDate|timesince }} )""",
        order_by=('-moment_actuacio', ))

    grup = tables.TemplateColumn(template_code=u"""{{ record.alumne.grup }}""",
                                 order_by=(
                                     'alumne.grup',
                                     'alumne.cognoms',
                                     'alumne.nom',
                                     '-moment_actuacio',
                                 ))

    alumne = tables.TemplateColumn(template_code=u"""{{ record.alumne }}""",
                                   order_by=(
                                       'alumne.cognoms',
                                       'alumne.nom',
                                       '-moment_actuacio',
                                   ))

    qui = tables.TemplateColumn(
        template_code=
        u"""{{ record.professional }} ( {{record.get_qui_fa_actuacio_display}})""",
        order_by=(
            'professional',
            '-moment_actuacio',
        ),
        verbose_name=u"Qui?")

    ambqui = tables.TemplateColumn(
        template_code=u"""{{ record.get_amb_qui_es_actuacio_display }}""",
        order_by=(
            'amb_qui_es_actuacio',
            'alumne.grup',
            'alumne.cognoms',
            'alumne.nom',
            '-moment_actuacio',
        ),
        verbose_name=u"Amb qui?")

    assumpte = tables.TemplateColumn(
        template_code=u"""{{ record.assumpte }}""",
        order_by=('assumpte', 'alumne.grup', 'alumne.cognoms', 'alumne.nom'))

    accions = tables.TemplateColumn(
        template_code=u"""
                    <div class="btn-group btn-group-xs">
                        <a class="btn dropdown-toggle btn-primary btn-xs" data-toggle="dropdown" href="#">
                          Accions
                          <span class="caret"></span>
                        </a>
                        <ul class="dropdown-menu pull-right dropdown-menu-right">
                        
                          <li>
                            <a href="/tutoria/editaActuacio/{{record.pk}}">
                            Modificar/Veure dades<br>
                            </a>
                          </li>
                        
                          <li>
                            <a href="/tutoria/esborraActuacio/{{record.pk}}">
                            Esborra actuació<br>
                            </a>
                          </li>

                        </ul>
                      </div>
            """,
        orderable=False,
    )

    class Meta:
        model = Actuacio
        # add class="paleblue" to <table> tag
        attrs = {"class": "paleblue table table-striped"}
        sequence = (
            "moment_actuacio",
            "grup",
            "alumne",
            "qui",
            "ambqui",
            "assumpte",
        )
        fields = sequence
        template = 'bootable2.html'
 class Table(tables.Table):
     tcol = tables.TemplateColumn('column={{ column.name }}')
Пример #23
0
class Table2_ExpulsionsIIncidenciesPerAlumne(tables.Table):

    Eliminar_Incidencia_Gestionada_Pel_Tutor = tables.TemplateColumn(
        verbose_name=u" ",
        attrs={'th': {
            'width': '4%'
        }},
        template_code=u"""
                        {% if record.gestionada_pel_tutor and record.professional_inicia %} 
                                <a style="color:red" href="/incidencies/eliminaIncidencia/{{record.pk}}?origen=tutoria"> 
                                    <span class="glyphicon glyphicon-remove"/> 
                                </a>
                        {% endif %}
                        """,
        orderable=False,
    )

    Eliminar = tables.TemplateColumn(
        verbose_name=u" ",
        attrs={'th': {
            'width': '4%'
        }},
        template_code=u"""
                        {% if  not record.es_incidencia_d_aula and not record.dia_expulsio %} 
                                <a style="color:red" href="/incidencies/eliminaIncidencia/{{record.pk}}"> 
                                    <span class="glyphicon glyphicon-remove"/> 
                                </a>
                        {% endif %}                                                
                        {% if record.dia_expulsio %}
                            <a href="/incidencies/editaExpulsio/{{ record.pk }}/"> 
                                    <span class="glyphicon glyphicon-pencil"/> 
                            </a>
                        {% endif %}
                        {% if record.es_incidencia_d_aula %}
                            <a class= "gi-2x" href="/incidencies/posaIncidenciaAula/{{record.control_assistencia.impartir.pk}}"> 
                                    <span class="glyphicon glyphicon-eye-open"/> 
                            </a>

                        {% endif %}
                        """,
        orderable=False,
    )

    Tipus = tables.TemplateColumn(
        verbose_name=u" ",
        attrs={'th': {
            'width': '10%'
        }},
        template_code=u"""
                                        {% if record.dia_incidencia %}
                                            {{ record.tipus }} 
                                        {% else %}
                                            Expulsió
                                        {% endif %}
                                        {% if record.es_vigent and not record.tipus.es_informativa %} <br>(vigent) {% endif %}
                                        """,
        orderable=False,
    )
    DataAsignatura = tables.TemplateColumn(
        verbose_name=u" ",
        attrs={'th': {
            'width': '35%'
        }},
        #verbose_name=u"Data/Assignatura",
        template_code=u"""
                                            {{ record.dia_expulsio }} {{ record.franja_expulsio }} {{ record.get_estat_display }}
                                            {{ record.dia_incidencia }}
                                            {{ record.franja_incidencia }}
                                            {{ record.control_assistencia.impartir.horari.assignatura}} <br>
                                            {{ record.get_gestionada_pel_tutor_motiu_display }}
                                            {% if record.gestionada_pel_tutor %}
                                            <br>
                                            Sancionat per: {{record.professional}}{{record.professor}}
                                            {% endif %}
                                            """,
        orderable=False,
    )
    Motiu = tables.TemplateColumn(
        verbose_name=u" ",
        #attrs={'th': {'width': '46%'}},
        template_code=u"""
                                            {{record.mini_motiu}}
                                            {{record.descripcio_incidencia}}
                                            """,
        orderable=False,
    )

    class Meta:
        # add class="paleblue" to <table> tag
        show_header = False
        attrs = {"class": "paleblue table table-striped"}
        template = 'bootable2.html'
Пример #24
0
class RevisitsTable(tables.Table):
    # patid = Patients.objects.get(id=)
    # path = '<a href="{% url \'revisits:edit_revisit\' record.patient_id record.visit record.id %}">{{ record.id }}</a>'
    # def render_rec(self, record):
    #     return "{}".format(record.patient_id)
    # return mark_safe(''' <a href="{% url \'revisits:edit_revisit\' record.patient_id record.visit record.id %}">%s</a> ''' % (record.patient, value))

    id = tables.TemplateColumn(
        '<a href="{% url \'revisits:edit_revisit\' record.id record.patient_id record.visit %}">{{record.id}}</a>',
        verbose_name=u'Revisit ID',
    )
    visit = tables.TemplateColumn(
        '<a href="{% url \'revisits:edit_revisit\' record.id record.patient_id record.visit %}">{{record.visit}}</a>',
        verbose_name=u'Visit No',
    )
    patient = tables.TemplateColumn(
        '<a href="{% url \'revisits:edit_revisit\' record.id record.patient_id record.visit %}">{{record.patient}}</a>',
        verbose_name=u'Patient Name',
    )

    revisitdate = tables.TemplateColumn(
        '<a href="{% url \'revisits:edit_revisit\' record.id record.patient_id record.visit %}">{{record.visitdate}}</a>',
        verbose_name=u'Revisit Date',
    )

    diagnosis = tables.TemplateColumn(
        '<a href="{% url \'revisits:edit_revisit\' record.id record.patient_id record.visit %}">{{record.diagnosis}}</a>',
        verbose_name=u'Revisit Daignosis',  #footer=len(tables.rows)
    )

    amount = tables.TemplateColumn(
        '<a href="{% url \'revisits:edit_revisit\' record.id record.patient_id record.visit %}">{{record.amount}}</a>',
        verbose_name=u'Revisit Amount',
        footer=render_footer)

    visitdate = tables.TemplateColumn(
        '<a href="{% url \'revisits:edit_revisit\' record.id record.patient_id record.visit %}">{{record.visit.visitdate}}</a>',
        verbose_name=u'Visit Date',
    )

    visitdia = tables.TemplateColumn(
        '<a href="{% url \'revisits:edit_revisit\' record.id record.patient_id record.visit %}">{{record.visit.diagnosis}}</a>',
        verbose_name=u'Visit Daignosis',  #footer=len(tables.rows)
    )

    visamount = tables.TemplateColumn(
        '<a href="{% url \'revisits:edit_revisit\' record.id record.patient_id record.visit %}">{{record.visit.amount}}</a>',
        accessor='visit.amount',
        verbose_name=u'Visit Amount',
        footer=render_footer)

    prn = tables.TemplateColumn(
        '<a class="btn btn-outline-secondary" href="#under_construction">Add Prescription</a>',
        verbose_name=u'Add Prescription')

    addrevis = tables.TemplateColumn(
        '<a class="btn btn-outline-primary" href="{% url \'revisits:save_revisit\' record.patient_id record.visit %}">Add Revisit</a>',
        verbose_name=u'Add Revisit')

    editvis = tables.TemplateColumn(
        '<a class="btn btn-outline-primary" href="{% url \'visits:visits_patient_id\' record.visit record.patient_id %}">Update Visit</a>',
        verbose_name=u'Update Visit')

    delrevis = tables.TemplateColumn(
        '<a class="btn btn-outline-danger" href="{% url \'revisits:delete_revisit\' record.id %}" '
        'onclick="return confirm(\'Are you sure you want to delete this Revisit ?\')">Delete Revisit</a>',
        verbose_name=u'Delete Revisit')

    class Meta:
        model = Revisits
        attrs = {"id": "revisits-table"}
        template_name = 'django_tables2/bootstrap4.html'
        fields = (
            'id',
            'visit',
            'patient',
            'revisitdate',
            'diagnosis',
            'amount',
            'visitdate',
            'visitdia',
            'visamount',
            'prn',
            'addrevis',
            'editvis',
            'delrevis',
        )
Пример #25
0
class PathEndpointTable(CableTerminationTable):
    connection = tables.TemplateColumn(accessor='_path.last_node',
                                       template_code=CABLETERMINATION,
                                       verbose_name='Connection',
                                       orderable=False)
Пример #26
0
class EnrollmentTable(tables.Table):

    edit_column = tables.TemplateColumn(
        verbose_name=_('Edit student'),
        orderable=False,
        template_name='enrollments/edit_column.html',
        attrs={'url': '/enrollments/edit/'})
    delete_column = tables.TemplateColumn(
        verbose_name=_('Delete student'),
        orderable=False,
        template_name='enrollments/delete_column.html',
        attrs={'url': '/api/enrollments/'})
    moved_column = tables.TemplateColumn(
        verbose_name=_('Student moved'),
        orderable=False,
        template_name='django_tables2/moved_column.html')
    grading_term1 = tables.TemplateColumn(
        verbose_name=_('Term 1'),
        orderable=False,
        template_name='django_tables2/grading_term1_column.html')
    grading_term2 = tables.TemplateColumn(
        verbose_name=_('Term 2'),
        orderable=False,
        template_name='django_tables2/grading_term2_column.html')
    grading_final = tables.TemplateColumn(
        verbose_name=_('Final'),
        orderable=False,
        template_name='django_tables2/grading_final_column.html')
    grading_incomplete = tables.TemplateColumn(
        verbose_name=_('Incomplete?'),
        orderable=False,
        template_name='django_tables2/grading_incomplete_column.html')

    student_age = tables.Column(
        verbose_name=_('Age'),
        accessor='student.age',
        orderable=False,
    )
    student_birthday = tables.Column(
        verbose_name=_('Birthday'),
        accessor='student.birthday',
        orderable=False,
    )
    student_phone_number = tables.Column(
        verbose_name=_('Phone number'),
        accessor='student.phone_number',
        orderable=False,
    )
    student_registered_in_unhcr = tables.Column(
        verbose_name=_('Registered in UNHCR'),
        orderable=False,
        accessor='student.registered_in_unhcr')

    class Meta:
        model = Enrollment
        template = 'django_tables2/bootstrap.html'
        fields = (
            'edit_column',
            'delete_column',
            'moved_column',
            'grading_term1',
            'grading_term2',
            'grading_final',
            'grading_incomplete',
            'registration_date',
            'student.first_name',
            'student.father_name',
            'student.last_name',
            'student.sex',
            'student_age',
            'student_birthday',
            'student.nationality',
            'student.mother_fullname',
            'student.mother_nationality',
            'student_registered_in_unhcr',
            'student.id_type',
            'student.id_number',
            'student.address',
            'student_phone_number',
            'classroom',
            'section',
            'last_education_level',
            'last_school_type',
            'last_school_shift',
            'last_school',
            'last_education_year',
            'last_year_result',
            'participated_in_alp',
            # 'last_informal_edu_level',
            'last_informal_edu_round',
            'last_informal_edu_final_result',
            'new_registry',
            'student_outreached',
            'have_barcode',
            'outreach_barcode',
            'created',
            'modified',
            'dropout_status',
            'disabled',
        )
Пример #27
0
class JobTable(LavaTable):
    """
    Common table for the TestJob model.
    There is no need to derive from this class merely
    to change the queryset - do that in the View.
    Do inherit from JobTable if you want to add new columns
    or change the exclusion list, i.e. the structure of the
    table, not the data shown by the table.
    To preserve custom handling of fields like id, device and duration,
    ensure those are copied into the new class.
    """

    id = tables.Column(verbose_name="ID")
    actions = tables.TemplateColumn(
        template_name="lava_scheduler_app/job_actions_field.html")
    actions.orderable = False
    device = tables.Column(accessor="actual_device", verbose_name="Device")
    device_type = tables.Column(accessor="requested_device_type",
                                verbose_name="Device type")
    duration = tables.Column()
    duration.orderable = False
    submit_time = tables.DateColumn(format="Nd, g:ia")
    end_time = tables.DateColumn(format="Nd, g:ia")
    state = tables.Column()
    state.orderable = False

    def __init__(self, *args, **kwargs):
        kwargs["template_name"] = "lazytables.html"
        super().__init__(*args, **kwargs)

    def render_state(self, record):
        if record.state == TestJob.STATE_RUNNING:
            return mark_safe(  # nosec - internal data
                '<span class="text-info"><strong>%s</strong></span>' %
                record.get_state_display())
        elif record.state == TestJob.STATE_FINISHED:
            if record.health == TestJob.HEALTH_UNKNOWN:
                text = "text-default"
            elif record.health == TestJob.HEALTH_COMPLETE:
                text = "text-success"
            elif record.health == TestJob.HEALTH_INCOMPLETE:
                text = "text-danger"
            elif record.health == TestJob.HEALTH_CANCELED:
                text = "text-warning"
            return mark_safe(  # nosec - internal data
                '<span class="%s"><strong>%s</strong></span>' %
                (text, record.get_health_display()))
        else:
            return mark_safe(  # nosec - internal data
                '<span class="text-muted"><strong>%s</strong></span>' %
                record.get_state_display())

    def render_device_type(self, record):
        if record.requested_device_type:
            return pklink(record.requested_device_type)
        return record

    def render_device(self, record):
        if record.actual_device:
            retval = pklink(record.actual_device)
        elif record.dynamic_connection:
            return "connection"
        else:
            return "-"
        device_type = None
        if record.requested_device_type:
            device_type = record.requested_device_type
        if not device_type:
            return "Error"
        return retval

    def render_description(self, value):
        if value:
            return value
        else:
            return ""

    def render_submitter(self, record):
        user_name = record.submitter.username
        full_name = record.submitter.get_full_name()

        if settings.SHOW_SUBMITTER_FULL_NAME and full_name:
            show_text = full_name
            hover_text = user_name
        else:
            show_text = user_name
            hover_text = full_name if full_name else user_name

        return mark_safe(  # nosec - internal data
            '<span title="%s">%s</span>' % (hover_text, show_text))

    class Meta(LavaTable.Meta):
        model = TestJob
        # alternatively, use 'fields' value to include specific fields.
        exclude = [
            "is_public",
            "sub_id",
            "target_group",
            "health_check",
            "definition",
            "original_definition",
            "multinode_definition",
            "requested_device_type",
            "start_time",
            "log_file",
            "actual_device",
            "health",
        ]
        fields = (
            "id",
            "actions",
            "state",
            "health",
            "device",
            "device_type",
            "description",
            "submitter",
            "submit_time",
            "end_time",
            "duration",
        )
        sequence = (
            "id",
            "actions",
            "state",
            "device",
            "device_type",
            "description",
            "submitter",
            "submit_time",
            "end_time",
            "duration",
        )
        # filter view functions supporting relational mappings and returning a Q()
        queries = {
            "device_query": "device",  # active_device
            "owner_query": "submitter",  # submitter
            "job_state_query": "state",
            "requested_device_type_query": "requested_device_type",
        }
        # fields which can be searched with default __contains queries
        # note the enums cannot be searched this way.
        searches = {
            "id": "contains",
            "sub_id": "contains",
            "description": "contains"
        }
        # dedicated time-based search fields
        times = {"submit_time": "hours", "end_time": "hours"}
Пример #28
0
class OpenRunsTable(tables.Table):
    run_number = tables.Column(verbose_name="Run Number")
    user = tables.Column(verbose_name="User")

    dataset_express = tables.Column(verbose_name="Express")
    dataset_prompt = tables.Column(verbose_name="Prompt")
    dataset_rereco = tables.Column(verbose_name="ReReco")
    dataset_rereco_ul = tables.Column(verbose_name="ReRecoUL")

    certify = tables.TemplateColumn('<div></div>',
                                    orderable=False,
                                    verbose_name="",
                                    visible=False)

    delete = tables.TemplateColumn(
        '<div align="center">'
        '<a href="{% url \'delete:delete_open_run\' run_number=record.run_number %}">'
        '{% if user == record.user %}'
        '<button class="btn btn-block btn-danger" id="id_openruns_delete">'
        '{% else %}'
        '<button class="btn btn-block btn-danger" id="id_openruns_delete" disabled>'
        '{% endif %}'
        'Remove Entry'
        '</button>'
        '</a>'
        '</div>',
        orderable=False,
        verbose_name="")

    def render_run_number(self, record):  # pagman: no cover
        return mark_safe(
            '<div>'
            '<span class="align-middle">{}</span>'
            '</div>'.format(record.run_number), )

    def render_dataset_express(self, record):  # pragma: no cover
        """
        :return: colored status of Dataset
        """
        return render_dataset(record.run_number, record.dataset_express,
                              record.state_express, "express", record.user,
                              self.request.user)

    def render_dataset_prompt(self, record):  # pragma: no cover
        """
        :return: colored status of Dataset
        """
        return render_dataset(record.run_number, record.dataset_prompt,
                              record.state_prompt, "prompt", record.user,
                              self.request.user)

    def render_dataset_rereco(self, record):  # pragma: no cover
        """
        :return: colored status of Dataset
        """
        return render_dataset(record.run_number, record.dataset_rereco,
                              record.state_rereco, "rereco", record.user,
                              self.request.user)

    def render_dataset_rereco_ul(self, record):  # pragma: no cover
        """
        :return: colored status of Dataset
        """
        return render_dataset(record.run_number, record.dataset_rereco_ul,
                              record.state_rereco_ul, "rerecoul", record.user,
                              self.request.user)

    def render_certify(self, record):  # pragma: no cover
        """
        :return: colored Certify button
        """
        return render_certify_button(record.run_number, record.dataset_express,
                                     record.dataset_prompt,
                                     record.dataset_rereco)

    class Meta:
        attrs = {"class": "table table-stripped", "id": "openruns_table"}
        row_attrs = {'user_row': lambda record: record.user.username}
Пример #29
0
class PrefixTable(BaseTable):
    pk = ToggleColumn()
    prefix = tables.TemplateColumn(template_code=PREFIX_LINK,
                                   attrs={'td': {
                                       'class': 'text-nowrap'
                                   }})
    prefix_flat = tables.TemplateColumn(
        template_code=PREFIXFLAT_LINK,
        attrs={'td': {
            'class': 'text-nowrap'
        }},
        verbose_name='Prefix (Flat)',
    )
    depth = tables.Column(accessor=Accessor('_depth'), verbose_name='Depth')
    children = LinkedCountColumn(accessor=Accessor('_children'),
                                 viewname='ipam:prefix_list',
                                 url_params={
                                     'vrf_id': 'vrf_id',
                                     'within': 'prefix',
                                 },
                                 verbose_name='Children')
    status = ChoiceFieldColumn(default=AVAILABLE_LABEL)
    vrf = tables.TemplateColumn(template_code=VRF_LINK, verbose_name='VRF')
    tenant = TenantColumn()
    site = tables.Column(linkify=True)
    vlan = tables.Column(linkify=True, verbose_name='VLAN')
    role = tables.Column(linkify=True)
    is_pool = BooleanColumn(verbose_name='Pool')
    mark_utilized = BooleanColumn(verbose_name='Marked Utilized')
    utilization = PrefixUtilizationColumn(accessor='get_utilization',
                                          orderable=False)
    tags = TagColumn(url_name='ipam:prefix_list')

    class Meta(BaseTable.Meta):
        model = Prefix
        fields = (
            'pk',
            'id',
            'prefix',
            'prefix_flat',
            'status',
            'children',
            'vrf',
            'utilization',
            'tenant',
            'site',
            'vlan',
            'role',
            'is_pool',
            'mark_utilized',
            'description',
            'tags',
        )
        default_columns = (
            'pk',
            'prefix',
            'status',
            'children',
            'vrf',
            'utilization',
            'tenant',
            'site',
            'vlan',
            'role',
            'description',
        )
        row_attrs = {
            'class': lambda record: 'success' if not record.pk else '',
        }
Пример #30
0
class MRSRequestListView(crudlfap.ListView):
    allowed_groups = ['Admin', 'UPN', 'Support', 'Superviseur']

    def get_show_caisse_filter(self):
        self.show_caisse_filter = (self.request.user.caisses.count() > 1
                                   or self.request.user.profile == 'admin')

    def get_filter_fields(self):
        filter_fields = [
            'status',
            'institution',
            'creation_date__gte',
            'creation_date__lte',
        ]
        if self.show_caisse_filter:
            filter_fields.append('caisse')
        return filter_fields

    filterset_extra_class_attributes = dict(
        creation_date__gte=django_filters.DateFilter(
            field_name='creation_datetime',
            lookup_expr='gte',
            input_formats=[DATE_FORMAT_FR],
            label='Date minimale',
            widget=forms.TextInput(attrs={
                'class': 'crudlfap-datepicker',
                'data-clearable': 'true',
                'data-format': 'dd/mm/yyyy',
            }, )),
        creation_date__lte=django_filters.DateFilter(
            field_name='creation_datetime',
            lookup_expr='lte',
            input_formats=[DATE_FORMAT_FR],
            label='Date maximale',
            widget=forms.TextInput(attrs={
                'class': 'crudlfap-datepicker',
                'data-clearable': 'true',
                'data-format': 'dd/mm/yyyy',
            }, ),
        ),
        has_conflicts_accepted=django_filters.BooleanFilter(
            field_name='conflicts_accepted',
            label='Signalements acceptés',
            method=boolean_gte_filter,
        ),
        has_conflicts_resolved=django_filters.BooleanFilter(
            field_name='conflicts_resolved',
            label='Signalements résolus',
            method=boolean_gte_filter,
        ),
    )

    DISPLAY_ID_TEMPLATE = '''
    <a
        data-position="bottom"
        data-tooltip="{{ record.tooltip }}"
        class="{{ record.color }}-text tooltipped"
        href="{{ record.get_absolute_url }}"
    >{{ record.display_id }}</a>
    '''

    table_columns = dict(  # our extra columns
        display_id=tables.TemplateColumn(DISPLAY_ID_TEMPLATE, ),
        first_name=tables.Column(
            accessor='insured.first_name',
            verbose_name='Prénom',
            order_by=['insured__first_name'],
        ),
        last_name=tables.Column(
            accessor='insured.last_name',
            verbose_name='Nom',
            order_by=['insured__last_name'],
        ),
        nir=tables.Column(
            accessor='insured.nir',
            verbose_name='NIR',
            order_by=['insured__nir'],
        ),
    )

    search_fields = (
        'insured__first_name',
        'insured__last_name',
        'insured__email',
        'insured__nir',
        'institution__finess',
        'display_id',
        'caisse__name',
        'caisse__number',
        'caisse__code',
    )

    def get_table_sequence(self):
        sequence = [
            'creation_datetime',
            'display_id',
            'first_name',
            'last_name',
            'nir',
            'status',
            'delay',
            'caisse',
        ]
        if self.request.user.profile == 'admin':
            sequence.append('saving')
        return sequence

    def get_filterset(self):
        filterset = super().get_filterset() or self.filterset
        form = filterset.form
        if 'caisse' in form.fields and self.request.user.profile != 'admin':
            form.fields['caisse'].queryset = self.request.user.caisses.all()
        return filterset

    def get_table_meta_checkbox_column_template(self):
        return ''.join([
            '{% if record.status == record.STATUS_INPROGRESS %}',
            super().get_table_meta_checkbox_column_template(),
            '{% endif %}',
        ])

    def get_queryset(self):
        qs = super().get_queryset()
        self.queryset = qs.select_related('caisse', 'insured')
        return self.queryset