예제 #1
0
    def get_table(self, **kwargs):
        # set some custom attributes for template rendering
        table = super(LogsIndexView, self).get_table(**kwargs)
        table.title = Tag(tag='i', attrs={"class": [IconEnum.LOGS.value]
                                          }) + _(' Logs')

        render_helper = RenderHelper(user_permissions=list(
            filter(None, self.request.user.get_all_permissions())),
                                     update_url_qs=get_current_view_args(
                                         self.request))

        # append export links
        query_trailer_sign = "?"
        if self.request.GET:
            query_trailer_sign = "&"
        csv_download_link = Link(url=self.request.get_full_path() +
                                 f"{query_trailer_sign}_export=csv",
                                 content=".csv")
        json_download_link = Link(url=self.request.get_full_path() +
                                  f"{query_trailer_sign}_export=json",
                                  content=".json")

        dropdown = Dropdown(btn_value=Tag(
            tag='i', attrs={"class": [IconEnum.DOWNLOAD.value]}) +
                            _(" Export as"),
                            items=[csv_download_link, json_download_link],
                            needs_perm=PermissionEnum.CAN_ACCESS_LOGS.value)
        table.actions = [render_helper.render_item(item=dropdown)]
        return table
예제 #2
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_uuid(self, record, value):
     if record.available:
         color = TextColorEnum.SUCCESS
     else:
         color = TextColorEnum.DANGER
     return Link(url=record.get_absolute_url(), color=color,
                 content=value).render(safe=True)
예제 #3
0
    def render_related_objects(self, value):
        link_list = []
        for metadata in value:
            if metadata.metadata_type == MetadataEnum.FEATURETYPE.value:
                kind_of_resource_icon = IconEnum.FEATURETYPE.value
                kind_of_resource = "Featuretype"
            elif metadata.metadata_type == MetadataEnum.LAYER.value:
                kind_of_resource_icon = IconEnum.LAYER.value
                kind_of_resource = "Layer"
            else:
                kind_of_resource_icon = ""
                kind_of_resource = ""
            kind_of_resource_icon = Tag(
                tag='i',
                attrs={
                    "class": [kind_of_resource_icon]
                },
            ).render()

            link_list.append(
                Link(
                    url=metadata.detail_view_uri,
                    content=format_html(kind_of_resource_icon +
                                        f" {metadata.title} [{metadata.id}]"),
                    tooltip=
                    _(f'Click to open the detail view of related {kind_of_resource} <strong>{metadata.title} [{metadata.id}]"</strong>'
                      ),
                ), )
        return format_html(
            self.render_helper.render_list_coherent(items=link_list))
예제 #4
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_metadatas__all(self, value):
     links = []
     for metadata in value:
         links.append(
             Tag(tag='span',
                 attrs={"class": ['mr-1']},
                 content=Link(url=metadata.get_absolute_url(),
                              content=metadata).render() + ','))
     return format_html(
         self.render_helper.render_list_coherent(items=links))
예제 #5
0
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)

        related_datasets = self.object.get_related_dataset_metadatas()

        item_list = []
        for related_dataset in related_datasets:
            link_to_dataset = Link(url=related_dataset.detail_view_uri,
                                   content=related_dataset.title)

            metadata_xml = Link(url=related_dataset.service_metadata_uri,
                                content=get_icon(IconEnum.CAPABILITIES) +
                                _(' XML'),
                                open_in_new_tab=True)
            metadata_html = Link(url=related_dataset.html_metadata_uri,
                                 content=get_icon(IconEnum.NEWSPAPER) +
                                 _(' HTML'),
                                 open_in_new_tab=True)

            dataset_metadata_dropdown = Dropdown(
                btn_value=get_icon(IconEnum.METADATA) + _(' Metadata'),
                items=[metadata_xml, metadata_html],
                color=ButtonColorEnum.SECONDARY,
                header=_l('Show metadata as:'))

            render_helper = RenderHelper(
                user_permissions=list(
                    filter(None, self.request.user.get_all_permissions())),
                update_url_qs=get_current_view_args(request=self.request),
                update_attrs={"class": ["btn-sm", "mr-1"]})
            right = render_helper.render_list_coherent(
                items=related_dataset.get_actions())

            item_content = DefaultHeaderRow(
                content_left=link_to_dataset.render(),
                content_center=dataset_metadata_dropdown.render(),
                content_right=right)
            item_list.append(ListGroupItem(content=item_content.render()))

        dataset_list = ListGroup(items=item_list)

        context.update({'card_body': dataset_list if related_datasets else ''})
        return context
