def login_check(self, *args):
    # this methd checks if the login and psswd entered are correct

        # we get the login & psswrd entered
        user_login = self.login_box.text
        user_password = self.password_box.text

######################### Beginning of the CSV Method #########################

        # DB CONNECTION
        db = MyDB()

        # we get the users dtf
        users_dataframe = db.get_dataframe(objct = Userd)

        # We check that the login and the psswrd match
        temp_user = users_dataframe[users_dataframe.user_login == user_login]

        if not temp_user.empty:
            # print(temp_user.user_password)
            if temp_user.user_password.item() == user_password:
                # we save the user log in the singleton User()
                user_logged = User(
                                login = user_login,
                                index = temp_user.index.item()
                                  )
                # And launch the on_right_id method
                self.dispatch('on_right_id')
                # and stop the method
                return
        # if they are wrong
        # launch the on_wrong_id method
        self.dispatch('on_wrong_id')
    def init_dataframes(self):
######################### Beginning of the CSV Method #########################
        # init of the dtb
        # DB CONNECTION
        db = MyDB()

        # we get the id of the logged user
        user_id_logged = User().index

        # we get the modules dtf
        modules_dataframe = db.get_dataframe(objct = Module)

        # we get the tools dtf
        tools_dataframe = db.get_dataframe(objct = Tool)

        # we get the userstools dtf
        userstools_dataframe = db.get_dataframe(objct = UserTool)

        # we get the id of the tools available for the user
        tools_id_available = userstools_dataframe[
                            userstools_dataframe.index == user_id_logged
                                                 ].tool_index

        # we get the tools available
        self.tools_dataframe = tools_dataframe[
                            tools_dataframe.index.isin(tools_id_available)
                                              ]

        # we get the modules for the tools
        self.modules_dataframe = modules_dataframe[
                modules_dataframe.index.isin(self.tools_dataframe.module_index)
                                                  ]
Exemple #3
0
 def __init__(self, **kwargs):
     super(ExerciseTool, self).__init__(**kwargs)
     #init of the db
     self.mydb = MyDB()
     # init the dtf
     self.init_dtf()
     # gui building
     self.build_GUI()
Exemple #4
0
    def __init__(self, first_day = "2015-09-01",
                        last_day = "2015-11-30", **kwargs):
        super(GantTool, self).__init__(**kwargs)

        # this var handles the way the scrolling works between the different
        # scrolls
        # the use of the "being_scrolled" var prevent from a loop between
        # the update_from_scroll method of all the scrollview to occur
        self.being_scrolled = False

        # We build the GUI
        self.build_GUI()

        # we init the height of row displayed
        self.set_row_height(50)

        # we init the list of the days displayed
        self.update_days_dataframe(
                        new_days_list = build_list_of_days(
                                                        first_day=first_day,
                                                        last_day = last_day
                                                          ),
                        new_day_width = 100,
                        init = True
                                    )
        # print(self.days_dataframe)

        #init of the db
        self.mydb = MyDB()

        # we get the task groups
        self.taskgroups_dataframe = self.mydb.get_dataframe(objct = TaskGroup)

        # we get the ressource groups
        self.ressourcegroups_dataframe = self.mydb.get_dataframe(
                                                        objct = RessourceGroup
                                                                )

        # we get the ressources
        self.ressources_dataframe = self.mydb.get_dataframe(objct = Ressource)
        print(self.ressources_dataframe )
        # and we add each ressource in the dataframe
        for ix in self.ressources_dataframe.index:
            self.add_ressource(self.ressources_dataframe.ix[ix], init = True)

        self.tasks_dataframe = self.mydb.get_dataframe(objct = Task)
        # print(self.tasks_dataframe)
        # and we add each task in the dataframe
        for ix in self.tasks_dataframe.index:
            self.add_task(self.tasks_dataframe.ix[ix], init = True)
Exemple #5
0
    def __init__(self, **kwargs):
        super(NoteTool, self).__init__(**kwargs)
        #init of the db
        self.mydb = MyDB()
        # we get the note lists
        self.notelists_dataframe = self.mydb.get_dataframe(objct = NoteList)
        # we build the notelists items
        self.init_notelistitems()

        # we get the notes
        self.notes_dataframe = self.mydb.get_dataframe(objct = Note)
        # we build the note items
        self.init_noteitems()

        self.moving_noteitem = None
        self.moving_notelistitem = None
Exemple #6
0
class GantTool(FloatLayout):

