Colin Copeland avatar Colin Copeland committed c80ce14 Merge

merge default into stable

Comments (0)

Files changed (5)

 
 setup(
     name='django-timepiece',
-    version='0.1.0',
+    version='0.2.0',
     author='Caktus Consulting Group',
     author_email='solutions@caktusgroup.com',
     packages=find_packages(),

timepiece/management/commands/check_entries.py

                 if args and self.verbosity >= 1 or self.verbosity >= 2:
                     self.show_name(entry_a.user)
                     user = entry_a.user
-            #Check against entries after this one
-            for index_b in range(index_a, len(entries)):
-                entry_b = entries[index_b]
-                if entry_a.check_overlap(entry_b):
-                    user_total_overlaps += 1
-                    self.show_overlap(entry_a, entry_b)
+            if entry_a.is_overlapping():
+                user_total_overlaps += 1
+                self.show_overlap(entry_a)
+                
+#Removed until check_overlap is fixed
+#            for index_b in range(index_a, len(entries)):
+#                entry_b = entries[index_b]
+#                if entry_a.is_overlapping():
+#                if entry_a.check_overlap(entry_b):
+#                    user_total_overlaps += 1            
+#                    self.show_overlap(entry_a, entry_b)
+                    
         if user_total_overlaps and user and self.verbosity >= 1:
             overlap_data = {
                 'first': user.first_name,
         self.stdout.write('Checking %s %s...\n' % \
         (person.first_name, person.last_name))
 
-    def show_overlap(self, entry_a, entry_b):
+    def show_overlap(self, entry_a, entry_b=None):
         def make_output_data(entry):
             return{
                 'first_name': entry.user.first_name,
                 'project': entry.project
             }
         data_a = make_output_data(entry_a)
-        data_b = make_output_data(entry_b)
-        output = 'Entry %(entry)d for %(first_name)s %(last_name)s from ' \
-        % data_a + '%(start_time)s to %(end_time)s on %(project)s overlaps ' \
-        % data_a + 'entry %(entry)d from %(start_time)s to %(end_time)s on ' \
-        % data_b + '%(project)s.' % data_b
+        if entry_b:
+            data_b = make_output_data(entry_b)
+            output = 'Entry %(entry)d for %(first_name)s %(last_name)s from ' \
+            % data_a + '%(start_time)s to %(end_time)s on %(project)s overlaps ' \
+            % data_a + 'entry %(entry)d from %(start_time)s to %(end_time)s on ' \
+            % data_b + '%(project)s.' % data_b
+        else:
+            output = 'Entry %(entry)d for %(first_name)s %(last_name)s from ' \
+            % data_a + '%(start_time)s to %(end_time)s on %(project)s overlaps ' \
+            % data_a + 'with another entry.'
         self.stdout.write(output + '\n')

timepiece/models.py

         Given two entries, return True if they overlap, otherwise return False
         """
         entry_a = self
-        #if entries are open, consider them closed right now
+        #if entries are open, consider them to be closed right now
         if not entry_a.end_time:
             entry_a.end_time = datetime.datetime.now()
         if not entry_b.end_time:
             entry_b.end_time = datetime.datetime.now()
-        #Check the two entries against each other
-        if entry_a.start_time > entry_b.start_time \
-        and entry_a.start_time < entry_b.end_time or \
-        entry_a.end_time > entry_b.start_time \
-        and entry_a.end_time < entry_b.end_time or \
-        entry_a.start_time < entry_b.start_time \
-        and entry_a.end_time > entry_b.end_time:
-            return True
-        return False
+        #Check the two entries against each other        
+        start_is_inside = entry_a.start_time > entry_b.start_time \
+            and entry_a.start_time < entry_b.end_time 
+        end_is_inside = entry_a.end_time > entry_b.start_time \
+            and entry_a.end_time < entry_b.end_time        
+        b_is_inside = entry_a.start_time < entry_b.start_time \
+            and entry_a.end_time > entry_b.end_time
+        overlap = start_is_inside or end_is_inside or b_is_inside
+        return overlap
 
     def is_overlapping(self):
         if self.start_time and self.end_time:

timepiece/tests/__init__.py.orig

+from timepiece.tests.timesheet import *
+from timepiece.tests.periods import *
+from timepiece.tests.payroll import *
+from timepiece.tests.projection import *
+from timepiece.tests.projects import *
+from timepiece.tests.user_settings import *
+#Test does not reflect current state of the code. Import here when fixed
+from timepiece.tests.management import *
+

timepiece/tests/management.py

 from timepiece import forms as timepiece_forms
 from timepiece.management.commands import check_entries
 
-possible_args = [
-    '--thisweek', 
-    '--thismonth', 
-    '-y', '--thisyear', 
-    '-a', '--all', '--forever',
-    '-d', '--days',
-]
 
 class CheckEntries(TimepieceDataTestCase):
     def setUp(self):
         self.create_entry(self.default_data)
 #        check_1 = self.check('first1', verbosity=2)
 #        check_2 = self.check('first2', verbosity=2)
-        check_1_2 = self.check('first1', 'first2', verbosity=2)
+        bars = check_1_2 = self.check('first1', 'first2', verbosity=2)
+        self.show_overlap(bars)
         foos = self.get_overlap(check_1_2)
+
 #        print foos[0].get('entry', '')
 #        print check_1_2['out']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.