Example #1
0
    def scan_status(self, obj):
        try:
            scan = obj.securityscan
        except ObjectDoesNotExist:
            html = self._to_span('', 'No scan')
        else:
            if scan.is_ok:
                if not scan.is_patched:
                    html = self._to_span("alert", "Vulnerable")
                else:
                    html = self._to_span("success", "Host clean")
            else:
                html = self._to_span("warning", "Scan failed")

            url_name = _url_name_for_change_view(type(obj), 'security_info')
            if not url_name:
                logger.error("No security view for obj of type: {}".format(
                    type(obj)))
            else:
                try:
                    url = get_admin_url(obj, url_name)
                    html = _linkify(html, url)
                except NoReverseMatch:
                    logger.error("cant reverse url for: {}, {}".format(
                        obj, url_name))
        return mark_safe(html)
Example #2
0
    def scm_status_check(self, obj):
        try:
            scmstatuscheck = obj.scmstatuscheck
        except ObjectDoesNotExist:
            html = self._to_span('', self.icon_no_scan)
        else:
            check_result = SCMCheckResult.from_id(scmstatuscheck.check_result)

            html = self._to_span(
                check_result.alert,
                self.icon_scan.format(check_result.icon_class)
            )

            url_name = _url_name_for_change_view(type(obj), 'scm_info')

            if not url_name:
                logger.error("No scm info view for obj of type: %s", type(obj))
            else:
                try:
                    url = get_admin_url(obj, url_name)
                    html = _linkify(html, url)
                except NoReverseMatch:
                    logger.error(
                        "cant reverse url for: %s, %s", obj, url_name
                    )
        return mark_safe(html)
Example #3
0
def get_results(queryset, can_edit, prepend_empty=False):
    results = []
    if prepend_empty:
        results.append({
            'pk': AUTOCOMPLETE_EMPTY_VALUE,
            '__str__': AUTOCOMPLETE_EMPTY_LABEL,
        })
    results.extend([{
        'pk':
        obj.pk,
        '__str__':
        getattr(obj, 'autocomplete_str', str(obj)),
        'edit_url':
        '{}?_popup=1'.format(get_admin_url(obj, 'change'))
        if can_edit else None,
        'tooltip':
        getattr(obj, 'autocomplete_tooltip', None)
    } for obj in queryset])
    return results
Example #4
0
 def get_async_transitions_awaiter_url(self, job_ids):
     return get_admin_url(self.objects[0], 'current_transitions')