Changeset 40:5d592e2950a1 in stamper


Ignore:
Timestamp:
Aug 12, 2014, 11:33:10 PM (6 years ago)
Author:
Borja Lopez <borja@…>
Branch:
default
Phase:
public
Message:

Added customer filtering support to the timeline feature:

  • Get the timeline for the customer customA for the last week:

stamps -t customA 1w

  • Get the timeline for the customer customA for august, 2013:

stamps -t customA 2013-08-01--2013-09-01

  • Get all timeline for customer customA:

stamps -t customA

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • bin/stamps

    r38 r40  
    3939    # Call the proper methods, based on the given parameters
    4040    if args.timeline:
    41         s.timeline(args.filter)
     41        s.timeline(args.customer, args.filter)
    4242    elif args.delete:
    4343        s.remove_stamps(args.delete)
  • stamper/stamper.py

    r39 r40  
    237237        return details, totals, total_customer
    238238
    239     def timeline(self, stamp_filter=None):
     239    def timeline(self, customer=None, stamp_filter=None):
    240240        filter_from, filter_to = self.validate_filter(stamp_filter)
    241241        for stamp in self.stamps:
    242             customer = stamp['customer']
    243242            start = datetime.strptime(stamp['start'], DATETIME_FORMAT)
    244243            start_day = start.strftime('%Y-%m-%d')
     
    251250                # similar for the end date
    252251                continue
     252
    253253            if not stamp['customer']:
    254                 print(stamp['start'] + ' start')
     254                if customer is None:
     255                    print(stamp['start'] + ' start')
    255256            else:
     257                if customer and customer != stamp['customer']:
     258                    continue
     259                if customer:
     260                    print(stamp['start'] + ' start')
    256261                print(' '.join([stamp['end'],
    257262                                stamp['customer'],
Note: See TracChangeset for help on using the changeset viewer.