diff options
Diffstat (limited to 'lib/srtgui/tables.py')
-rw-r--r-- | lib/srtgui/tables.py | 100 |
1 files changed, 79 insertions, 21 deletions
diff --git a/lib/srtgui/tables.py b/lib/srtgui/tables.py index e0a6fb42..b8ff6f67 100644 --- a/lib/srtgui/tables.py +++ b/lib/srtgui/tables.py @@ -23,6 +23,7 @@ import re import json from srtgui.widgets import ToasterTable +from orm.models import SRTool from orm.models import Cve, Vulnerability, Investigation, CweTable, Product from orm.models import Package from orm.models import CpeTable, CpeFilter, Defect, DataSource, SrtSetting @@ -30,6 +31,7 @@ from orm.models import PublishPending from orm.models import Notify, NotifyCategories from orm.models import CveHistory, VulnerabilityHistory, InvestigationHistory, DefectHistory from orm.models import PublishSet +from orm.models import ErrorLog from users.models import UserSafe from django.db.models import Q @@ -593,31 +595,31 @@ class DefectsTable(ToasterTable): # SRT Priority filter is_srt_priority = TableFilter(name="is_srt_priority", - title="Filter defects by 'Priority'") - for priority in range(len(Defect.SRT_PRIORITY)): - if Defect.PRIORITY_ERROR == Defect.SRT_PRIORITY[priority][0]: + title="Filter defects by 'SRT Priority'") + for priority in range(len(SRTool.SRT_PRIORITY)): + if SRTool.PRIORITY_ERROR == SRTool.SRT_PRIORITY[priority][0]: continue is_srt_priority.add_action(TableFilterActionToggle( - Defect.SRT_PRIORITY[priority][1].lower().replace(' ','_'), - Defect.SRT_PRIORITY[priority][1], - Q(priority=Defect.SRT_PRIORITY[priority][0])) + SRTool.SRT_PRIORITY[priority][1].lower().replace(' ','_'), + SRTool.SRT_PRIORITY[priority][1], + Q(priority=SRTool.SRT_PRIORITY[priority][0])) ) self.add_filter(is_srt_priority) # SRTool Status filter is_srt_status = TableFilter(name="is_srt_status", - title="Filter defects by 'Status'") - for status in range(len(Defect.SRT_STATUS)): + title="Filter defects by 'SRT Status'") + for status in range(len(SRTool.SRT_STATUS)): is_srt_status.add_action(TableFilterActionToggle( - Defect.SRT_STATUS[status][1].lower().replace(' ','_'), - Defect.SRT_STATUS[status][1], - Q(status=Defect.SRT_STATUS[status][0])) + SRTool.SRT_STATUS[status][1].lower().replace(' ','_'), + SRTool.SRT_STATUS[status][1], + Q(status=SRTool.SRT_STATUS[status][0])) ) self.add_filter(is_srt_status) # SRTool Outcome filter is_srt_outcome = TableFilter(name="is_srt_outcome", - title="Filter defects by 'Outcome'") + title="Filter defects by 'SRT Outcome'") for status in range(len(Defect.SRT_OUTCOME)): is_srt_outcome.add_action(TableFilterActionToggle( Defect.SRT_OUTCOME[status][1].lower().replace(' ','_'), @@ -2057,7 +2059,7 @@ class NotificationsTable(ToasterTable): orderable=True, field_name="srt_created", static_data_name="srt_created", - static_data_template='{{data.srt_updated | date:"m/d/y H:i"}}' + static_data_template='{{data.srt_created | date:"m/d/y H:i"}}' ) self.add_column(title="Category", @@ -2120,14 +2122,70 @@ class NotificationsTable(ToasterTable): # static_data_template='''{{data.author.name}}''', # ) - manage_link_template = ''' - <span class="glyphicon glyphicon-edit edit-notify" id="notify_edit_'+{{data.id}}+'" x-data="{{data.id}}"></span> - ''' -# <span class="glyphicon glyphicon-trash trash-notify" id="notify_trash_'+{{data.id}}+'" x-data="{{data.id}}"></span> - self.add_column(title="Manage", - static_data_name="manage", - static_data_template=manage_link_template, - ) + if False: + manage_link_template = ''' + <span class="glyphicon glyphicon-edit edit-notify" id="notify_edit_'+{{data.id}}+'" x-data="{{data.id}}"></span> + ''' +# <span class="glyphicon glyphicon-trash trash-notify" id="notify_trash_'+{{data.id}}+'" x-data="{{data.id}}"></span> + self.add_column(title="Manage", + static_data_name="manage", + static_data_template=manage_link_template, + ) + + +class ErrorLogsTable(ToasterTable): + """Table of ErrorLogs in SRTool""" + + def __init__(self, *args, **kwargs): + super(ErrorLogsTable, self).__init__(*args, **kwargs) + self.default_orderby = "-srt_created" + + def get_context_data(self,**kwargs): + context = super(ErrorLogsTable, self).get_context_data(**kwargs) + return context + + def setup_queryset(self, *args, **kwargs): + self.queryset = ErrorLog.objects.all() + self.queryset = self.queryset.order_by(self.default_orderby) + + def setup_columns(self, *args, **kwargs): + + self.add_column(title="Select", + field_name="Select", + hideable=False, + static_data_name="select", + static_data_template='<input type="checkbox" value="{{data.pk}}" name="select-notify" />', + ) + + self.add_column(title="SRT Created", + hideable=False, + orderable=True, + field_name="srt_created", + static_data_name="srt_created", + static_data_template='{{data.srt_created | date:"m/d/y H:i"}}' + ) + + self.add_column(title="Severity", + field_name="severity", + orderable=True, + static_data_name="severity", + static_data_template='''{{ data.get_severity_text }}''', + ) + + self.add_column(title="Description", + field_name="description", + hideable=False, + orderable=True, + ) + + if False: + manage_link_template = ''' + <span class="glyphicon glyphicon-trash trash-errorlog" id="errorlog_trash_'+{{data.id}}+'" x-data="{{data.id}}"></span> + ''' + self.add_column(title="Manage", + static_data_name="manage", + static_data_template=manage_link_template, + ) class PackageFilterTable(ToasterTable): |