Esempio n. 1
0
 def to(self, task, status):
     if task.status == 'NEW' and status == 'READY':
         if task.price == 0:
             raise NotPricing()
         task.start_time = utils.now()
         task.ready_time = utils.now()
     else:
         raise BadRequest
Esempio n. 2
0
 def to(self, task, status):
     if task.status == 'NEW' and status == 'READY':
         if task.price == 0:
             raise NotPricing()
         task.start_time = utils.now()
         task.ready_time = utils.now()
     else:
         raise BadRequest
Esempio n. 3
0
 def pricing(self, price):
     if self.status == 'NEW':
         self.price = price
         self.status = 'READY'
         self.start_time = utils.now()
         db.session.commit()
     else:
         raise BadRequest()
Esempio n. 4
0
 def to(self, task, status):
     if task.status == 'PROGRESS' and (status == 'READY' or status == 'DONE'):
         task.append_timeslot(
             TimeSlot(task.start_time, (utils.now() - task.start_time).total_seconds(), current_user, partner=task.partner))
         task.partner = None
         task.owner = None
     else:
         raise BadRequest
Esempio n. 5
0
 def pricing(self, price):
     if self.status == 'NEW':
         self.price = price
         self.status = 'READY'
         self.start_time = utils.now()
         db.session.commit()
     else:
         raise BadRequest()
Esempio n. 6
0
 def estimating(self, estimate):
     if self.status == 'READY':
         self.estimate = estimate
         self.status = 'PROGRESS'
         self.start_time = utils.now()
         self.owner = current_user
         db.session.commit()
     else:
         raise BadRequest()
Esempio n. 7
0
 def leave(self, tid):
     task = Task.query.get_or_404(tid)
     task.partner = None
     current_time = utils.now()
     task.append_timeslot(
         TimeSlot(task.start_time, (current_time - task.start_time).total_seconds(), task.owner, partner=self))
     task.start_time = current_time
     db.session.commit()
     return task
Esempio n. 8
0
 def estimating(self, estimate):
     if self.status == 'READY':
         self.estimate = estimate
         self.status = 'PROGRESS'
         self.start_time = utils.now()
         self.owner = current_user
         db.session.commit()
     else:
         raise BadRequest()
Esempio n. 9
0
def zeroing():
    begin = utils.now().replace(hour=0, minute=0, second=0, microsecond=0)
    tasks = Task.query.filter(Task.start_time > utils.get_current_monday(), Task.start_time < utils.now())
    burnings = {}
    for task in tasks:
        if task.status == 'PROGRESS':
            task.status = 'READY'
            end_time = utils.now()
            if end_time.hour > 18:
                end_time = end_time.replace(hour=18, minute=0, second=0)
            task.time_slots.append(TimeSlot(task.start_time, (end_time - task.start_time).total_seconds(), task.owner, partner=task.partner))
            task.owner = None
            task.partner = None
        burning = burnings.setdefault(task.team.id, Burning(task.team, begin))
        burning.add(task)

    for key, item in burnings.iteritems():
        db.session.add(item)
    db.session.commit()
Esempio n. 10
0
 def join(self, tid):
     self.check_progress()
     task = Task.query.get_or_404(tid)
     task.partner = self
     current_time = utils.now()
     print current_time
     task.append_timeslot(TimeSlot(task.start_time, (current_time - task.start_time).total_seconds(), task.owner))
     task.start_time = current_time
     db.session.commit()
     return task
Esempio n. 11
0
    def to(self, task, status):
        if task.status == 'READY' and (status == 'PROGRESS' or status == 'NEW'):
            if status == 'PROGRESS':
                current_user.check_progress()
                if task.estimate == 0:
                    raise NotEstimate()

                task.start_time = utils.now()
                task.owner = current_user
        else:
            raise BadRequest
Esempio n. 12
0
 def to(self, task, status):
     if task.status == 'PROGRESS' and (status == 'READY'
                                       or status == 'DONE'):
         task.append_timeslot(
             TimeSlot(task.start_time,
                      (utils.now() - task.start_time).total_seconds(),
                      current_user,
                      partner=task.partner))
         task.partner = None
         task.owner = None
     else:
         raise BadRequest
Esempio n. 13
0
 def leave(self, tid):
     task = Task.query.get_or_404(tid)
     task.partner = None
     current_time = utils.now()
     task.append_timeslot(
         TimeSlot(task.start_time,
                  (current_time - task.start_time).total_seconds(),
                  task.owner,
                  partner=self))
     task.start_time = current_time
     db.session.commit()
     return task
Esempio n. 14
0
    def to(self, task, status):
        if task.status == 'READY' and (status == 'PROGRESS'
                                       or status == 'NEW'):
            if status == 'PROGRESS':
                current_user.check_progress()
                if task.estimate == 0:
                    raise NotEstimate()

                task.start_time = utils.now()
                task.owner = current_user
        else:
            raise BadRequest
Esempio n. 15
0
 def join(self, tid):
     self.check_progress()
     task = Task.query.get_or_404(tid)
     task.partner = self
     current_time = utils.now()
     print current_time
     task.append_timeslot(
         TimeSlot(task.start_time,
                  (current_time - task.start_time).total_seconds(),
                  task.owner))
     task.start_time = current_time
     db.session.commit()
     return task
Esempio n. 16
0
def zeroing():
    begin = utils.now().replace(hour=0, minute=0, second=0, microsecond=0)
    tasks = Task.query.filter(Task.start_time > utils.get_current_monday(),
                              Task.start_time < utils.now())
    burnings = {}
    for task in tasks:
        if task.status == 'PROGRESS':
            task.status = 'READY'
            end_time = utils.now()
            if end_time.hour > 18:
                end_time = end_time.replace(hour=18, minute=0, second=0)
            task.time_slots.append(
                TimeSlot(task.start_time,
                         (end_time - task.start_time).total_seconds(),
                         task.owner,
                         partner=task.partner))
            task.owner = None
            task.partner = None
        burning = burnings.setdefault(task.team.id, Burning(task.team, begin))
        burning.add(task)

    for key, item in burnings.iteritems():
        db.session.add(item)
    db.session.commit()