예제 #6
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_health_state(self, value):
     if value.health_state_code == HealthStateEnum.WARNING.value:
         color = TextColorEnum.WARNING
     elif value.health_state_code == HealthStateEnum.CRITICAL.value:
         color = TextColorEnum.DANGER
     elif value.health_state_code == HealthStateEnum.UNAUTHORIZED.value:
         color = TextColorEnum.SECONDARY
     else:
         color = TextColorEnum.SUCCESS
     return Link(url=value.get_absolute_url, color=color,
                 content=value.pk).render(safe=True)
예제 #7
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_organization(self, record):
     if record.organization:
         url = reverse('structure:organization_details',
                       args=(record.organization.id, ))
         tooltip = _(
             'Click to open the detail view of <strong>{}</strong>.'.format(
                 record.organization.organization_name))
         return Link(tooltip=tooltip,
                     url=url,
                     content=record.organization.organization_name,
                     open_in_new_tab=True).render(safe=True)
     else:
         return '-'
예제 #8
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_name(self, record):
     url = reverse('structure:group_details', args=(record.id, ))
     icon = ''
     tooltip = _(
         'Click to open the detail view of <strong>{}</strong>'.format(
             record.name))
     if record.is_public_group:
         icon = Tag(tag='i', attrs={
             "class": [IconEnum.PUBLIC.value]
         }).render()
         tooltip = _('This is the anonymous public user group.'
                     ) + " {}".format(tooltip)
     return Link(
         tooltip=tooltip,
         url=url,
         content=format_html("{} {}".format(icon, record.name)),
         needs_perm=None,
         open_in_new_tab=True,
     ).render(safe=True)
예제 #9
0
 def render_online_resource(self, value):
     return Link(url=value, content=value).render(safe=True)
예제 #10
0
 def render_title(self, record, value):
     return Link(url=record.detail_view_uri,
                 content=value).render(safe=True)
예제 #11
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_results(self, record):
     if record.result_view_uri:
         return Link(url=record.result_view_uri,
                     content=_('results')).render(safe=True)
     else:
         return ''
예제 #12
0
 def render_parent_service(self, value):
     return Link(url=value.detail_view_uri, content=value).render(safe=True)
예제 #13
0
 def render_title(self, value, record):
     return Link(url=record.detail_html_view_uri,
                 content=value,
                 open_in_new_tab=True).render(safe=True)
예제 #14
0
 def render_service__published_for(self, value):
     return Link(url=value.detail_view_uri, content=value).render(safe=True)
예제 #15
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_uuid(self, record, value):
     return Link(url=record.get_absolute_url(),
                 content=value).render(safe=True)
예제 #16
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_monitoring_run(self, value):
     return Link(url=value.get_absolute_url(),
                 content=value).render(safe=True)
예제 #17
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_monitored_uri(self, value):
     return Link(url=value, content=value,
                 open_in_new_tab=True).render(safe=True)
예제 #18
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_metadata(self, value):
     return Link(url=value.get_absolute_url(),
                 content=value).render(safe=True)
예제 #19
0
 def render_contact(self, value):
     return Link(url=value.detail_view_uri, content=value).render(safe=True)
예제 #20
0
 def render_service__created_by(self, value):
     return Link(url=value.get_absolute_url(),
                 content=value).render(safe=True)
예제 #21
0
파일: tables.py 프로젝트: terrestris/mrmap
 def render_results(self, value):
     return Link(url=value.result_view_uri,
                 content=_('Results')).render(safe=True)