##################### Constructeur #####################
    def __init__(self, first_day = "2015-09-01",
                        last_day = "2015-11-30", **kwargs):
        super(GantTool, self).__init__(**kwargs)

        # this var handles the way the scrolling works between the different
        # scrolls
        # the use of the "being_scrolled" var prevent from a loop between
        # the update_from_scroll method of all the scrollview to occur
        self.being_scrolled = False

        # We build the GUI
        self.build_GUI()

        # we init the height of row displayed
        self.set_row_height(50)

        # we init the list of the days displayed
        self.update_days_dataframe(
                        new_days_list = build_list_of_days(
                                                        first_day=first_day,
                                                        last_day = last_day
                                                          ),
                        new_day_width = 100,
                        init = True
                                    )
        # print(self.days_dataframe)

        #init of the db
        self.mydb = MyDB()

        # we get the task groups
        self.taskgroups_dataframe = self.mydb.get_dataframe(objct = TaskGroup)

        # we get the ressource groups
        self.ressourcegroups_dataframe = self.mydb.get_dataframe(
                                                        objct = RessourceGroup
                                                                )

        # we get the ressources
        self.ressources_dataframe = self.mydb.get_dataframe(objct = Ressource)
        print(self.ressources_dataframe )
        # and we add each ressource in the dataframe
        for ix in self.ressources_dataframe.index:
            self.add_ressource(self.ressources_dataframe.ix[ix], init = True)

        self.tasks_dataframe = self.mydb.get_dataframe(objct = Task)
        # print(self.tasks_dataframe)
        # and we add each task in the dataframe
        for ix in self.tasks_dataframe.index:
            self.add_task(self.tasks_dataframe.ix[ix], init = True)



    def update_days_dataframe(
                                self,
                                new_days_list = [],
                                new_day_width = 0,
                                init = False
                              ):
    # This method update the days_dataframe according to:
    #     a new day list if so
    #     a new day width if so
    # If the init attr is = True, it creates the objects
    # self.number_of_days and self.day_width before creating the dtf
    # Using the init without any new_day... will create an empty dtf

        # if it's an init we need to create the var
        if init == True:
            self.day_width = new_day_width
            self.number_of_days = len(new_days_list)
            self.init_days_dataframe(self.number_of_days)
            self.days_dataframe.date = new_days_list
            self.days_dataframe.absc = self.get_address_list(
                                number_of_days = self.number_of_days,
                                day_width = self.day_width
                                                            )
            self.calendar_scrollview.days_list_upd()
            self.gant_scrollview.days_list_upd()

        else:

            # If there is a new day_list then we need to update the dtf
            if new_days_list != []:
                # If there is a new day width then
                if new_day_width != 0:
                    self.day_width = new_day_width
                    # the number of days in the new days_list
                    new_number_of_days = len(days_list)
                    # If this number of days is != from the old number_of_days,
                    # we need to re-create a new dtf
                    if self.number_of_days != new_number_of_days:
                        self.number_of_days = new_number_of_days
                        self.init_days_dataframe(new_number_of_days)

                        self.days_dataframe.date = days_list
                        self.days_dataframe.absc = self.get_address_list(
                                        number_of_days = new_number_of_days,
                                        day_width = self.day_width
                                                    )

                        self.calendar_scrollview.days_list_upd()
                        self.gant_scrollview.days_list_upd()
                    # Else we dont need a new dtf, we can just replace values
                    # in the current one
                    else:
                        self.days_dataframe.date = days_list
                        self.days_dataframe.absc = self.get_address_list(
                                        number_of_days = new_number_of_days,
                                        day_width = self.day_width
                                                                    )
                        self.calendar_scrollview.days_list_upd()
                        self.gant_scrollview.days_list_upd()
                # If the day_widh is the same
                else:
                    # the number of days in the new days_list
                    new_number_of_days = len(new_days_list)
                    # If this number of days is != from the old number_of_days,
                    # we need to re-create a new dtf
                    if self.number_of_days != new_number_of_days:
                        self.number_of_days = new_number_of_days
                        self.init_days_dataframe(new_number_of_days)

                        self.days_dataframe.date = new_days_list
                        self.days_dataframe.absc = self.get_address_list(
                                        number_of_days = new_number_of_days,
                                        day_width = self.day_width
                                                                    )

                        self.calendar_scrollview.days_list_upd()
                        self.gant_scrollview.days_list_upd()
                    # if the number of day is the same AND the day width, we
                    # just need t update the dates list in the dtf
                    else:
                        self.days_dataframe.date = new_days_list

                        self.calendar_scrollview.days_list_upd()
                        self.gant_scrollview.days_list_upd()
            # If there is no new_day_list
            else:
                # If there is a new day width then we just need to update the
                # absc list in the dtf
                if new_day_width != 0:
                    self.day_width = new_day_width
                    self.days_dataframe.absc = self.get_address_list(
                                        number_of_days = self.number_of_days,
                                        day_width = self.day_width
                                                                )

                    self.calendar_scrollview.day_width_upd()
                    self.gant_scrollview.day_width_upd()

    def init_days_dataframe(self, number_of_days):
        self.days_dataframe = pd.DataFrame(index = range(number_of_days),
                    columns = ['date','absc'])



    def update_day_width_display(self):
        # We update the calendar accordingly
        self.calendar_scrollview.day_width = value
        # # We update the gant accordingly
        self.gant_scrollview.day_width = value


    def update_days_list_display(self, days_list):
        # We update the calendar accordingly
        self.calendar_scrollview.days_list_upd()
        # # We update the gant accordingly
        self.gant_scrollview.days_list_upd()



    def get_address_list(self, number_of_days, day_width):
        address_list = []
        for i in range(number_of_days):
            address_list.append(i * day_width)
        return address_list


    def set_row_height(self, value):
        # we save the width in a var
        self.row_height = value
        # # We update the calendar accordingly
        self.gant_scrollview.row_height_upd()
        # The height of the header is controled by the height of the gant


    def add_ressource(self, ressource, init = False):
        if init == False:
            # we add the ressource in the var only if we are not at the init
            # of the project
            self.ressources_dataframe.ix[ressource.name] = ressource
        # We update the header accordingly
        self.header_scrollview.add_ressource(ressource.name)
        # We update the gant accordingly
        self.gant_scrollview.add_ressource(ressource.name)


    def update_ressource(self, ressource):
        self.ressources_dataframe.ix[ressource.name] = ressource

        # We update the header accordingly
        self.header_scrollview.ressource_updated(ressource.name)
        # We update the gant accordingly
        self.gant_scrollview.ressource_updated(ressource.name)


    def add_task(self, task, init = False):
        if init == False:
            # we add the tasks in the var only if we are not at the init
            # of the project
            self.tasks_dataframe.ix[task.name] = task
        # We update the gant accordingly
        self.gant_scrollview.add_task(task.name)

    def add_taskgroup(self, taskgroup, init = False):
        if init == False:
            # we add the taskgroups in the var only if we are not at the init
            # of the project
            self.taskgroups_dataframe.ix[taskgroup.name] = taskgroup

    def add_ressourcegroup(self, ressourcegroup, init = False):
        if init == False:
            # we add the taskgroups in the var only if we are not at the init
            # of the project
            self.ressourcegroups_dataframe.ix[
                            ressourcegroup.name
                                             ] = ressourcegroup


    def delete_ressource(self, ressource_id = 1):
        self.ressources_dataframe = self.ressources_dataframe[
                            self.ressources_dataframe.index != ressource_id]
        self.header_scrollview.delete_ressource(ressource_id)
        self.gant_scrollview.delete_ressource(ressource_id)
        # need to delete the task inside!

    def delete_task(self, task_id):
        self.tasks_dataframe = self.tasks_dataframe[
                            self.tasks_dataframe.index != task_id]
        self.gant_scrollview.delete_task(task_id)

    def delete_all_ressources(self):
        self.header_scrollview.delete_all_ressources()
        self.gant_scrollview.delete_all_ressources()

    def delete_all_tasks(self):
        self.gant_scrollview.delete_all_tasks()


    def set_task_list(self):
        # self.gant_scrollview.task_list = task_list
        pass



    def met1(self):
        # This methode will be used to change the range of dates being
        # displayed
        # self.update_days_dataframe(new_days_list=
        #                     ['2015-09-01','2015-09-02','2015-09-03'])

        CP = RessourceGroup_Edit_Window(
                                title = "New RessourceGroup",
                                project = self,
                                size_hint = (None, None),
                                size = ("480dp", "400dp")
                                    )
        CP.open()


    def met2(self):
        # # This metode will be used to change the width of day columns
        # self.update_days_dataframe(new_day_width = self.day_width - 10)

        TEW = Task_Edit_Window(
                                title = "New Task",
                                project = self,
                                size_hint = (None, None),
                                size = (700, 350)
                                   )
        TEW.open()

    def new_task(self, ressource_id = 1):
        TEW = Task_Edit_Window(
                                title = "New Task",
                                project = self,
                                ressource_id = ressource_id,
                                size_hint = (None, None),
                                size = (700, 350)
                                   )
        TEW.open()

    def met3(self):

        REW = Ressource_Edit_Window(
                                title = "New Ressource",
                                project = self,
                                size_hint = (None, None),
                                size = (700, 200)
                                   )
        REW.open()



    def new_ressource(self):

        REW = Ressource_Edit_Window(
                                title = "New Ressource",
                                project = self,
                                size_hint = (None, None),
                                size = (700, 200)
                                   )
        REW.open()


    def met4(self):

        CP = TaskGroup_Edit_Window(
                                title = "New TaskGroup",
                                project = self,
                                size_hint = (None, None),
                                size = ("480dp", "400dp")
                                    )
        CP.open()

    def new_taskgroup(self):
        CP = TaskGroup_Edit_Window(
                                title = "New TaskGroup",
                                project = self,
                                size_hint = (None, None),
                                size = ("480dp", "400dp")
                                    )
        CP.open()


    def new_ressourcegroup(self):
        CP = RessourceGroup_Edit_Window(
                                title = "New RessourceGroup",
                                project = self,
                                size_hint = (None, None),
                                size = ("480dp", "400dp")
                                    )
        CP.open()

    def met5(self):
        from kivy.core.window import Window
        # Window.maximize()
        # Window.close()
        # Window.minimize()
        # Window.toggle_fullscreen()
        # if Window.borderless == True:
        #     Window.borderless = False
        # else:
        #     Window.borderless = True
        pass

    def build_GUI(self):
        # L'interface graphique du mdule
        # Elle affiche 3 principaux objets :

        # Un objet "calendar_scrollview" qui est la zone scrollable haute, dans
        # laquelle on interragit avec les dates.
        self.calendar_scrollview = CalendarHeaderScroll(
                                            project = self,
                                            pos_hint = {'x': 0.17,'y': .94},
                                            size_hint = (0.81, 0.04)
                                            )

        # Un objet "Gant_scrollview" qui est la zone scrollable centrale, dans
        # laquelle on interragit avec les tests.
        self.gant_scrollview = GantMainScroll(
                                            project = self,
                                            pos_hint = {'x': 0.17,'y': .02},
                                            size_hint = (0.81, 0.92)
                                            )

        # Un objet "header_scrollview" qui est la zone scrollable
        # gauche, dans laquelle on interragit avec les ressources.
        self.header_scrollview = HeaderScroll(
                                            project = self,
                                            pos_hint = {'x': 0.02,'y': .02},
                                            size_hint = (0.15, 0.92)
                                            )

        # we display these 3 objects
        self.add_widget(self.calendar_scrollview)
        self.add_widget(self.gant_scrollview)
        self.add_widget(self.header_scrollview)
Exemple #7
0
    def get_expense_dtf(self):
        # init of the db
        self.mydb = MyDB()

        # we get the expenses
        expenses_dataframe = pd.merge(
            pd.merge(
                pd.merge(
                    pd.merge(
                        self.mydb.get_dataframe(objct=Expense),
                        ################ B TCE DTF ###############
                        pd.merge(
                            self.mydb.get_dataframe(objct=TypeCenterExpense, index=False),
                            pd.merge(
                                self.mydb.get_dataframe(objct=Center, index=False),
                                pd.merge(
                                    self.mydb.get_dataframe(objct=Service, index=False),
                                    self.mydb.get_dataframe(objct=Location, index=False).drop("legalentity_id", axis=1),
                                    on="location_id",
                                    how="left",
                                ).drop("location_id", axis=1),
                                on="service_id",
                                how="left",
                            ).drop("service_id", axis=1),
                            on="center_id",
                            how="left",
                        ).drop("center_id", axis=1),
                        ################ E TCE DTF ###############
                        on="tce_id",
                        how="left",
                    ).drop("tce_id", axis=1),
                    self.mydb.get_dataframe(objct=Status, index=False),
                    on="status_id",
                    how="left",
                ).drop("status_id", axis=1),
                ################ B COSTELMT DTF ###############
                pd.merge(
                    pd.merge(
                        self.mydb.get_dataframe(objct=CostElement, index=False),
                        self.mydb.get_dataframe(objct=CEGroupCE, index=False),
                        on="costelement_id",
                        how="left",
                    ),
                    self.mydb.get_dataframe(objct=CostElementGroup, index=False),  # ADD .classification_id == ...
                    on="costelementgroup_id",
                    how="left",
                ).drop("costelementgroup_id", axis=1),
                ################ B COSTELMT DTF ###############
                on="costelement_id",
                how="left",
            ).drop("costelement_id", axis=1),
            ################ B WBS DTF ###############
            pd.merge(
                pd.merge(
                    self.mydb.get_dataframe(objct=WBSElement, index=False),
                    ################ B CODE DTF ###############
                    pd.merge(
                        # pd.merge(
                        pd.merge(
                            pd.merge(
                                self.mydb.get_dataframe(objct=Code, index=False),
                                self.mydb.get_dataframe(objct=CodeTyp, index=False),
                                on="codetype_id",
                                how="left",
                            ).drop("codetype_id", axis=1),
                            ################ B PROJECT DTF ###############
                            pd.merge(
                                pd.merge(
                                    pd.merge(
                                        self.mydb.get_dataframe(objct=Project, index=False),
                                        self.mydb.get_dataframe(objct=ProjectType, index=False),
                                        on="projecttype_id",
                                        how="left",
                                    ).drop("projecttype_id", axis=1),
                                    self.mydb.get_dataframe(objct=Customer, index=False).drop("address_id", axis=1),
                                    on="customer_id",
                                    how="left",
                                ).drop("customer_id", axis=1),
                                self.mydb.get_dataframe(objct=Location, index=False).drop("legalentity_id", axis=1),
                                on="location_id",
                                how="left",
                            ).drop("location_id", axis=1),
                            ################ E PROJECT DTF ###############
                            on="project_id",
                            how="left",
                        ).drop("project_id", axis=1),
                        self.mydb.get_dataframe(objct=Location, index=False).drop("legalentity_id", axis=1),
                        on="location_id",
                        how="left",
                    ).drop("location_id", axis=1),
                    # self.mydb.get_dataframe(objct = Center, index = False),
                    # on = 'center_id'
                    #     ).drop(
                    #     'center_id',
                    #     axis=1
                    #           ),
                    ################ E CODE DTF ###############
                    on="code_id",
                    how="left",
                ).drop("code_id", axis=1),
                self.mydb.get_dataframe(objct=WBSCA, index=False),
                on="wbsca_id",
                how="left",
            )
            .drop("wbsca_id", axis=1)
            .drop(
                [
                    "code_appdate",
                    "code_clodate",
                    "project_clodate",
                    "project_editflag",
                    "project_enmodification",
                    "project_appdate",
                    "project_rewdate",
                ],
                axis=1,
            ),
            ############### E WBS DTF ###############
            on="wbs_id",
            how="left",
        ).drop("wbs_id", axis=1)

        return expenses_dataframe
Exemple #8
0
class CJSLTool(FloatLayout):

    ##################### Constructeur #####################
    def __init__(self, **kwargs):
        super(CJSLTool, self).__init__(**kwargs)

        # We build the GUI
        self.build_GUI()

        self.write_dtf_to_csv(self.get_expense_dtf())

        self.launch_cjsl()

    def launch_cjsl(self):

        shutil.copyfile(
            "D:\\Programmation\\Mascaret\\Programme Mascaret 2.0\\tools\\cjsl\\excel\\cjsl.xlsm",
            "D:\\Programmation\\Mascaret\\Programme Mascaret 2.0\\temp\\cjsl.xlsm",
        )

        p = subprocess.Popen(
            [
                "C:\Program Files\Microsoft Office\Office14\EXCEL.EXE",
                "D:\\Programmation\\Mascaret\\Programme Mascaret 2.0\\temp\\cjsl.xlsm",
            ]
        )

        # ret_val = p.wait()

    def write_dtf_to_csv(self, dtf):

        dtf.to_csv("D:\\Programmation\\Mascaret\\Programme Mascaret 2.0\\temp\\exp.csv", index=False)

    def get_expense_dtf(self):
        # init of the db
        self.mydb = MyDB()

        # we get the expenses
        expenses_dataframe = pd.merge(
            pd.merge(
                pd.merge(
                    pd.merge(
                        self.mydb.get_dataframe(objct=Expense),
                        ################ B TCE DTF ###############
                        pd.merge(
                            self.mydb.get_dataframe(objct=TypeCenterExpense, index=False),
                            pd.merge(
                                self.mydb.get_dataframe(objct=Center, index=False),
                                pd.merge(
                                    self.mydb.get_dataframe(objct=Service, index=False),
                                    self.mydb.get_dataframe(objct=Location, index=False).drop("legalentity_id", axis=1),
                                    on="location_id",
                                    how="left",
                                ).drop("location_id", axis=1),
                                on="service_id",
                                how="left",
                            ).drop("service_id", axis=1),
                            on="center_id",
                            how="left",
                        ).drop("center_id", axis=1),
                        ################ E TCE DTF ###############
                        on="tce_id",
                        how="left",
                    ).drop("tce_id", axis=1),
                    self.mydb.get_dataframe(objct=Status, index=False),
                    on="status_id",
                    how="left",
                ).drop("status_id", axis=1),
                ################ B COSTELMT DTF ###############
                pd.merge(
                    pd.merge(
                        self.mydb.get_dataframe(objct=CostElement, index=False),
                        self.mydb.get_dataframe(objct=CEGroupCE, index=False),
                        on="costelement_id",
                        how="left",
                    ),
                    self.mydb.get_dataframe(objct=CostElementGroup, index=False),  # ADD .classification_id == ...
                    on="costelementgroup_id",
                    how="left",
                ).drop("costelementgroup_id", axis=1),
                ################ B COSTELMT DTF ###############
                on="costelement_id",
                how="left",
            ).drop("costelement_id", axis=1),
            ################ B WBS DTF ###############
            pd.merge(
                pd.merge(
                    self.mydb.get_dataframe(objct=WBSElement, index=False),
                    ################ B CODE DTF ###############
                    pd.merge(
                        # pd.merge(
                        pd.merge(
                            pd.merge(
                                self.mydb.get_dataframe(objct=Code, index=False),
                                self.mydb.get_dataframe(objct=CodeTyp, index=False),
                                on="codetype_id",
                                how="left",
                            ).drop("codetype_id", axis=1),
                            ################ B PROJECT DTF ###############
                            pd.merge(
                                pd.merge(
                                    pd.merge(
                                        self.mydb.get_dataframe(objct=Project, index=False),
                                        self.mydb.get_dataframe(objct=ProjectType, index=False),
                                        on="projecttype_id",
                                        how="left",
                                    ).drop("projecttype_id", axis=1),
                                    self.mydb.get_dataframe(objct=Customer, index=False).drop("address_id", axis=1),
                                    on="customer_id",
                                    how="left",
                                ).drop("customer_id", axis=1),
                                self.mydb.get_dataframe(objct=Location, index=False).drop("legalentity_id", axis=1),
                                on="location_id",
                                how="left",
                            ).drop("location_id", axis=1),
                            ################ E PROJECT DTF ###############
                            on="project_id",
                            how="left",
                        ).drop("project_id", axis=1),
                        self.mydb.get_dataframe(objct=Location, index=False).drop("legalentity_id", axis=1),
                        on="location_id",
                        how="left",
                    ).drop("location_id", axis=1),
                    # self.mydb.get_dataframe(objct = Center, index = False),
                    # on = 'center_id'
                    #     ).drop(
                    #     'center_id',
                    #     axis=1
                    #           ),
                    ################ E CODE DTF ###############
                    on="code_id",
                    how="left",
                ).drop("code_id", axis=1),
                self.mydb.get_dataframe(objct=WBSCA, index=False),
                on="wbsca_id",
                how="left",
            )
            .drop("wbsca_id", axis=1)
            .drop(
                [
                    "code_appdate",
                    "code_clodate",
                    "project_clodate",
                    "project_editflag",
                    "project_enmodification",
                    "project_appdate",
                    "project_rewdate",
                ],
                axis=1,
            ),
            ############### E WBS DTF ###############
            on="wbs_id",
            how="left",
        ).drop("wbs_id", axis=1)

        return expenses_dataframe

    def build_GUI(self):
        # L'interface graphique du mdule
        # Elle affiche 3 principaux objets :
        pass
