Loading cog/actions.py +10 −2 Original line number Diff line number Diff line Loading @@ -1749,16 +1749,24 @@ class UM(Action): if self.args.offset: system.map_offset = self.args.offset if self.args.priority: try: cogdb.query.get_admin(self.session, self.duser) except cog.exc.NoMatch as exc: raise cog.exc.InvalidPerms("{} You are not an admin!".format(self.msg.author.mention)) from exc system.priority = " ".join(self.args.priority) self.payloads += cogdb.scanners.UMScanner.update_systemum_priority_dict(system.sheet_col, system.priority) if self.args.set: system.set_status(self.args.set) if self.args.set or self.args.offset: self.session.commit() # TODO: Same payload now, but will have to switch if diverge. self.payloads += cogdb.scanners.UMScanner.update_systemum_dict( system.sheet_col, system.progress_us, system.progress_them, system.map_offset ) if self.payloads: self.session.commit() scanner = get_scanner("hudson_undermine" if self.args.sheet_src == EUMSheet.main else "hudson_snipe") await scanner.send_batch(self.payloads) Loading cog/parse.py +4 −0 Original line number Diff line number Diff line Loading @@ -679,6 +679,9 @@ def subs_um(subs, prefix): **{prefix}um burr --offset 4000** **{prefix}um burr -o 4000** Set the offset difference of cmdr merits and galmap. **{prefix}um burr --priority Medium** **{prefix}um burr -p Medium** Set the priority for the undermining system. **{prefix}um --list** Show all outstanding merits by users and system. **{prefix}um --npcs** Loading @@ -691,6 +694,7 @@ def subs_um(subs, prefix): sub.add_argument('-s', '--set', help='Set the status of the system, us:them. Example-> --set 3500:200') sub.add_argument('-o', '--offset', type=int, help='Set the system galmap offset.') sub.add_argument('-p', '--priority', nargs='+', help='The priority to set for the system.') sub.add_argument('-l', '--list', action='store_true', help='Show all outstanding merits on sheet.') sub.add_argument('--npcs', action='store_true', help='List powerplay NPC ships by alligence.') Loading cogdb/scanners.py +15 −0 Original line number Diff line number Diff line Loading @@ -455,6 +455,21 @@ class UMScanner(FortScanner): values = [[progress_us], [progress_them], ['Hold Merits'], [map_offset]] return [{'range': cell_range, 'values': values}] @staticmethod def update_systemum_priority_dict(col, priority): """ Create an update system dict. See AsyncGSheet.batch_update Args: col: The main (left most) column of the system in sheet. priority: The new priority to set. Returns: A list of update dicts to pass to batch_update. """ column = cog.sheets.Column(col) cell_range = '{col}8:{col}8'.format(col=column.fwd()) return [{'range': cell_range, 'values': [[priority]]}] @staticmethod def update_hold_dict(system_col, user_row, held, redeemed): """ Loading tests/cog/test_actions.py +13 −0 Original line number Diff line number Diff line Loading @@ -1474,6 +1474,19 @@ async def test_cmd_um_npcs(f_bot): assert call_args_list[0][1]['embed'] is not call_args_list[1][1]['embed'] @pytest.mark.asyncio async def test_cmd_um_priority(f_bot, f_dusers, f_um_testbed, f_admins, patch_scanners): msg = fake_msg_gears("!um Burr --priority High") await action_map(msg, f_bot).execute() with cogdb.session_scope(cogdb.Session) as session: burr = session.query(UMSystem).filter(UMSystem.name == "Burr").one() assert burr.priority == 'High' assert patch_scanners.payloads == [{'range': 'I8:I8', 'values': [['High']]}] @pytest.mark.asyncio async def test_cmd_user(f_bot, f_testbed): msg = fake_msg_gears("!user") Loading tests/cogdb/test_scanners.py +5 −0 Original line number Diff line number Diff line Loading @@ -225,6 +225,11 @@ async def test_umscanner_parse_sheet(f_asheet_umscanner, f_dusers_many, session, assert session.query(UMHold).all() def test_umscanner_update_systemsum_priority_dict(): data = UMScanner.update_systemum_priority_dict("G", "Medium Priority") assert data == [{'range': 'H8:H8', 'values': [['Medium Priority']]}] def test_umscanner_update_systemsum_dict(): data = UMScanner.update_systemum_dict("G", 7000, 500, 4300) assert data == [{"range": "G10:G13", "values": [[7000], [500], ["Hold Merits"], [4300]]}] Loading Loading
cog/actions.py +10 −2 Original line number Diff line number Diff line Loading @@ -1749,16 +1749,24 @@ class UM(Action): if self.args.offset: system.map_offset = self.args.offset if self.args.priority: try: cogdb.query.get_admin(self.session, self.duser) except cog.exc.NoMatch as exc: raise cog.exc.InvalidPerms("{} You are not an admin!".format(self.msg.author.mention)) from exc system.priority = " ".join(self.args.priority) self.payloads += cogdb.scanners.UMScanner.update_systemum_priority_dict(system.sheet_col, system.priority) if self.args.set: system.set_status(self.args.set) if self.args.set or self.args.offset: self.session.commit() # TODO: Same payload now, but will have to switch if diverge. self.payloads += cogdb.scanners.UMScanner.update_systemum_dict( system.sheet_col, system.progress_us, system.progress_them, system.map_offset ) if self.payloads: self.session.commit() scanner = get_scanner("hudson_undermine" if self.args.sheet_src == EUMSheet.main else "hudson_snipe") await scanner.send_batch(self.payloads) Loading
cog/parse.py +4 −0 Original line number Diff line number Diff line Loading @@ -679,6 +679,9 @@ def subs_um(subs, prefix): **{prefix}um burr --offset 4000** **{prefix}um burr -o 4000** Set the offset difference of cmdr merits and galmap. **{prefix}um burr --priority Medium** **{prefix}um burr -p Medium** Set the priority for the undermining system. **{prefix}um --list** Show all outstanding merits by users and system. **{prefix}um --npcs** Loading @@ -691,6 +694,7 @@ def subs_um(subs, prefix): sub.add_argument('-s', '--set', help='Set the status of the system, us:them. Example-> --set 3500:200') sub.add_argument('-o', '--offset', type=int, help='Set the system galmap offset.') sub.add_argument('-p', '--priority', nargs='+', help='The priority to set for the system.') sub.add_argument('-l', '--list', action='store_true', help='Show all outstanding merits on sheet.') sub.add_argument('--npcs', action='store_true', help='List powerplay NPC ships by alligence.') Loading
cogdb/scanners.py +15 −0 Original line number Diff line number Diff line Loading @@ -455,6 +455,21 @@ class UMScanner(FortScanner): values = [[progress_us], [progress_them], ['Hold Merits'], [map_offset]] return [{'range': cell_range, 'values': values}] @staticmethod def update_systemum_priority_dict(col, priority): """ Create an update system dict. See AsyncGSheet.batch_update Args: col: The main (left most) column of the system in sheet. priority: The new priority to set. Returns: A list of update dicts to pass to batch_update. """ column = cog.sheets.Column(col) cell_range = '{col}8:{col}8'.format(col=column.fwd()) return [{'range': cell_range, 'values': [[priority]]}] @staticmethod def update_hold_dict(system_col, user_row, held, redeemed): """ Loading
tests/cog/test_actions.py +13 −0 Original line number Diff line number Diff line Loading @@ -1474,6 +1474,19 @@ async def test_cmd_um_npcs(f_bot): assert call_args_list[0][1]['embed'] is not call_args_list[1][1]['embed'] @pytest.mark.asyncio async def test_cmd_um_priority(f_bot, f_dusers, f_um_testbed, f_admins, patch_scanners): msg = fake_msg_gears("!um Burr --priority High") await action_map(msg, f_bot).execute() with cogdb.session_scope(cogdb.Session) as session: burr = session.query(UMSystem).filter(UMSystem.name == "Burr").one() assert burr.priority == 'High' assert patch_scanners.payloads == [{'range': 'I8:I8', 'values': [['High']]}] @pytest.mark.asyncio async def test_cmd_user(f_bot, f_testbed): msg = fake_msg_gears("!user") Loading
tests/cogdb/test_scanners.py +5 −0 Original line number Diff line number Diff line Loading @@ -225,6 +225,11 @@ async def test_umscanner_parse_sheet(f_asheet_umscanner, f_dusers_many, session, assert session.query(UMHold).all() def test_umscanner_update_systemsum_priority_dict(): data = UMScanner.update_systemum_priority_dict("G", "Medium Priority") assert data == [{'range': 'H8:H8', 'values': [['Medium Priority']]}] def test_umscanner_update_systemsum_dict(): data = UMScanner.update_systemum_dict("G", 7000, 500, 4300) assert data == [{"range": "G10:G13", "values": [[7000], [500], ["Hold Merits"], [4300]]}] Loading