diff --git a/log/middleware.py b/log/middleware.py index 92df8af..66cbfb3 100644 --- a/log/middleware.py +++ b/log/middleware.py @@ -14,35 +14,36 @@ class TimeSpentMiddleware(object): if not 'admin' in app_names: if not request.is_ajax(): - log_id = request.session.get('log_id', None) + if not request.path.startswith('/uploads/'): + log_id = request.session.get('log_id', None) - if not log_id is None: - log = get_object_or_404(Log, id = log_id) + if not log_id is None: + log = get_object_or_404(Log, id = log_id) - if type(log.context) == dict: - log_context = log.context - else: - log_context = json.loads(log.context) + if type(log.context) == dict: + log_context = log.context + else: + log_context = json.loads(log.context) - log_context['timestamp_end'] = str(int(time.time())) + log_context['timestamp_end'] = str(int(time.time())) - log.context = log_context + log.context = log_context - log.save() + log.save() - request.session['log_id'] = None + request.session['log_id'] = None - if request.user.is_authenticated: - oppened_logs = Log.objects.filter(user = request.user, context__contains={'timestamp_end': '-1'}) + if request.user.is_authenticated: + oppened_logs = Log.objects.filter(user = request.user, context__contains={'timestamp_end': '-1'}) - for op_log in oppened_logs: - if type(op_log.context) == dict: - log_context = op_log.context - else: - log_context = json.loads(op_log.context) + for op_log in oppened_logs: + if type(op_log.context) == dict: + log_context = op_log.context + else: + log_context = json.loads(op_log.context) - log_context['timestamp_end'] = str(int(time.time())) + log_context['timestamp_end'] = str(int(time.time())) - op_log.context = log_context + op_log.context = log_context - op_log.save() \ No newline at end of file + op_log.save() \ No newline at end of file diff --git a/subjects/templates/subjects/subject_card.html b/subjects/templates/subjects/subject_card.html index d82229b..f0b55df 100644 --- a/subjects/templates/subjects/subject_card.html +++ b/subjects/templates/subjects/subject_card.html @@ -42,6 +42,9 @@