Пример #1
0
def fetch_database_urls():
    db = MyDB()
    query = "SELECT link, id FROM cs_sites"
    db.query(query)
    urls = {}
    for item in list(db.fetchall()):
        urls[item[1]] = item[0]
    db.commit()
    db.close()
    return urls
Пример #2
0
    def get_ent_jur_list(self):

        #DB CONNECTION
        db = MyDB()
        #Execute la requete SQL
        get_all_legal_entities_query = "SELECT *FROM EntiteJuridique;"

        try:
            db.query(get_all_legal_entities_query,[])
            db.commit()
        except:
            db.rollback()
        #On obtient une matrice
        legal_entities_data = db.db_fetchall()

        # Liste d'entite Juridique
        data_ent_jur = ListEntJur(legal_entities_data)
        
        return data_ent_jur
Пример #3
0
    def get_location_list(self):

        #DB CONNECTION
        db = MyDB()
        #Execute la requete SQL
        get_all_location_query = "SELECT * FROM Location;"

        try:
            db.query(get_all_location_query,[])

            db.commit()
        except:
            db.rollback()
        #On obtient une matrice
        location_data = db.db_fetchall()

        # Liste d'entite Juridique
        data_location = ListLocationFromFetch(location_data)
        
        return data_location
Пример #4
0
    def check_existence_of_new_location_and_add_it(self, data_location):

        #DB CONNECTION
        db = MyDB()
        
        location_exist = False
        for row in data_location:
            if row.loc_intitule == self.new_location_box.text:
                print("This Location already exists")
                location_exist = True

        if location_exist == False:
            
            #selected_ent_jur = 
            idEntJur= self.ent_jur_listbox.ent_jur_listview.adapter.selection[0].id_jur_ent

            add_permission_query = "INSERT INTO `Permission`;"

            get_permission_id_query = """SELECT P.idPermission AS idP
                                    FROM Permission P
                                    ORDER BY P.idPermission DESC
                                    LIMIT 1;"""

            add_location_query = """INSERT INTO `Location` (idLocation, intitule, idEntJur)
                                    VALUES (%d,%s,%d);"""

            #try:
            db.query(add_permission_query,[])

            db.query(get_permission_id_query,[])
            id_permission_data = db.db_fetchone()

            parameters_query = [id_permission_data,self.new_location_box.text,idEntJur]
            
            db.query(add_location_query,parameters_query)
            db.commit()
            #except:
                #db.rollback()

            self.new_location_box.text = ""
            self.location_listbox.location_listview.adapter.data = self.location_listbox.get_location_list()
Пример #5
0
    def check_login(self, *args):
        user_login = self.login_box.text
        user_password = self.password_box.text


        # DB CONNECTION
        db = MyDB()

        login_query = "SELECT * FROM utilisateur WHERE login =%s AND password = %s"

        parameters_query =[user_login,user_password]

        try:
            db.query(login_query,parameters_query)
            db.commit()
        except:
            db.rollback()

        login_data = db.db_fetchall()

        if login_data:

            user_logged = User(user_login)
            self.dispatch('on_right_id')


        else:
            self.login_box.focus = True
            self.remove_widget(self.pan_screen)
            self.error_box.text = "Wrong credentials"
            # create an animation object. This object could be stored
            # and reused each call or reused across different widgets.
            # += is a sequential step, while &= is in parallel
            animation = Animation(x=(0), t='out_bounce')

            # apply the animation on the button, passed in the "instance" argument
            # Notice that default 'click' animation (changing the button
            # color while the mouse is down) is unchanged.
            animation.start(self.login_area)
Пример #6
0
    def check_existence_of_new_ent_jur_and_add_it(self, data_ent_jur):

        #DB CONNECTION
        db = MyDB()
        
        entity_exist = False
        for row in data_ent_jur:
            if row.ent_name == self.new_legal_entity_box.text:
                print("This Legal Entity already exists")
                entity_exist = True
        if entity_exist == False:
            add_legal_entity_query = "INSERT INTO `entitejuridique` (`intitule`) VALUES (%s) ;"

            parameters_query = [str(self.new_legal_entity_box.text)]

            try:
                db.query(add_legal_entity_query,parameters_query)
                db.commit()
            except:
                db.rollback()

            self.new_legal_entity_box.text = ""
            self.list_ent_jur_box.ent_jur_listview.adapter.data = self.list_ent_jur_box.get_ent_jur_list()
Пример #7
0
    def get_module_available(self):

                ###################Looking into Module#####################

        #DB CONNECTION

        db = MyDB()

        modules_query = """SELECT m.intitule, o.intitule
                        FROM module AS m , outil AS o, utilisateur AS u, utilisateuroutil AS uo
                        WHERE u.login =%s AND uo.idUtilisateur = u.idUtilisateur
                        AND uo.idOutil = o.idOutil AND o.idModule = m.idModule"""

        user_logged = User()
        parameters_query =[user_logged.login]
        try:
            db.query(modules_query,parameters_query)
            db.commit()
        except:
            db.rollback()
            
        modules_data = db.db_fetchall()

        return modules_data