0003-debug-manage-null-variable-32147.patch
hobo/debug/views.py | ||
---|---|---|
34 | 34 | |
35 | 35 |
@cached_property |
36 | 36 |
def debug_ips_variable(self): |
37 | 37 |
return get_setting_variable('INTERNAL_IPS.extend') |
38 | 38 | |
39 | 39 |
def get_initial(self): |
40 | 40 |
initial = super(HomeView, self).get_initial() |
41 | 41 |
initial['debug_log'] = bool(self.debug_log_variable.json) |
42 |
initial['debug_ips'] = self.debug_ips_variable.json |
|
42 |
initial['debug_ips'] = self.debug_ips_variable.json or []
|
|
43 | 43 |
return initial |
44 | 44 | |
45 | 45 |
@property |
46 | 46 |
def current_ip(self): |
47 | 47 |
return self.request.META.get('REMOTE_ADDR') or None |
48 | 48 | |
49 | 49 |
def get_context_data(self, **kwargs): |
50 | 50 |
ctx = super(HomeView, self).get_context_data(**kwargs) |
51 |
ctx['current_ip_debug'] = self.current_ip in self.debug_ips_variable.json
|
|
51 |
ctx['current_ip_debug'] = self.current_ip in (self.debug_ips_variable.json or [])
|
|
52 | 52 |
return ctx |
53 | 53 | |
54 | 54 |
def toggle_value(self, l, value): |
55 | 55 |
if value in l: |
56 | 56 |
return [x for x in l if x != value] |
57 | 57 |
else: |
58 | 58 |
return l + [value] |
59 | 59 | |
60 |
- |