Esempio n. 1
0
    def check_galaxy(self):
        """Check if user have galaxy triples"""

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        result = query_laucher.process_query(
            sqa.check_galaxy(self.username).query)

        return ParamManager.Bool(result[0]['status'])
Esempio n. 2
0
    def get_admin_blocked_by_email(self):
        """
        get the admin status of the user by his username
        """
        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        result = query_laucher.process_query(
            sqa.get_admin_blocked_by_email(self.email).query)

        results = {}

        if len(result) <= 0:
            results['blocked'] = True
            results['admin'] = True
        else:
            results['blocked'] = ParamManager.Bool(result[0]['blocked'])
            results['admin'] = ParamManager.Bool(result[0]['admin'])

        return results
Esempio n. 3
0
    def ckeck_key_belong_user(self, key):
        """Check if a key belong to a user"""

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        result = query_laucher.process_query(
            sqa.ckeck_key_belong_user(self.username, key).query)
        self.log.debug('---> result: ' + str(result))

        if len(result) <= 0:
            return False

        return ParamManager.Bool(result[0]['count'])
Esempio n. 4
0
    def get_admin_blocked_by_email(self):
        """
        get the admin status of the user by his username
        """
        database = DatabaseConnector(self.settings, self.session)
        query = '''
        SELECT admin, blocked
        FROM users
        WHERE email=?
        '''

        rows = database.execute_sql_query(query, (self.email, ))

        results = {}

        if len(rows) <= 0:
            results['blocked'] = True
            results['admin'] = False
        else:
            results['blocked'] = ParamManager.Bool(rows[0][1])
            results['admin'] = ParamManager.Bool(rows[0][0])

        return results
Esempio n. 5
0
    def check_email_in_database(self):
        """
        Check if the email is present in the TS
        """

        query_laucher = QueryLauncher(self.settings, self.session)
        sqa = SparqlQueryAuth(self.settings, self.session)

        result = query_laucher.process_query(
            sqa.check_email_presence(self.email).query)

        if len(result) <= 0:
            return False

        return ParamManager.Bool(result[0]['status'])
Esempio n. 6
0
 def test_bool(self):
     try:
         ParamManager.Bool(None)
         assert False
     except Exception as e:
         assert True
     assert not ParamManager.Bool("FALSE")
     assert not ParamManager.Bool("FaLsE")
     assert ParamManager.Bool("TRUE")
     assert ParamManager.Bool("TrUe")
     assert ParamManager.Bool("1")
     try:
         ParamManager.Bool(1)
         assert False
     except Exception as e:
         assert True