コード例 #1
0
 def tasks_with_gaps(self):
     all_tasks = []
     all_tasks.append(ProjectTodoItem(title='Tuesday', due_date=datetime(2019, 9, 24, 16)))
     all_tasks.append(ProjectTodoItem(title='THU', due_date=datetime(2019, 9, 26)))
     all_tasks.append(ProjectTodoItem(title='FRI', due_date=datetime(2019, 9, 27)))
     all_tasks.append(ProjectTodoItem(title='Saturday', due_date=datetime(2019, 9, 28, 12)))
     all_tasks.append(ProjectTodoItem(title='Second Saturday', due_date=datetime(2019, 9, 28, 13)))
     return all_tasks
コード例 #2
0
 def calc_karma(self, profile, calc_date):
     completed_tasks = ProjectTodoItem.get_completed_tasks_by_user_by_date(profile, calc_date)
     task_points = completed_tasks.count()
     habit_points = self.calc_habit_points(profile, calc_date)
     journal_points = self.calc_journal_points(profile, calc_date)
     total_points = task_points + habit_points + journal_points
     KarmaPoints.store_points(profile, calc_date, task_points, habit_points, journal_points, total_points)
コード例 #3
0
 def get(self, request):
     profile = self.my_profile
     week_start = calc_week_start(profile.utc_offset)
     personal_tasks = ProjectTodoItem.get_personal_tasks_for_stats(
         profile, week_start)
     results = [task.to_dict() for task in personal_tasks]
     return JsonResponse({'tasks': results})
コード例 #4
0
    def put(self, request, item_id):
        data = self.parse_json_body()
        track_minutes = int(data['trackMinutes'])
        track_hours = int(data['trackHours'])
        total_minutes = track_minutes + 60 * track_hours
        track_date = parse(data['trackDate']).date()
        project_id = data.get('projectId', None)
        if project_id == '0':
            project_id = None

        if track_date == self.profile_today:
            ProjectTodoItem.update_minutes_worked(item_id, total_minutes)
        else:
            TrackWorkedDay.update_track(self.my_profile.id, project_id,
                                        item_id, track_date, total_minutes)
        return JsonResponse({})
コード例 #5
0
 def post(self, request, item_id):
     data = self.parse_json_body()
     minutes_worked = int(data['manualMinutes'])
     hours_worked = int(data['manualHours'])
     total_minutes = minutes_worked + 60 * hours_worked
     manual_date = parse(data['manualDate']).date()
     project_id = data['manualProjectId'] or None
     task_list_id = data['manualTaskListId'] or None
     if manual_date == self.profile_today:
         ProjectTodoItem.update_minutes_worked(item_id, total_minutes)
     else:
         if project_id == '0':
             TrackWorkedDay.add_manual(self.my_profile.id, item_id,
                                       manual_date, total_minutes)
         else:
             TrackWorkedDay.add_manual(self.my_profile.id, item_id,
                                       manual_date, total_minutes,
                                       project_id, task_list_id)
     ProjectTodoItem.set_in_progress(item_id)
     return JsonResponse({})
コード例 #6
0
 def create_tasks_full(self):
     all_tasks = []
     all_tasks.append(ProjectTodoItem(title='MOnday', due_date=datetime(2019, 9, 23)))
     all_tasks.append(ProjectTodoItem(title='Tuesday', due_date=datetime(2019, 9, 24)))
     all_tasks.append(ProjectTodoItem(title='Wed', due_date=datetime(2019, 9, 25)))
     all_tasks.append(ProjectTodoItem(title='THU', due_date=datetime(2019, 9, 26)))
     all_tasks.append(ProjectTodoItem(title='FRI', due_date=datetime(2019, 9, 27)))
     all_tasks.append(ProjectTodoItem(title='Sat', due_date=datetime(2019, 9, 28)))
     all_tasks.append(ProjectTodoItem(title='Sun', due_date=datetime(2019, 9, 29, 13, 30)))
     return all_tasks
コード例 #7
0
 def store_personal_tasks(self, profile):
     personal_tasks_worked = ProjectTodoItem.personal_tasks_worked_today(
         profile)
     profile_now = user_time_now(profile.utc_offset)
     profile_yesterday = (profile_now - datetime.timedelta(days=1)).date()
     for task in personal_tasks_worked:
         record = TrackWorkedDay(user=profile,
                                 task=task,
                                 track_date=profile_yesterday,
                                 minutes_worked=task.minutes_worked_today)
         record.save()
         task.minutes_worked_today = 0
         task.save()
コード例 #8
0
 def post(self, request, item_id):
     data = self.parse_json_body()
     minutes_worked = data['minutes_worked']
     ProjectTodoItem.update_minutes_worked(item_id, minutes_worked)
     return JsonResponse({})