1818class AbstractCheck (TimeStampedEditableModel ):
1919 name = models .CharField (max_length = 64 , db_index = True )
2020 is_active = models .BooleanField (
21- _ (' active' ),
21+ _ (" active" ),
2222 default = True ,
2323 db_index = True ,
2424 help_text = _ (
25- ' whether the check should be run, related metrics collected and alerts sent'
25+ " whether the check should be run, related metrics collected and alerts sent"
2626 ),
2727 )
28- description = models .TextField (blank = True , help_text = _ (' Notes' ))
28+ description = models .TextField (blank = True , help_text = _ (" Notes" ))
2929 content_type = models .ForeignKey (
3030 ContentType , on_delete = models .CASCADE , null = True , blank = True
3131 )
3232 object_id = models .CharField (max_length = 36 , db_index = True , blank = True )
33- content_object = GenericForeignKey (' content_type' , ' object_id' )
33+ content_object = GenericForeignKey (" content_type" , " object_id" )
3434 check_type = models .CharField (
35- _ (' check type' ),
35+ _ (" check type" ),
3636 choices = app_settings .CHECK_CHOICES ,
3737 db_index = True ,
3838 max_length = 128 ,
3939 )
4040 params = JSONField (
41- _ (' parameters' ),
41+ _ (" parameters" ),
4242 default = dict ,
4343 blank = True ,
44- help_text = _ (' parameters needed to perform the check' ),
45- load_kwargs = {' object_pairs_hook' : OrderedDict },
46- dump_kwargs = {' indent' : 4 },
44+ help_text = _ (" parameters needed to perform the check" ),
45+ load_kwargs = {" object_pairs_hook" : OrderedDict },
46+ dump_kwargs = {" indent" : 4 },
4747 )
4848
4949 class Meta :
5050 abstract = True
51- unique_together = (' name' , ' object_id' , ' content_type' )
51+ unique_together = (" name" , " object_id" , " content_type" )
5252 indexes = [
5353 models .Index (
54- fields = [' content_type' , ' object_id' , ' is_active' ],
55- name = ' active_object_checks_idx' ,
54+ fields = [" content_type" , " object_id" , " is_active" ],
55+ name = " active_object_checks_idx" ,
5656 )
5757 ]
5858
5959 permissions = (
60- (' add_check_inline' , ' Can add check inline' ),
61- (' change_check_inline' , ' Can change check inline' ),
62- (' delete_check_inline' , ' Can delete check inline' ),
63- (' view_check_inline' , ' Can view check inline' ),
60+ (" add_check_inline" , " Can add check inline" ),
61+ (" change_check_inline" , " Can change check inline" ),
62+ (" delete_check_inline" , " Can delete check inline" ),
63+ (" view_check_inline" , " Can view check inline" ),
6464 )
6565
6666 def __str__ (self ):
6767 if not self .object_id or not self .content_type :
6868 return self .name
6969 obj = self .content_object
7070 model_name = obj .__class__ .__name__
71- return ' {0} ({1}: {2})' .format (self .name , model_name , obj )
71+ return " {0} ({1}: {2})" .format (self .name , model_name , obj )
7272
7373 def clean (self ):
7474 self .check_instance .validate ()
@@ -95,10 +95,10 @@ def check_instance(self):
9595 def perform_check (self , store = True ):
9696 """Initializes check instance and calls the check method."""
9797 if (
98- hasattr (self .content_object , ' is_deactivated' )
98+ hasattr (self .content_object , " is_deactivated" )
9999 and self .content_object .is_deactivated ()
100100 ) or (
101- hasattr (self .content_object , ' organization_id' )
101+ hasattr (self .content_object , " organization_id" )
102102 and self .content_object .organization .is_active is False
103103 ):
104104 return
0 commit comments