@@ -18,10 +18,7 @@ class AppSettings(UuidAuditedModel):
1818
1919 owner = models .ForeignKey (User , on_delete = models .PROTECT )
2020 app = models .ForeignKey ('App' , on_delete = models .CASCADE )
21- routable = models .BooleanField (null = True )
22- # the default values is None to differentiate from user sending an empty allowlist
23- # and user just updating other fields meaning the values needs to be copied from prev release
24- allowlist = models .JSONField (default = None , null = True )
21+ routable = models .BooleanField (default = True )
2522 autoscale = models .JSONField (default = dict , blank = True )
2623 label = models .JSONField (default = dict , blank = True )
2724
@@ -37,15 +34,11 @@ def __init__(self, *args, **kwargs):
3734 def __str__ (self ):
3835 return "{}-{}" .format (self .app .id , str (self .uuid )[:7 ])
3936
40- def new (self , user , allowlist ):
37+ def new (self , user ):
4138 """
42- Create a new application appSettings using the provided allowlist
43- on behalf of a user.
39+ Create a new application appSettings on behalf of a user.
4440 """
45-
46- app_settings = AppSettings .objects .create (
47- owner = user , app = self .app , allowlist = allowlist )
48-
41+ app_settings = AppSettings .objects .create (owner = user , app = self .app )
4942 return app_settings
5043
5144 def _update_routable (self , previous_settings ):
@@ -54,35 +47,12 @@ def _update_routable(self, previous_settings):
5447 # If no previous settings then assume it is the first record and default to true
5548 if previous_settings is None :
5649 setattr (self , 'routable' , True )
57- self .app .routable (True )
5850 # if nothing changed copy the settings from previous
5951 elif new is None and old is not None :
6052 setattr (self , 'routable' , old )
6153 elif old != new :
62- self .app .routable (new )
6354 self .summary += ["{} changed routablity from {} to {}" .format (self .owner , old , new )]
6455
65- def _update_allowlist (self , previous_settings ):
66- # If no previous settings then assume it is the first record and set as empty
67- # to prevent from database constraint violation
68- if not previous_settings :
69- setattr (self , 'allowlist' , [])
70- old = getattr (previous_settings , 'allowlist' , [])
71- new = getattr (self , 'allowlist' , None )
72- # if nothing changed copy the settings from previous
73- if new is None and old is not None :
74- setattr (self , 'allowlist' , old )
75- elif set (old ) != set (new ):
76- added = ', ' .join (k for k in set (new )- set (old ))
77- added = 'added ' + added if added else ''
78- deleted = ', ' .join (k for k in set (old )- set (new ))
79- deleted = 'deleted ' + deleted if deleted else ''
80- changes = ', ' .join (i for i in (added , deleted ) if i )
81- if changes :
82- if self .summary :
83- self .summary += ' and '
84- self .summary += "{} {}" .format (self .owner , changes )
85-
8656 def _update_autoscale (self , previous_settings ):
8757 data = getattr (previous_settings , 'autoscale' , {}).copy ()
8858 new = getattr (self , 'autoscale' , {}).copy ()
@@ -165,7 +135,6 @@ def save(self, *args, **kwargs):
165135
166136 try :
167137 self ._update_routable (previous_settings )
168- self ._update_allowlist (previous_settings )
169138 self ._update_autoscale (previous_settings )
170139 self ._update_label (previous_settings )
171140 except (UnprocessableEntity , NotFound ):
@@ -180,4 +149,3 @@ def save(self, *args, **kwargs):
180149 summary = ' ' .join (self .summary )
181150 self .app .log ('summary of app setting changes: {}' .format (summary ), logging .DEBUG )
182151 super (AppSettings , self ).save (** kwargs )
183- self .app .refresh ()
0 commit comments