15
15
from django .utils import timezone
16
16
from django .utils .decorators import method_decorator
17
17
from django .views .decorators .csrf import csrf_exempt
18
- from django .views .generic import View
18
+ from django .views .generic import TemplateView , View
19
19
from ipware import get_client_ip
20
20
21
21
from core .models import Service
@@ -119,7 +119,7 @@ def get(self, *args, **kwargs):
119
119
"service_uuid" : self .kwargs .get ("service_uuid" ),
120
120
},
121
121
)
122
- if self .kwargs .get ("identifier" ) is None
122
+ if self .kwargs .get ("identifier" ) == None
123
123
else reverse (
124
124
"ingress:endpoint_script_id" ,
125
125
kwargs = {
@@ -129,9 +129,6 @@ def get(self, *args, **kwargs):
129
129
)
130
130
)
131
131
heartbeat_frequency = settings .SCRIPT_HEARTBEAT_FREQUENCY
132
- dnt = self .request .META .get ("HTTP_DNT" , "0" ).strip () == "1"
133
- service_uuid = self .kwargs .get ("service_uuid" )
134
- service = Service .objects .get (pk = service_uuid , status = Service .ACTIVE )
135
132
return render (
136
133
self .request ,
137
134
"analytics/scripts/page.js" ,
@@ -141,7 +138,6 @@ def get(self, *args, **kwargs):
141
138
"protocol" : protocol ,
142
139
"heartbeat_frequency" : heartbeat_frequency ,
143
140
"script_inject" : self .get_script_inject (),
144
- "dnt" : dnt and service .respect_dnt ,
145
141
}
146
142
),
147
143
content_type = "application/javascript" ,
@@ -163,7 +159,7 @@ def post(self, *args, **kwargs):
163
159
def get_script_inject (self ):
164
160
service_uuid = self .kwargs .get ("service_uuid" )
165
161
script_inject = cache .get (f"script_inject_{ service_uuid } " )
166
- if script_inject is None :
162
+ if script_inject == None :
167
163
service = Service .objects .get (uuid = service_uuid )
168
164
script_inject = service .script_inject
169
165
cache .set (f"script_inject_{ service_uuid } " , script_inject , timeout = 3600 )
0 commit comments