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 +17,16 @@ class TimeSpentMiddleware(object): | ||
17 | 17 | ||
18 | date_time_click = datetime.strptime(request.session.get('time_spent'), "%Y-%m-%d %H:%M:%S.%f") | 18 | date_time_click = datetime.strptime(request.session.get('time_spent'), "%Y-%m-%d %H:%M:%S.%f") |
19 | _now = datetime.now() | 19 | _now = datetime.now() |
20 | - | 20 | + |
21 | time_spent = _now - date_time_click | 21 | time_spent = _now - date_time_click |
22 | - | 22 | + |
23 | secs = time_spent.total_seconds() | 23 | secs = time_spent.total_seconds() |
24 | hours = int(secs / 3600) | 24 | hours = int(secs / 3600) |
25 | minutes = int(secs / 60) % 60 | 25 | minutes = int(secs / 60) % 60 |
26 | secs = secs % 60 | 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 | log_context = log.context | 30 | log_context = log.context |
32 | else: | 31 | else: |
33 | log_context = json.loads(log.context) | 32 | log_context = json.loads(log.context) |
@@ -38,11 +37,9 @@ class TimeSpentMiddleware(object): | @@ -38,11 +37,9 @@ class TimeSpentMiddleware(object): | ||
38 | time['seconds'] = secs | 37 | time['seconds'] = secs |
39 | 38 | ||
40 | log_context['time_spent'] = time | 39 | log_context['time_spent'] = time |
41 | - | 40 | + |
42 | log.context = log_context | 41 | log.context = log_context |
43 | 42 | ||
44 | log.save() | 43 | log.save() |
45 | 44 | ||
46 | request.session['log_id'] = None | 45 | request.session['log_id'] = None |
47 | - | ||
48 | - |