Exemple #9
0
class NoteTool(RelativeLayout):
    notelistcontaineritem = ObjectProperty(None)

    notelist_width = NumericProperty(200)

    spacing = NumericProperty(50)

    def __init__(self, **kwargs):
        super(NoteTool, self).__init__(**kwargs)
        #init of the db
        self.mydb = MyDB()
        # we get the note lists
        self.notelists_dataframe = self.mydb.get_dataframe(objct = NoteList)
        # we build the notelists items
        self.init_notelistitems()

        # we get the notes
        self.notes_dataframe = self.mydb.get_dataframe(objct = Note)
        # we build the note items
        self.init_noteitems()

        self.moving_noteitem = None
        self.moving_notelistitem = None

    def init_notelistitems(self):
        self.notelistitems_dict = {}
        self.i = 0

        for ix in self.notelists_dataframe.index:
            self.add_notelistitem(ix)

    def init_noteitems(self):
        self.noteitems_dict = {}

        for ix in self.notes_dataframe.index:
            self.add_noteitem(ix)

    def add_notelistitem_in_dict(self, notelistitem):
        self.notelistitems_dict[notelistitem.notelist_id] = notelistitem

    def add_noteitem_in_dict(self, noteitem):
        self.noteitems_dict[noteitem.note_id] = noteitem

    def del_notelisttiem_in_dict(self, notelistitem):
        del self.notelistitems_dict[notelistitem.notelist_id]

    def del_noteitem_in_dict(self, noteitem):
        del self.noteitems_dict[noteitem.note_id]

    def add_notelistitem(self, notelist_id):

        # we get the place_id
        place_id = self.get_notelist_attr(
                                            notelist_id = notelist_id,
                                            attr = 'notelist_place_id'
                                     )

        # we create the notelistitem
        new_notelistitem = NoteListItem(
            notelist_id = notelist_id,
            notetool = self,
            place_id = place_id,
            width = self.notelist_width
                                              )
        # we add it to the dict
        self.add_notelistitem_in_dict(notelistitem = new_notelistitem)
        # we display it
        self.notelistcontaineritem.add_notelistitem(notelistitem = new_notelistitem, notelist_place_id = place_id)

    def add_noteitem(self, note_id):

        # we get the notelist_id in wich the note is added
        linked_notelist_id = self.get_note_attr(
                                            note_id = note_id,
                                            attr = 'notelist_index'
                                               )
        # we get the notelistitem
        linked_notelist = self.notelistitems_dict[linked_notelist_id]

        # we get the place_id
        place_id = self.get_note_attr(
                                            note_id = note_id,
                                            attr = 'note_place_id'
                                     )

        # we create the note item
        new_noteitem = NoteItem(
                            note_id = note_id,
                            notetool = self,
                            notecontainer = linked_notelist.notecontaineritem,
                            place_id = place_id,
                            notelist_id = linked_notelist_id
                               )
        # we add it to the dict
        self.add_noteitem_in_dict(noteitem = new_noteitem)

        # we ask the linked notelist to display it
        linked_notelist.add_noteitem(noteitem = new_noteitem, note_place_id = place_id)

    def get_notelistitem(self, notelist_id):
    # This method get a noteitem from the noteitem dict
        # Check if this noteitem exists
        if (
            notelist_id in
            self.notelistitems_dict.keys()
           ):
        #    If it does then it returns the header
            return (
            self.notelistitems_dict[notelist_id]
                   )
        # else it returns None
        else:
            return None

    def get_note_attr(self, note_id, attr):
    # Method to get the required attr in the ressource dtf
        return self.notes_dataframe.loc[note_id, attr]

    def get_notelist_attr(self, notelist_id, attr):
    # Method to get the required attr in the notelist dtf
        return self.notelists_dataframe.loc[notelist_id, attr]

    def get_noteitem(self, note_id):
    # This method get a noteitem from the noteitem dict
        # Check if this noteitem exists
        if (
            note_id in
            self.noteitems_dict.keys()
           ):
        #    If it does then it returns the header
            return (
            self.noteitems_dict[note_id]
                   )
        # else it returns None
        else:
            return None

    def on_touch_up(self,touch):
        # if there is a moving_noteitem in the notetool it mean the touch up is
        # the end of a grab of a noteitem.
        if self.moving_noteitem != None:
            # therfore we need to insert this
            # moving noteitem at the chosen place
            self.insert_moving_noteitem()

        if self.moving_notelistitem != None:
            # therfore we need to insert this
            # moving noteitem at the chosen place
            self.insert_moving_notelistitem()


    def insert_moving_noteitem(self):
    # method to insert a moving noteitem at the place of its new_place_noteitem
        # At first we clear it from the notetool
        self.clear_widgets([self.moving_noteitem])

        # re-ref of the notelistitem
        self.moving_noteitem.notecontainer = self.moving_noteitem.new_place_noteitem.notecontainer
        # re-Init of the place_id
        self.moving_noteitem.place_id = self.moving_noteitem.new_place_noteitem.place_id
        # re-Init of the notelist_id
        self.moving_noteitem.notelist_id = self.moving_noteitem.new_place_noteitem.notelist_id
        # this is a flag triggered when the note item is moved by touch
        self.moving_noteitem.move_flag = False
        # re-Init of the pos
        self.moving_noteitem.pos = self.moving_noteitem.new_place_noteitem.pos

        # We clear the NewPlaceNoteItem from the container
        self.moving_noteitem.new_place_noteitem.notecontainer.clear_widgets(
                                    [self.moving_noteitem.new_place_noteitem]
                                                                       )

        # We add it to the new container
        self.moving_noteitem.new_place_noteitem.notecontainer.add_widget(
                                                    self.moving_noteitem
                                                                    )
        # we delete the NewPlaceNoteItem of the moving noteitem
        del self.moving_noteitem.new_place_noteitem

        # de-ref of the moving note item
        self.moving_noteitem = None

        Cursor().unblock()
        Cursor().update()

    def insert_moving_notelistitem(self):
    # method to insert a moving notelistitem at the place of its new_place_notelistitem
        # At first we clear it from the notetool
        self.clear_widgets([self.moving_notelistitem])

        # re-Init of the place_id
        self.moving_notelistitem.place_id = self.moving_notelistitem.new_place_notelistitem.place_id
        # this is a flag triggered when the note item is moved by touch
        self.moving_notelistitem.move_flag = False
        # re-Init of the pos
        self.moving_notelistitem.pos = self.moving_notelistitem.new_place_notelistitem.pos

        # We clear the NewPlaceNoteListItem from the container
        self.notelistcontaineritem.clear_widgets(
                            [self.moving_notelistitem.new_place_notelistitem]
                                                                       )

        # We add it to the new container
        self.notelistcontaineritem.add_widget(
                                            self.moving_notelistitem
                                             )
        # we delete the NewPlaceNoteItem of the moving noteitem
        del self.moving_notelistitem.new_place_notelistitem

        # de-ref of the moving note item
        self.moving_notelistitem = None

        Cursor().unblock()
        Cursor().update()
