add support for profile pictures
This commit is contained in:
parent
1b9fa0d8a6
commit
69c3ea9b68
@ -31,10 +31,3 @@ if __name__ == "__main__":
|
||||
seating_service = SeatingService(seating_config, lan_info, db_service, ticketing_service)
|
||||
catering_service = CateringService(db_service, accounting_service, user_service)
|
||||
|
||||
# catering_service.place_order(
|
||||
# {
|
||||
# CateringMenuItem(item_id=5, name='Bier', price=250, category=CateringMenuItemCategory.BEVERAGE_ALCOHOLIC, additional_info="Pils", is_disabled=False): 12,
|
||||
# CateringMenuItem(item_id=6, name='Pizza Hawaii', price=900, category=CateringMenuItemCategory.MAIN_COURSE, additional_info = '', is_disabled = False): 2
|
||||
# },
|
||||
# 19
|
||||
# )
|
||||
|
||||
@ -482,3 +482,26 @@ class DatabaseService:
|
||||
)] = order_catering_menu_item_raw[2]
|
||||
|
||||
return result
|
||||
|
||||
def set_user_profile_picture(self, user_id: int, picture_data: bytes) -> None:
|
||||
cursor = self._get_cursor()
|
||||
try:
|
||||
cursor.execute(
|
||||
"INSERT INTO user_profile_picture (user_id, picture) VALUES (?, ?) ON DUPLICATE KEY UPDATE picture = VALUES(picture)",
|
||||
(user_id, picture_data)
|
||||
)
|
||||
self._connection.commit()
|
||||
except Exception as e:
|
||||
logger.warning(f"Error setting user profile picture: {e}")
|
||||
|
||||
def get_user_profile_picture(self, user_id: int) -> Optional[bytes]:
|
||||
cursor = self._get_cursor()
|
||||
try:
|
||||
cursor.execute("SELECT (picture) FROM user_profile_picture WHERE user_id = ?", (user_id, ))
|
||||
r = cursor.fetchone()
|
||||
if r is None:
|
||||
return
|
||||
return r[0]
|
||||
except Exception as e:
|
||||
logger.warning(f"Error setting user profile picture: {e}")
|
||||
return None
|
||||
|
||||
@ -23,6 +23,12 @@ class UserService:
|
||||
return self._db_service.get_user_by_mail(accessor)
|
||||
return self._db_service.get_user_by_name(accessor)
|
||||
|
||||
def set_profile_picture(self, user_id: int, picture: bytes) -> None:
|
||||
self._db_service.set_user_profile_picture(user_id, picture)
|
||||
|
||||
def get_profile_picture(self, user_id: int) -> bytes:
|
||||
return self._db_service.get_user_profile_picture(user_id)
|
||||
|
||||
def create_user(self, user_name: str, user_mail: str, password_clear_text: str) -> User:
|
||||
disallowed_char = self._check_for_disallowed_char(user_name)
|
||||
if disallowed_char:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user