def get(self, year): if permissions.has_admin_permissions(): return time_spents_service.get_month_table(year) else: current_user = persons_service.get_current_user() return time_spents_service.get_month_table( year, person_id=current_user["id"])
def get(self, year): project_id = self.get_project_id() person_id = None if not permissions.has_admin_permissions(): person_id = persons_service.get_current_user()["id"] return time_spents_service.get_month_table( year, person_id=person_id, project_id=project_id )
def test_get_month_table_with_different_projects(self): with app.app_context(): self.generate_fixture_project_standard() self.generate_fixture_asset_standard() self.generate_fixture_task_standard() tasks_service.create_or_update_time_spent(self.task_standard.id, self.person_id, "2018-05-03", 600) month_table = time_spents_service.get_month_table( "2018", project_id=self.project_standard.id) self.assertEqual(month_table["5"][self.person_id], 600)
def get(self, year): """ Return a table giving time spent by user and by month for given year. --- tags: - Persons parameters: - in: path name: year required: True schema: type: integer example: 2022 responses: 200: description: Table giving time spent by user and by month for given year """ project_id = self.get_project_id() person_id = None if not permissions.has_admin_permissions(): person_id = persons_service.get_current_user()["id"] return time_spents_service.get_month_table( year, person_id=person_id, project_id=project_id )
def test_get_month_table(self): month_table = time_spents_service.get_month_table("2018") self.assertEqual(month_table["6"][self.person_id], 1400) self.assertEqual(month_table["6"][self.user_id], 600) self.assertTrue("1" not in month_table)
def get(self, year): permissions.check_admin_permissions() return time_spents_service.get_month_table(year)