mirror of https://github.com/openspug/spug
				
				
				
			fix issues
							parent
							
								
									4c9975202b
								
							
						
					
					
						commit
						902cfbe89f
					
				| 
						 | 
				
			
			@ -18,7 +18,7 @@ logging.captureWarnings(True)
 | 
			
		|||
 | 
			
		||||
def site_check(url, limit):
 | 
			
		||||
    try:
 | 
			
		||||
        res = requests.get(url, timeout=10, verify=False)
 | 
			
		||||
        res = requests.get(url, timeout=10)
 | 
			
		||||
        if limit:
 | 
			
		||||
            duration = int(res.elapsed.total_seconds() * 1000)
 | 
			
		||||
            if duration > int(limit):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -39,8 +39,8 @@ class Detection(models.Model, ModelMixin):
 | 
			
		|||
    updated_at = models.CharField(max_length=20, null=True)
 | 
			
		||||
    updated_by = models.ForeignKey(User, models.PROTECT, related_name='+', null=True)
 | 
			
		||||
 | 
			
		||||
    def to_dict(self, *args, **kwargs):
 | 
			
		||||
        tmp = super().to_dict(*args, **kwargs)
 | 
			
		||||
    def to_view(self):
 | 
			
		||||
        tmp = self.to_dict()
 | 
			
		||||
        tmp['type_alias'] = self.get_type_display()
 | 
			
		||||
        tmp['notify_mode'] = json.loads(self.notify_mode)
 | 
			
		||||
        tmp['notify_grp'] = json.loads(self.notify_grp)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,7 +14,7 @@ class DetectionView(View):
 | 
			
		|||
    def get(self, request):
 | 
			
		||||
        detections = Detection.objects.all()
 | 
			
		||||
        groups = [x['group'] for x in detections.order_by('group').values('group').distinct()]
 | 
			
		||||
        return json_response({'groups': groups, 'detections': [x.to_dict() for x in detections]})
 | 
			
		||||
        return json_response({'groups': groups, 'detections': [x.to_view() for x in detections]})
 | 
			
		||||
 | 
			
		||||
    def post(self, request):
 | 
			
		||||
        form, error = JsonParser(
 | 
			
		||||
| 
						 | 
				
			
			@ -64,7 +64,7 @@ class DetectionView(View):
 | 
			
		|||
                if form.is_active:
 | 
			
		||||
                    task = Detection.objects.filter(pk=form.id).first()
 | 
			
		||||
                    message = {'id': form.id, 'action': 'add'}
 | 
			
		||||
                    message.update(task.to_dict(selects=('targets', 'extra', 'rate', 'type')))
 | 
			
		||||
                    message.update(task.to_dict(selects=('targets', 'extra', 'rate', 'type', 'threshold', 'quiet')))
 | 
			
		||||
                else:
 | 
			
		||||
                    message = {'id': form.id, 'action': 'remove'}
 | 
			
		||||
                rds_cli = get_redis_connection()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue