Exemple #1
0
 def adjust_background(self, *args, **kwargs):
     with ignored(Exception):
         self.background_instruction.clear()
         self.background_instruction.add(
             Rectangle(pos=self.pos,
                       size=Window.size,
                       source=self.parent.get_proper_background_image()))
Exemple #2
0
 def insert_new_session(user_id, device_id):
     date = "{}/{}/{}".format(gmtime().tm_year, gmtime().tm_mon + 1, gmtime().tm_mday)
     with ignored(Exception):
         DatabaseConnection().execute_command(
             'insert into session (expiration_date, user_id, device_id) '
             'values (STR_TO_DATE("{date}", "%Y/%m/%d"), {user_id}, "{device_id}")'.format(date=date,
                                                                                           user_id=user_id,
                                                                                           device_id=device_id))
Exemple #3
0
 def logout(self, *args, **kwargs):
     with ignored(Exception):
         stop_notification_service()
     schedule_task(callback=SqlCommands.delete_session, device_id=plyer.uniqueid.id)
     super(MyLoginManager, self).logout()
     self.session_id = None
     self.__session_supervisor = BackgroundSessionSupervisor(self)
     self.choosen_user = None
     self.get_screen("CarouselWithActionBar").reinitialize()
Exemple #4
0
 def change_permissions(*args, **kwargs):
     with ignored(Exception):
         user_button, permission_button = args
         if permission_button in privileges:
             DatabaseConnection().execute_command(
                 "Update instruktorzy set uprawnienia = '{}' where id = {}".format(permission_button,
                                                                                   user_button.id))
             query = DatabaseConnection().fetch_query(
                 'Select uprawnienia from instruktorzy where id = {}'.format(user_button.id))
             return True if query[0][0] == permission_button else False
Exemple #5
0
 def create_user(firstname, lastname, login, *args, **kwargs):
     try:
         if firstname.isalpha() and login.isalnum():
             query = DatabaseConnection().fetch_query(
                 "Select login from instruktorzy where login='******'".format(login))
             with ignored(IndexError):
                 if query[0][0] == login: return False
             cmd = "Insert into instruktorzy (login, password, imie, nazwisko, uprawnienia) values " \
                   "('{login}', '{password}', '{firstname}', '{lastname}', 'User')".format(firstname=firstname,
                                                                                           lastname=lastname,
                                                                                           login=login,
                                                                                           password=hash(login))
             DatabaseConnection().execute_command(cmd)
             query = DatabaseConnection().fetch_query(
                 "Select login from instruktorzy where login='******'".format(login))
             if query[0][0] == login: return True
     except:
         return None
Exemple #6
0
 def go_back(self):
     carousel = self.get_screen("CarouselWithActionBar").carousel
     with ignored(IndexError):
         self.commands_stack.pop()
         carousel.load_slide(self.commands_stack.pop())
     return True
Exemple #7
0
 def refresh(*args):
     with ignored(Exception):
         caro = App.get_running_app().root.get_screen(
             "CarouselWithActionBar")
         caro.carousel.current_slide.refresh(*args)
Exemple #8
0
 def remove_user(user, *args, **kwargs):
     with ignored(Exception):
         DatabaseConnection().execute_command('Delete from instruktorzy where id={}'.format(user.id))
         query = DatabaseConnection().fetch_query('Select id from instruktorzy where id={}'.format(user.id))
         if len(query) > 0: return False
         return True
Exemple #9
0
 def get_earnings(period, user, *args, **kwargs):
     with ignored(Exception):
         cmd = EarningsCmdChooser().get_earnings_cmd_from[period[0]](period, user)
         query = DatabaseConnection().fetch_query(cmd)
         return query[0][0]