From fce128fba1086f1eeeeef39cc1d810b1b7223696 Mon Sep 17 00:00:00 2001 From: Vincent 'Philaeux' Lamotte Date: Wed, 23 Aug 2023 01:07:14 +0200 Subject: [PATCH] Add 3 new flags for a player --- .../alembic/versions/cf80d303e86f_.py | 34 + src/dota_notes/data/models/player_entity.py | 31 +- src/dota_notes/data/states/player_state.py | 4 +- src/dota_notes/ui/app_qt.py | 2 + src/dota_notes/ui/images/resumes_pause.png | Bin 0 -> 452 bytes src/dota_notes/ui/main_window.py | 6 +- src/dota_notes/ui/resources.qrc | 1 + src/dota_notes/ui/ui_main_window.ui | 711 +++++++++++++++++- 8 files changed, 760 insertions(+), 29 deletions(-) create mode 100644 src/dota_notes/alembic/versions/cf80d303e86f_.py create mode 100644 src/dota_notes/ui/images/resumes_pause.png diff --git a/src/dota_notes/alembic/versions/cf80d303e86f_.py b/src/dota_notes/alembic/versions/cf80d303e86f_.py new file mode 100644 index 0000000..afde49e --- /dev/null +++ b/src/dota_notes/alembic/versions/cf80d303e86f_.py @@ -0,0 +1,34 @@ +"""empty message + +Revision ID: cf80d303e86f +Revises: f240ff7795a9 +Create Date: 2023-08-22 21:23:06.012752 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = 'cf80d303e86f' +down_revision: Union[str, None] = 'f240ff7795a9' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('players', sa.Column('rages_buyback', sa.Boolean(), nullable=False, server_default="0")) + op.add_column('players', sa.Column('bm_pause', sa.Boolean(), nullable=False, server_default="0")) + op.add_column('players', sa.Column('resumes_pause', sa.Boolean(), nullable=False, server_default="0")) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('players', 'resumes_pause') + op.drop_column('players', 'bm_pause') + op.drop_column('players', 'rages_buyback') + # ### end Alembic commands ### diff --git a/src/dota_notes/data/models/player_entity.py b/src/dota_notes/data/models/player_entity.py index 22bfc5d..5576cb2 100644 --- a/src/dota_notes/data/models/player_entity.py +++ b/src/dota_notes/data/models/player_entity.py @@ -23,6 +23,9 @@ class PlayerEntity(BaseEntity): is_feeder: flag gives_up: flag destroys_items: flag + rages_buyback: flag + bm_pause: flag + resumes_pause: flag note: user set note """ __tablename__ = 'players' @@ -40,11 +43,14 @@ class PlayerEntity(BaseEntity): is_feeder: Mapped[bool] = mapped_column() gives_up: Mapped[bool] = mapped_column() destroys_items: Mapped[bool] = mapped_column() + rages_buyback: Mapped[bool] = mapped_column() + bm_pause: Mapped[bool] = mapped_column() + resumes_pause: Mapped[bool] = mapped_column() note: Mapped[str] = mapped_column(String(500)) def __init__(self, steam_id, name, pro_name=None, custom_name="", match_count=None, smurf="", smurf_stratz=None, is_racist=False, is_sexist=False, is_toxic=False, is_feeder=False, gives_up=False, - destroys_items=False, note=""): + destroys_items=False, rages_buyback=False, bm_pause=False, resumes_pause=False, note=""): self.steam_id = steam_id self.name = name self.pro_name = pro_name @@ -58,6 +64,9 @@ def __init__(self, steam_id, name, pro_name=None, custom_name="", match_count=No self.is_feeder = is_feeder self.gives_up = gives_up self.destroys_items = destroys_items + self.rages_buyback = rages_buyback + self.bm_pause = bm_pause + self.resumes_pause = resumes_pause self.note = note @staticmethod @@ -67,20 +76,9 @@ def make_from_state(player_state): Args: player_state: state to import information from """ - return PlayerEntity( - str(player_state.steam_id), - player_state.name, - player_state.pro_name if player_state.pro_name != "" else None, - player_state.custom_name, - player_state.match_count, - player_state.smurf, - player_state.smurf_stratz, - player_state.is_racist, - player_state.is_sexist, - player_state.is_toxic, - player_state.is_feeder, - player_state.gives_up, - player_state.destroys_items) + entity = PlayerEntity(str(player_state.steam_id), player_state.name) + PlayerEntity.import_export(from_object=player_state, to_object=entity) + return entity @staticmethod def import_export(from_object, to_object): @@ -101,6 +99,9 @@ def import_export(from_object, to_object): to_object.is_feeder = from_object.is_feeder to_object.gives_up = from_object.gives_up to_object.destroys_items = from_object.destroys_items + to_object.rages_buyback = from_object.rages_buyback + to_object.bm_pause = from_object.bm_pause + to_object.resumes_pause = from_object.resumes_pause to_object.note = from_object.note def __repr__(self) -> str: diff --git a/src/dota_notes/data/states/player_state.py b/src/dota_notes/data/states/player_state.py index acb8be5..79bb016 100644 --- a/src/dota_notes/data/states/player_state.py +++ b/src/dota_notes/data/states/player_state.py @@ -21,12 +21,14 @@ class PlayerState(QObject): gives_up = False destroys_items = False rages_buyback = False + bm_pause = False + resumes_pause = False note = "" ATTRIBUTES_FOR_COPY = ["steam_id", "avatar", "account_level", "medal", "country_code", "pro_name", "custom_name", "match_count", "smurf", "smurf_stratz", "is_racist", "is_sexist", "is_toxic", "is_feeder", "gives_up", "destroys_items", - "rages_buyback", "note"] + "rages_buyback", "bm_pause", "resumes_pause", "note"] def copy_from(self, from_object): """Copy attributes from another object into this diff --git a/src/dota_notes/ui/app_qt.py b/src/dota_notes/ui/app_qt.py index 4d98f51..1d807c5 100644 --- a/src/dota_notes/ui/app_qt.py +++ b/src/dota_notes/ui/app_qt.py @@ -239,6 +239,8 @@ def on_save_player_details(self): player_state.gives_up = self.window.checkBoxDetailsGivesUp.isChecked() player_state.destroys_items = self.window.checkBoxDetailsDestroysItems.isChecked() player_state.rages_buyback = self.window.checkBoxDetailsBuyback.isChecked() + player_state.bm_pause = self.window.checkBoxDetailsPauseWar.isChecked() + player_state.resumes_pause = self.window.checkBoxDetailsResumesPause.isChecked() player_state.note = self.window.inputDetailsNote.toPlainText() self.window.draw_match_player(self.last_selected_index, player_state) with Session(self.dota_notes.database.engine) as session: diff --git a/src/dota_notes/ui/images/resumes_pause.png b/src/dota_notes/ui/images/resumes_pause.png new file mode 100644 index 0000000000000000000000000000000000000000..32d2ab6221c327fc52de17d6324ac425e7ed1b40 GIT binary patch literal 452 zcmV;#0XzPQP)H2 z&nbB4;o+%*wX(%yG0f26Uu0p8J7VN(W;EPE2$^K+9#X3nj6|4Qj(D&8e%%5Q9H@){ zUj||Qe9e&MltQEaYJVaH7b>F_;(*fz*GU44a}C9*H9-_N6r3yXBzNUoD3yd!qov;Wi7k&?8CkbpViWgz9NZkd098r(Rwwc+s ugs!`(ae`;9)V1Edve$9 0) def draw_details_with_player(self, player_state): @@ -124,4 +126,6 @@ def draw_details_with_player(self, player_state): self.checkBoxDetailsGivesUp.setChecked(player_state.gives_up) self.checkBoxDetailsDestroysItems.setChecked(player_state.destroys_items) self.checkBoxDetailsBuyback.setChecked(player_state.rages_buyback) + self.checkBoxDetailsPauseWar.setChecked(player_state.bm_pause) + self.checkBoxDetailsResumesPause.setChecked(player_state.resumes_pause) self.inputDetailsNote.setPlainText(player_state.note) diff --git a/src/dota_notes/ui/resources.qrc b/src/dota_notes/ui/resources.qrc index c3461b4..9b22a5b 100644 --- a/src/dota_notes/ui/resources.qrc +++ b/src/dota_notes/ui/resources.qrc @@ -1,5 +1,6 @@ + images/resumes_pause.png images/evil_pause.png images/rage_buyback.png images/ranks/10.png diff --git a/src/dota_notes/ui/ui_main_window.ui b/src/dota_notes/ui/ui_main_window.ui index cfbe2c4..fd3f1ec 100644 --- a/src/dota_notes/ui/ui_main_window.ui +++ b/src/dota_notes/ui/ui_main_window.ui @@ -1352,7 +1352,7 @@ font: 20pt "Arial"; - <html><head/><body><p>Rage buyback.</p></body></html> + <html><head/><body><p>Rage buyback</p></body></html> @@ -1365,6 +1365,74 @@ font: 20pt "Arial"; + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>BM Pause</p></body></html> + + + + + + :/images/evil_pause.png + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>Resumes Pause</p></body></html> + + + + + + :/images/resumes_pause.png + + + true + + + @@ -1729,7 +1797,7 @@ font: 20pt "Arial"; - <html><head/><body><p>Rage buyback.</p></body></html> + <html><head/><body><p>Rage buyback</p></body></html> @@ -1742,6 +1810,74 @@ font: 20pt "Arial"; + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>BM Pause</p></body></html> + + + + + + :/images/evil_pause.png + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>Resumes Pause</p></body></html> + + + + + + :/images/resumes_pause.png + + + true + + + @@ -2055,7 +2191,7 @@ font: 20pt "Arial"; - <html><head/><body><p>Rage buyback.</p></body></html> + <html><head/><body><p>Rage buyback</p></body></html> @@ -2068,6 +2204,74 @@ font: 20pt "Arial"; + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>BM Pause</p></body></html> + + + + + + :/images/evil_pause.png + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>Resumes Pause</p></body></html> + + + + + + :/images/resumes_pause.png + + + true + + + @@ -2330,7 +2534,7 @@ font: 20pt "Arial"; - <html><head/><body><p>Rage buyback.</p></body></html> + <html><head/><body><p>Rage buyback</p></body></html> @@ -2343,6 +2547,74 @@ font: 20pt "Arial"; + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>BM Pause</p></body></html> + + + + + + :/images/evil_pause.png + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>Resumes Pause</p></body></html> + + + + + + :/images/resumes_pause.png + + + true + + + @@ -2605,7 +2877,7 @@ font: 20pt "Arial"; - <html><head/><body><p>Rage buyback.</p></body></html> + <html><head/><body><p>Rage buyback</p></body></html> @@ -2618,6 +2890,74 @@ font: 20pt "Arial"; + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>BM Pause</p></body></html> + + + + + + :/images/evil_pause.png + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>Resumes Pause</p></body></html> + + + + + + :/images/resumes_pause.png + + + true + + + @@ -2860,7 +3200,75 @@ font: 20pt "Arial"; - + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>Rage buyback</p></body></html> + + + + + + :/images/rage_buyback.png + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>BM Pause</p></body></html> + + + + + + :/images/evil_pause.png + + + true + + + + + 0 @@ -2880,13 +3288,13 @@ font: 20pt "Arial"; - <html><head/><body><p>Rage buyback.</p></body></html> + <html><head/><body><p>Resumes Pause</p></body></html> - :/images/rage_buyback.png + :/images/resumes_pause.png true @@ -3205,7 +3613,7 @@ font: 20pt "Arial";} - <html><head/><body><p>Rage buyback.</p></body></html> + <html><head/><body><p>Rage buyback</p></body></html> @@ -3218,6 +3626,74 @@ font: 20pt "Arial";} + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>BM Pause</p></body></html> + + + + + + :/images/evil_pause.png + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>Resumes Pause</p></body></html> + + + + + + :/images/resumes_pause.png + + + true + + + @@ -3477,7 +3953,7 @@ font: 20pt "Arial";} - <html><head/><body><p>Rage buyback.</p></body></html> + <html><head/><body><p>Rage buyback</p></body></html> @@ -3490,6 +3966,74 @@ font: 20pt "Arial";} + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>BM Pause</p></body></html> + + + + + + :/images/evil_pause.png + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>Resumes Pause</p></body></html> + + + + + + :/images/resumes_pause.png + + + true + + + @@ -3752,7 +4296,7 @@ font: 20pt "Arial";} - <html><head/><body><p>Rage buyback.</p></body></html> + <html><head/><body><p>Rage buyback</p></body></html> @@ -3765,6 +4309,74 @@ font: 20pt "Arial";} + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>BM Pause</p></body></html> + + + + + + :/images/evil_pause.png + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>Resumes Pause</p></body></html> + + + + + + :/images/resumes_pause.png + + + true + + + @@ -4078,7 +4690,7 @@ font: 20pt "Arial"; - <html><head/><body><p>Rage buyback.</p></body></html> + <html><head/><body><p>Rage buyback</p></body></html> @@ -4091,6 +4703,74 @@ font: 20pt "Arial"; + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>BM Pause</p></body></html> + + + + + + :/images/evil_pause.png + + + true + + + + + + + + 0 + 0 + + + + + 24 + 24 + + + + + 24 + 24 + + + + <html><head/><body><p>Resumes Pause</p></body></html> + + + + + + :/images/resumes_pause.png + + + true + + + @@ -5861,6 +6541,13 @@ font: 57 10pt "Roboto Medium"; + + + + Resumes Pause + + +