forked from b0bac/ApolloScanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodels.py
50 lines (41 loc) · 2.39 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from django.db import models
from django.utils.html import format_html
class VulnerabilityMonitorTask(models.Model):
id = models.AutoField(primary_key=True, db_column="id", verbose_name='序号')
name = models.CharField(max_length=32, db_column="name", verbose_name='任务名称')
keyword = models.CharField(db_column="keyword", max_length=256, verbose_name='关键字')
timestamp = models.DateTimeField(db_column="timestamp", verbose_name='创建日期', auto_now=True)
def __str__(self):
return self.name
def change(self):
btn_str = '<a class="btn btn-xs btn-danger" href="{}">' \
'<input name="编辑任务"' \
'type="button" id="passButton" ' \
'title="passButton" value="编辑">' \
'</a>'
return format_html(btn_str, '%s/change'%self.id)
change.short_description = '任务编辑'
class Meta:
verbose_name = '任务管理'
verbose_name_plural = verbose_name
# Create your models here.
class VulnerbilityMonitorResult(models.Model):
id = models.AutoField(primary_key=True, db_column="id", verbose_name='序号')
username = models.CharField(max_length=32, db_column="username", verbose_name='GitHub用户', editable=False)
taskname = models.CharField(max_length=32, db_column="taskname", verbose_name='对应任务', default='', editable=False)
projectname = models.CharField(max_length=200, db_column="projectname", verbose_name='项目名称', editable=False)
linkurl = models.CharField(db_column="linkurl", max_length=256, verbose_name='项目URL', unique=True, editable=False)
state = models.BooleanField(db_column="state", verbose_name='更新标志', default=False)
timestamp = models.DateTimeField(db_column="timestamp", verbose_name='监控日期', auto_now=True, editable=False)
class Meta:
verbose_name = '漏洞监控'
verbose_name_plural = verbose_name
def change(self):
# VulnerbilityMonitorResult.objects.filter(id=self.id).update(state=False)
btn_str = '<a class="btn btn-xs btn-danger" href="{}">' \
'<input name="查看漏洞"' \
'type="button" id="passButton" ' \
'title="passButton" value="查看">' \
'</a>'
return format_html(btn_str, '%s/change'%self.id)
change.short_description = '漏洞查看'