Commits

George Notaras  committed 9efd3f7

Timeframe browser now supports browsing custom timeframe.

  • Participants
  • Parent commits b11bd15

Comments (0)

Files changed (1)

File src/sysscope/views.py

         backward = request.POST.get('backward', None)
         forward = request.POST.get('forward', None)
     
-        if selected_timeframe:
+        if not selected_timeframe:
+            selected_timeframe = timeframe
             
-            # Check value
-            if selected_timeframe not in TIME_FRAME_POOL.keys():
-                try:
-                    int(selected_timeframe)
-                except ValueError:
-                    return HttpResponseBadRequest
+        # Check value
+        if selected_timeframe not in TIME_FRAME_POOL.keys():
+            try:
+                int(selected_timeframe)
+            except ValueError:
+                return HttpResponseBadRequest
+        
+        timestamp_current = resolve_time(start)
+        timestamp_from_selection = resolve_time(selected_timeframe)
             
-            timestamp_current = resolve_time(start)
-            timestamp_from_selection = resolve_time(selected_timeframe)
-                
-            if backward:
-                new_start = timestamp_current + timestamp_from_selection
+        if backward:
+            new_start = timestamp_current + timestamp_from_selection
+            start = '-%d' % new_start
+            timeframe = selected_timeframe
+        
+        elif forward:
+            new_start = timestamp_current - timestamp_from_selection
+            if new_start > 0:
                 start = '-%d' % new_start
                 timeframe = selected_timeframe
             
-            elif forward:
-                new_start = timestamp_current - timestamp_from_selection
-                if new_start > 0:
-                    start = '-%d' % new_start
-                    timeframe = selected_timeframe
-                
-            return HttpResponseRedirect(reverse('section', kwargs={
-                'section': section,
-                'start': start,
-                'timeframe': timeframe,
-                }))
+        return HttpResponseRedirect(reverse('section', kwargs={
+            'section': section,
+            'start': start,
+            'timeframe': timeframe,
+            }))
 
     # Find section object by its canonical name
     for section_obj in CFG.sections_ordered: