Commits

Caleb Smith committed c8723c8 Merge

merge

Comments (0)

Files changed (2)

timepiece/models.py

             if entry.end_time: 
                 if entry.start_time.date() == start.date() and entry.end_time.date() == end.date():
                     entry_data['start_time'] = entry.start_time.strftime('%H:%M:%S')
-                    entry_data['end_time'] = entry.end_time.strftime('%H:%M:%S')
-                
+                    entry_data['end_time'] = entry.end_time.strftime('%H:%M:%S')                
                 output = 'Start time overlaps with: %(project)s - %(activity)s' \
                          ' - from %(start_time)s to %(end_time)s' % entry_data
-
                 raise ValidationError(output)
             
         if end <= start:

timepiece/views.py

                 id = entry.id
             )
             #clock_out every open project one second before the last to avoid overlap  
-            for sec_bump, active_entry in enumerate(my_active_entries):        
+            for sec_bump, active_entry in enumerate(my_active_entries):
                 active_entry.unpause()
                 active_entry.end_time = entry.start_time - datetime.timedelta(seconds = sec_bump + 1)
-                active_entry.save()                
+                #If the entry is less than one second old, it's times are wrong
+                if active_entry.start_time > active_entry.end_time:
+                    active_entry.delete()
+                else:
+                    active_entry.save()
             
             request.user.message_set.create(message='You have clocked into %s' % entry.project)
             return HttpResponseRedirect(reverse('timepiece-entries'))