def get(self, person_id, date): """ Get time spents for given person and date. --- tags: - Persons parameters: - in: path name: person_id required: True schema: type: UUID example: a24a6ea4-ce75-4665-a070-57453082c25 - in: path name: date required: True schema: type: timestamp example: 2022-07-12 responses: 200: description: Time spents for given person and date 404: description: Wrong date format """ current_user = persons_service.get_current_user() if current_user["id"] != person_id: try: permissions.check_at_least_supervisor_permissions() except permissions.PermissionDenied: return [] try: return time_spents_service.get_time_spents(person_id, date) except WrongDateFormatException: abort(404)
def get(self, date): try: current_user = persons_service.get_current_user() return time_spents_service.get_time_spents(current_user["id"], date) except WrongDateFormatException: abort(404)
def test_get_time_spents(self): time_spents = time_spents_service.get_time_spents( self.person_id, "2018-06-04") duration = 0 for time_spent in time_spents: duration += time_spent["duration"] self.assertEqual(len(time_spents), 2) self.assertEqual(duration, 800)
def get(self, person_id, date): permissions.check_admin_permissions() try: return time_spents_service.get_time_spents(person_id, date) except WrongDateFormatException: abort(404)
def get(self, person_id, date): try: return time_spents_service.get_time_spents(person_id, date) except WrongDateFormatException: abort(404)