Exemple #10
0
class ExerciseTool(ScreenManager):

    def __init__(self, **kwargs):
        super(ExerciseTool, self).__init__(**kwargs)
        #init of the db
        self.mydb = MyDB()
        # init the dtf
        self.init_dtf()
        # gui building
        self.build_GUI()


    def build_GUI(self):
        self.homepage = ExerciseToolHP(self)
        self.add_widget(Screen(name = 'hpscreen'))
        self.get_screen('hpscreen').add_widget(self.homepage)

        self.trainingintrolayout = TrainingIntroLayout(self)
        self.add_widget(Screen(name = 'trainingintroscreen'))
        self.get_screen('trainingintroscreen').add_widget(self.trainingintrolayout)


    def init_dtf(self):
        # we get the list of favorites workout
        self.trainings_dataframe = self.mydb.get_dataframe(objct = Training)
        self.favtrainings_dataframe = self.trainings_dataframe[self.trainings_dataframe.training_fav == 1]
        # print(self.favtrainings_dataframe.head(n=1).index.item())

        self.workouts_dataframe = self.mydb.get_dataframe(objct = Workout)


    def get_wide(self):
    # This method must trigger the "fullpage" mode of the tool in mascaret
        # TO BE REPLACED BY A MODE (WIDE/NARROW) CHECK /B
        if self.to_window(*self.pos)[0] == 64:
            return
        else:
            print('go wide')
        # TO BE REPLACED BY A MODE (WIDE/NARROW) CHECK /E

    def show_training_intro(self, training_id):

        # dataframe of the exercises
        self.exercises_dataframe = self.mydb.get_dataframe(
                                            objct = Exercise,
                                            index = False
                                                     )
        # dataframe with the exsc
        exercisescalings_dataframe = self.mydb.get_dataframe(
                                            objct = ExerciseScaling,
                                            index = False
                                                            )
        # dataframe with the association exsc - training
        exsctrainings_dataframe = self.mydb.get_dataframe(
                                            objct = ExScTraining,
                                            index = False
                                                         )
        # we keep only the asso exsc - training related to the actual training
        exsctrainings_dataframe = exsctrainings_dataframe[
                            exsctrainings_dataframe.training_id == training_id
                                                         ]

        # dataframe with the workouts
        former_workouts_dataframe = self.mydb.get_dataframe(
                                            objct = Workout,
                                            index = False
                                                           )
        # we get the latest workout_id
        if not former_workouts_dataframe.empty:
        # if it is not our first workout:
            self.latest_workout_id = former_workouts_dataframe.workout_id.max()
            self.latest_appex_id = self.mydb.get_dataframe(
                                                objct = AppExercise,
                                                index = False
                                                             ).appexercise_id.max()
            self.latest_serie_id = self.mydb.get_dataframe(
                                                objct = Serie,
                                                index = False
                                                             ).serie_id.max()
        else:
        # if it is our first workout:
            # we init the ids and return
            self.latest_workout_id = 0
            self.latest_appex_id = 0
            self.latest_serie_id = 0

        # print('latest_workout_id: ' + str(self.latest_workout_id))

        # we keep only the workouts for the actual training
        former_workouts_dataframe = former_workouts_dataframe[
                                    former_workouts_dataframe.training_id
                                                    ==
                                                training_id
                                                             ]
        # if there are already workouts of the actual training
        if not former_workouts_dataframe.empty:
            # we get its informations
            self.latest_former_workout_serie = former_workouts_dataframe.ix[
                                former_workouts_dataframe.idxmax()['workout_n']
                                                                            ]
            # the number of the latest workout of the actual training
            self.latest_workout_n = self.latest_former_workout_serie.workout_id
            # dataframe with the series merged with their appex
            self.former_series_dataframe = pd.merge(
                self.mydb.get_dataframe(objct = Serie, index = False),
                self.mydb.get_dataframe(objct = AppExercise, index = False),
                how = 'left',
                on = 'appexercise_id'
                                                   )
            # we keep only the series of the latest workout of the actual
            # training
            self.former_series_dataframe = self.former_series_dataframe[
                                self.former_series_dataframe.workout_id
                                                    ==
                                        self.latest_workout_n
                                                                       ]
        else:
            self.latest_workout_n = 0

        print('latest_workout_n: ' + str(self.latest_workout_n))

        # dataframe with the exsc for the actual training sorted
        self.current_exercisescalings_dataframe = pd.merge(
                                    pd.merge(
                                        exsctrainings_dataframe,
                                        exercisescalings_dataframe,
                                        how = 'left',
                                        on = 'exercisescaling_id'
                                            ),
                                    exercises_dataframe,
                                    how = 'left',
                                    on = 'exercise_id'
                                                          ).sort(
                                                columns = 'exercisescaling_n'
                                                                )



        self.trainingintrolayout.init_training(training_id)

        self.current = 'trainingintroscreen'