Example #1
0
 def get(self, year, month):
     if permissions.has_admin_permissions():
         return time_spents_service.get_day_table(year, month)
     else:
         current_user = persons_service.get_current_user()
         return time_spents_service.get_day_table(
             year, month, person_id=current_user["id"])
Example #2
0
 def get(self, year, month):
     """
     Return a table giving time spent by user and by day for given year and month.
     ---
     tags:
     - Persons
     parameters:
       - in: path
         name: year
         required: True
         schema:
             type: integer
             example: 2022
       - in: path
         name: month
         required: True
         schema:
             type: integer
             example: 07 (from 01 to 12)
     responses:
         200:
             description: Table giving time spent by user and by day for given year and month
     """
     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_day_table(
         year, month, person_id=person_id, project_id=project_id
     )
Example #3
0
 def test_get_day_table(self):
     with app.app_context():
         day_table = time_spents_service.get_day_table("2018", "06")
         self.assertEqual(day_table["3"][self.person_id], 600)
         self.assertEqual(day_table["4"][self.person_id], 800)
         self.assertEqual(day_table["3"][self.user_id], 600)
         self.assertTrue("1" not in day_table)
Example #4
0
 def get(self, year, month):
     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_day_table(
         year, month, person_id=person_id, project_id=project_id
     )
Example #5
0
 def get(self, year, month):
     permissions.check_admin_permissions()
     return time_spents_service.get_day_table(year, month)