Commit 4e78bf14eb80fe521f6d66c821b4709b9f7dcdef
1 parent
45be92ec
Exists in
master
and in
3 other branches
Fixing issue in log middleware
Showing
1 changed file
with
10 additions
and
9 deletions
Show diff stats
log/middleware.py
@@ -32,16 +32,17 @@ class TimeSpentMiddleware(object): | @@ -32,16 +32,17 @@ class TimeSpentMiddleware(object): | ||
32 | 32 | ||
33 | request.session['log_id'] = None | 33 | request.session['log_id'] = None |
34 | 34 | ||
35 | - oppened_logs = Log.objects.filter(user = request.user, context__contains={'timestamp_end': '-1'}) | 35 | + if request.user.is_authenticated: |
36 | + oppened_logs = Log.objects.filter(user = request.user, context__contains={'timestamp_end': '-1'}) | ||
36 | 37 | ||
37 | - for op_log in oppened_logs: | ||
38 | - if type(op_log.context) == dict: | ||
39 | - log_context = op_log.context | ||
40 | - else: | ||
41 | - log_context = json.loads(op_log.context) | 38 | + for op_log in oppened_logs: |
39 | + if type(op_log.context) == dict: | ||
40 | + log_context = op_log.context | ||
41 | + else: | ||
42 | + log_context = json.loads(op_log.context) | ||
42 | 43 | ||
43 | - log_context['timestamp_end'] = str(int(time.time())) | 44 | + log_context['timestamp_end'] = str(int(time.time())) |
44 | 45 | ||
45 | - op_log.context = log_context | 46 | + op_log.context = log_context |
46 | 47 | ||
47 | - op_log.save() | ||
48 | \ No newline at end of file | 48 | \ No newline at end of file |
49 | + op_log.save() | ||
49 | \ No newline at end of file | 50 | \ No newline at end of file |