Commit 7f7a3c154c81b4e8a44a1bc5e4da8a7b93f3540c
1 parent
e9a86f5a
Exists in
master
and in
5 other branches
Fixed issue with log_context dict in middleware [Issue:#231]
Showing
1 changed file
with
4 additions
and
7 deletions
Show diff stats
core/middleware.py
... | ... | @@ -17,17 +17,16 @@ class TimeSpentMiddleware(object): |
17 | 17 | |
18 | 18 | date_time_click = datetime.strptime(request.session.get('time_spent'), "%Y-%m-%d %H:%M:%S.%f") |
19 | 19 | _now = datetime.now() |
20 | - | |
20 | + | |
21 | 21 | time_spent = _now - date_time_click |
22 | - | |
22 | + | |
23 | 23 | secs = time_spent.total_seconds() |
24 | 24 | hours = int(secs / 3600) |
25 | 25 | minutes = int(secs / 60) % 60 |
26 | 26 | secs = secs % 60 |
27 | 27 | |
28 | - print(type(log.context) == 'str') | |
29 | 28 | |
30 | - if type(log.context) == 'dist': | |
29 | + if type(log.context) == dict: | |
31 | 30 | log_context = log.context |
32 | 31 | else: |
33 | 32 | log_context = json.loads(log.context) |
... | ... | @@ -38,11 +37,9 @@ class TimeSpentMiddleware(object): |
38 | 37 | time['seconds'] = secs |
39 | 38 | |
40 | 39 | log_context['time_spent'] = time |
41 | - | |
40 | + | |
42 | 41 | log.context = log_context |
43 | 42 | |
44 | 43 | log.save() |
45 | 44 | |
46 | 45 | request.session['log_id'] = None |
47 | - | |
48 | - | ... | ... |