diff --git a/CHANGELOG.md b/CHANGELOG.md index 14edcd0e..ff8b58e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,22 @@ #Changelog +* 1.7.0: + * Features: + * Added UI and Database based sorting and tagging of fits + * Added config option to have everyone banned by default, so only whitelisted characters have access + * Added config option to disable scruffy mode disable->scruffy_mode + * Added config option to disable public api access without login disable->public_api + * Improvements: + * Some messages and pages related to Teamspeak are now hidden if TS is disabled or no configuration set + * Implemented proper merging of base and user logger config because using pythons dictConfig really isn't very good + * If TS is disabled Teamspeak related pages do not show up anymore, if there is no active TS teamspeak related messages should not show anymore + * Changes: + * Updated minimum version of various python requirements + * Made werkzeug a fix version requirement since it broke between 0.14 and 0.15 also updated to 0.15.2 + * Waitlists on frontpage now use part of the with instead of 1/4th (which made the 5th go into another row) + * Website titles now have the community_name config option at the end + * Fixes: + * Sending data with some from esi forwarded 204 response + * Wrong title on Help page * 1.6.5: * Improvements: * Added import of market groups diff --git a/migrations/versions/afa58b54a8fe_.py b/migrations/versions/afa58b54a8fe_.py deleted file mode 100644 index 2d62c032..00000000 --- a/migrations/versions/afa58b54a8fe_.py +++ /dev/null @@ -1,59 +0,0 @@ -"""empty message - -Revision ID: afa58b54a8fe -Revises: 5d4aee209354 -Create Date: 2019-04-18 17:40:20.275827 - -""" -from alembic import op -import sqlalchemy as sa -from waitlist.utility.sde import update_invtypes -from waitlist.base import db -from waitlist.storage.database import MarketGroup, InvGroup, InvCategory, InvType - -# revision identifiers, used by Alembic. -revision = 'afa58b54a8fe' -down_revision = '5d4aee209354' -branch_labels = None -depends_on = None - - -def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('fk_invmarketgroups_parent_group_id_invmarketgroups', 'invmarketgroups', type_='foreignkey') - # adjust the type for the KF - op.alter_column('invtypes', 'market_group_id', type_=sa.Integer, existing_type=sa.BigInteger) - op.create_foreign_key(op.f('fk_invmarketgroups_parent_group_id_invmarketgroups'), 'invmarketgroups', 'invmarketgroups', ['parent_group_id'], ['market_group_id'], onupdate='CASCADE', ondelete='CASCADE') - - # now we actually need to make sure all of the ones we use FK to are up to date - # this updates market groups and inventory groups+categories - # only do this if there is any inventory data - - market_count = db.session.query(sa.func.count(MarketGroup.marketGroupID)).scalar() - invgroup_count = db.session.query(sa.func.count(InvGroup.groupID)).scalar() - invcat_count = db.session.query(sa.func.count(InvCategory.categoryID)).scalar() - invtype_count = db.session.query(sa.func.count(InvType.typeID)).scalar() - print("Queried counts") - max_count = max(market_count, invgroup_count, invcat_count, invtype_count) - if max_count > 0: - print("We are updating all inventory data now, this can take a while") - update_invtypes() - print("Updating inventory data done") - else: - print("Empty database, no need to upgrade data") - db.session.remove() - - # now we are ready to apply new FKs - op.create_foreign_key(op.f('fk_invtypes_market_group_id_invmarketgroups'), 'invtypes', 'invmarketgroups', ['market_group_id'], ['market_group_id'], onupdate='CASCADE', ondelete='CASCADE') - op.create_foreign_key(op.f('fk_invtypes_group_id_invgroup'), 'invtypes', 'invgroup', ['group_id'], ['group_id'], onupdate='CASCADE', ondelete='CASCADE') - # ### end Alembic commands ### - - -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(op.f('fk_invtypes_group_id_invgroup'), 'invtypes', type_='foreignkey') - op.drop_constraint(op.f('fk_invtypes_market_group_id_invmarketgroups'), 'invtypes', type_='foreignkey') - op.drop_constraint(op.f('fk_invmarketgroups_parent_group_id_invmarketgroups'), 'invmarketgroups', type_='foreignkey') - op.alter_column('invtypes', 'market_group_id', _type=sa.BigInteger, existing_type=sa.Integer) - op.create_foreign_key('fk_invmarketgroups_parent_group_id_invmarketgroups', 'invmarketgroups', 'invmarketgroups', ['parent_group_id'], ['market_group_id']) - # ### end Alembic commands ### diff --git a/migrations/versions/dee8dcee93e4_.py b/migrations/versions/dee8dcee93e4_.py new file mode 100644 index 00000000..11d4f09f --- /dev/null +++ b/migrations/versions/dee8dcee93e4_.py @@ -0,0 +1,158 @@ +"""empty message + +Revision ID: dee8dcee93e4 +Revises: 5d4aee209354 +Create Date: 2019-04-26 15:54:00.665467 + +""" +from alembic import op +import sqlalchemy as sa +from waitlist.storage.database import WaitlistGroup, MarketGroup, InvGroup, InvCategory, InvType +from waitlist.base import db +from waitlist.utility.sde import update_invtypes + +# revision identifiers, used by Alembic. +revision = 'dee8dcee93e4' +down_revision = '5d4aee209354' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('ship_check_collection', + sa.Column('collection_id', sa.Integer(), nullable=False), + sa.Column('collection_name', sa.String(length=50), nullable=True), + sa.Column('waitlist_group_id', sa.Integer(), nullable=True), + sa.Column('default_target_id', sa.Integer(), nullable=True), + sa.Column('default_tag', sa.String(length=20), nullable=True), + sa.ForeignKeyConstraint(['default_target_id'], ['waitlists.id'], name=op.f('fk_ship_check_collection_default_target_id_waitlists'), onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['waitlist_group_id'], ['waitlist_groups.group_id'], name=op.f('fk_ship_check_collection_waitlist_group_id_waitlist_groups'), onupdate='CASCADE', ondelete='CASCADE'), + sa.PrimaryKeyConstraint('collection_id', name=op.f('pk_ship_check_collection')), + sa.UniqueConstraint('waitlist_group_id', name=op.f('uq_ship_check_collection_waitlist_group_id')) + ) + op.create_table('ship_check', + sa.Column('check_id', sa.Integer(), nullable=False), + sa.Column('check_name', sa.String(length=100), nullable=True), + sa.Column('collection_id', sa.Integer(), nullable=True), + sa.Column('check_target_id', sa.Integer(), nullable=False), + sa.Column('check_type', sa.Integer(), nullable=True), + sa.Column('order', sa.Integer(), nullable=True), + sa.Column('modifier', sa.Numeric(precision=5, scale=2), nullable=True), + sa.Column('tag', sa.String(length=20), nullable=True), + sa.ForeignKeyConstraint(['check_target_id'], ['waitlists.id'], name=op.f('fk_ship_check_check_target_id_waitlists'), onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['collection_id'], ['ship_check_collection.collection_id'], name=op.f('fk_ship_check_collection_id_ship_check_collection'), onupdate='CASCADE', ondelete='CASCADE'), + sa.PrimaryKeyConstraint('check_id', name=op.f('pk_ship_check')) + ) + op.create_table('ship_check_groups', + sa.Column('check_id', sa.Integer(), nullable=True), + sa.Column('group_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['check_id'], ['ship_check.check_id'], name=op.f('fk_ship_check_groups_check_id_ship_check'), onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['group_id'], ['invgroup.group_id'], name=op.f('fk_ship_check_groups_group_id_invgroup'), onupdate='CASCADE', ondelete='CASCADE') + ) + op.create_table('ship_check_invtypes', + sa.Column('check_id', sa.Integer(), nullable=True), + sa.Column('type_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['check_id'], ['ship_check.check_id'], name=op.f('fk_ship_check_invtypes_check_id_ship_check'), onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['type_id'], ['invtypes.type_id'], name=op.f('fk_ship_check_invtypes_type_id_invtypes'), onupdate='CASCADE', ondelete='CASCADE') + ) + op.create_table('ship_check_marketgroups', + sa.Column('check_id', sa.Integer(), nullable=True), + sa.Column('market_group_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['check_id'], ['ship_check.check_id'], name=op.f('fk_ship_check_marketgroups_check_id_ship_check'), onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['market_group_id'], ['invmarketgroups.market_group_id'], name=op.f('fk_ship_check_marketgroups_market_group_id_invmarketgroups'), onupdate='CASCADE', ondelete='CASCADE') + ) + op.create_table('ship_check_rest_groups', + sa.Column('check_id', sa.Integer(), nullable=True), + sa.Column('group_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['check_id'], ['ship_check.check_id'], name=op.f('fk_ship_check_rest_groups_check_id_ship_check'), onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['group_id'], ['invgroup.group_id'], name=op.f('fk_ship_check_rest_groups_group_id_invgroup'), onupdate='CASCADE', ondelete='CASCADE') + ) + op.create_table('ship_check_rest_invtypes', + sa.Column('check_id', sa.Integer(), nullable=True), + sa.Column('type_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['check_id'], ['ship_check.check_id'], name=op.f('fk_ship_check_rest_invtypes_check_id_ship_check'), onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['type_id'], ['invtypes.type_id'], name=op.f('fk_ship_check_rest_invtypes_type_id_invtypes'), onupdate='CASCADE', ondelete='CASCADE') + ) + op.create_table('ship_check_rest_marketgroups', + sa.Column('check_id', sa.Integer(), nullable=True), + sa.Column('market_group_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['check_id'], ['ship_check.check_id'], name=op.f('fk_ship_check_rest_marketgroups_check_id_ship_check'), onupdate='CASCADE', ondelete='CASCADE'), + sa.ForeignKeyConstraint(['market_group_id'], ['invmarketgroups.market_group_id'], name=op.f('fk_ship_check_rest_marketgroups_market_group_id_invmarketgroups'), onupdate='CASCADE', ondelete='CASCADE') + ) + op.add_column('fittings', sa.Column('target_waitlist', sa.Integer(), nullable=True)) + op.create_foreign_key(op.f('fk_fittings_target_waitlist_waitlists'), 'fittings', 'waitlists', ['target_waitlist'], ['id'], onupdate='CASCADE', ondelete='CASCADE') + # below here changes the ondelete, onupdate from Restrict to Cascade + op.drop_constraint('fk_invmarketgroups_parent_group_id_invmarketgroups', 'invmarketgroups', type_='foreignkey') + op.create_foreign_key(op.f('fk_invmarketgroups_parent_group_id_invmarketgroups'), 'invmarketgroups', 'invmarketgroups', ['parent_group_id'], ['market_group_id'], onupdate='CASCADE', ondelete='CASCADE') + + # adjust the type for the KF + op.alter_column('invtypes', 'market_group_id', type_=sa.Integer, existing_type=sa.BigInteger) + + # now we actually need to make sure all of the ones we use FK to are up to date + # this updates market groups and inventory groups+categories + # only do this if there is any inventory data + market_count = db.session.query(sa.func.count(MarketGroup.marketGroupID)).scalar() + invgroup_count = db.session.query(sa.func.count(InvGroup.groupID)).scalar() + invcat_count = db.session.query(sa.func.count(InvCategory.categoryID)).scalar() + invtype_count = db.session.query(sa.func.count(InvType.typeID)).scalar() + print("Queried counts") + max_count = max(market_count, invgroup_count, invcat_count, invtype_count) + if max_count > 0: + print("We are updating all inventory data now, this can take a while") + update_invtypes() + print("Updating inventory data done") + else: + print("Empty database, no need to upgrade data") + db.session.remove() + # now we are ready to apply new FKs + op.create_foreign_key(op.f('fk_invtypes_market_group_id_invmarketgroups'), 'invtypes', 'invmarketgroups', ['market_group_id'], ['market_group_id'], onupdate='CASCADE', ondelete='CASCADE') + + op.create_foreign_key(op.f('fk_invtypes_group_id_invgroup'), 'invtypes', 'invgroup', ['group_id'], ['group_id'], onupdate='CASCADE', ondelete='CASCADE') + op.add_column('waitlist_groups', sa.Column('queueID', sa.Integer(), nullable=True)) + wl_groups = db.session.query(WaitlistGroup).all() + for wl_group in wl_groups: + queue_wl = None + for wl in wl_group.waitlists: + if wl.waitlistType == "xup": + queue_wl = wl + break + if queue_wl is None: + print("There is an error with your database, waitlist group", wl_group.groupID, "is missing an xup list") + else: + wl_group.queueID = queue_wl.id + db.session.commit() + # now we can remove the nullable=True + op.alter_column('waitlist_groups', 'queueID', existing_type=sa.Integer(), nullable=False) + op.create_foreign_key(op.f('fk_waitlist_groups_queueID_waitlists'), 'waitlist_groups', 'waitlists', ['queueID'], ['id']) + op.alter_column('fittings', 'wl_type', + existing_type=sa.String(length=10), + type_=sa.String(length=20), + existing_nullable=True) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('fittings', 'wl_type', + existing_type=sa.String(length=20), + type_=sa.String(length=10), + existing_nullable=True) + op.drop_constraint(op.f('fk_waitlist_groups_queueID_waitlists'), 'waitlist_groups', type_='foreignkey') + op.drop_column('waitlist_groups', 'queueID') + op.drop_constraint(op.f('fk_invtypes_group_id_invgroup'), 'invtypes', type_='foreignkey') + op.drop_constraint(op.f('fk_invtypes_market_group_id_invmarketgroups'), 'invtypes', type_='foreignkey') + op.alter_column('invtypes', 'market_group_id', _type=sa.BigInteger, existing_type=sa.Integer) + op.drop_constraint(op.f('fk_invmarketgroups_parent_group_id_invmarketgroups'), 'invmarketgroups', type_='foreignkey') + op.create_foreign_key('fk_invmarketgroups_parent_group_id_invmarketgroups', 'invmarketgroups', 'invmarketgroups', ['parent_group_id'], ['market_group_id']) + op.drop_constraint(op.f('fk_fittings_target_waitlist_waitlists'), 'fittings', type_='foreignkey') + op.drop_column('fittings', 'target_waitlist') + op.drop_table('ship_check_rest_marketgroups') + op.drop_table('ship_check_rest_invtypes') + op.drop_table('ship_check_rest_groups') + op.drop_table('ship_check_marketgroups') + op.drop_table('ship_check_invtypes') + op.drop_table('ship_check_groups') + op.drop_table('ship_check_collection') + op.drop_table('ship_check') + # ### end Alembic commands ### diff --git a/requirements.txt b/requirements.txt index 28a3f89b..9a6f45f0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,17 +1,17 @@ Flask>=1.0.2 -PyYAML>=3.12 -SQLAlchemy>=1.2.7 -Werkzeug>=0.14.1 -alembic>=0.9.9 -bcrypt>=3.1.1 +PyYAML>=5.1 +SQLAlchemy>=1.3.3 +Werkzeug==0.15.2 +alembic>=1.0.9 +bcrypt>=3.1.6 blinker>=1.4 -gevent>=1.3.1 -requests>=2.18.4 +gevent>=1.4.0 +requests>=2.21.0 esipy==0.5.0 Flask-Assets>=0.12 -Flask-htmlmin>=1.2 +Flask-htmlmin>=1.5.0 Flask-Login>=0.4.1 -Flask-Migrate>=2.0.0 +Flask-Migrate>=2.4.0 Flask-Principal>=0.4.0 Flask-SeaSurf>=0.2.2 Flask-SQLAlchemy>=2.3.2 @@ -19,6 +19,6 @@ Flask-CDN>=1.5.3 flask-limiter>=1.0.1 ts3==1.0.6 Flask-Script>=2.0.6 -Flask-Babel>=0.11.2 +Flask-Babel>=0.12.2 csscompressor>=0.9.5 -flasgger>=0.9.0 \ No newline at end of file +flasgger>=0.9.2 diff --git a/setup.py b/setup.py index 1bd6e625..0bed0934 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ setuptools.setup( name="EVE Incursion waitlist", - version="1.6.5", + version="1.7.0", author="SpeedProg", author_email="speedprogde@googlemail.com", description="Waitlist geared towards EveOnline Incursion Groups", diff --git a/setup_shipclassifications.py b/setup_shipclassifications.py new file mode 100644 index 00000000..66ce92e6 --- /dev/null +++ b/setup_shipclassifications.py @@ -0,0 +1,262 @@ +import logging +from decimal import Decimal +from typing import Optional, List, Tuple +from waitlist.storage.database import Waitlist, ShipCheckCollection, ShipCheck,\ + InvType, InvGroup, MarketGroup, WaitlistGroup +from waitlist.base import db +from waitlist.storage import modules +from waitlist.utility.constants import check_types + + + +def add_default_sorting(collection: ShipCheckCollection, logi_wl, dps_wl, sniper_wl): + + # how old WTM sorting worked was to first sort out T2 logi ships :> + check = ShipCheck( + checkName = 'SortOutLogiHulls', + checkTargetID = logi_wl.id, + checkType = check_types.SHIP_CHECK_TYPEID, + order = 0, + modifier = Decimal('1.00'), + checkTag = 'logi' + ) + + collection.checks.append(check) + + for k, v in modules.logi_ships.items(): + inv_type: InvType = db.session.query(InvType).get(k) + if inv_type is None: + print('ERROR NONE', inv_type) + + check.ids.append(inv_type) + + # check dps weapons + check = ShipCheck( + checkName = 'SortToDpsByWeapon', + checkTargetID=dps_wl.id, + checkType = check_types.MODULE_CHECK_TYPEID, + order = 1, + modifier = Decimal('1.00'), + checkTag = 'dps' + ) + + collection.checks.append(check) + + for k, v in modules.dps_weapons.items(): + inv_type = db.session.query(InvType).get(k) + if inv_type is None: + print('ERROR NONE', inv_type) + + check.ids.append(inv_type) + + # check sniper weapons + check = ShipCheck( + checkName = 'SortToSniperByWeapon', + checkTargetID = sniper_wl.id, + checkType = check_types.MODULE_CHECK_TYPEID, + order = 1, + modifier = Decimal('1.00'), + checkTag = 'sniper' + ) + collection.checks.append(check) + + for k, v in modules.sniper_weapons.items(): + inv_type = db.session.query(InvType).get(k) + if inv_type is None: + print('ERROR NONE', inv_type) + + check.ids.append(inv_type) + + # check sniper by market group + check = ShipCheck( + checkName = 'SortToSniperByWeaponMarketGroup', + checkTargetID = sniper_wl.id, + checkType = check_types.MODULE_CHECK_MARKETGROUP, + order = 2, + modifier = Decimal('1.00'), + checkTag = 'sniper' + ) + collection.checks.append(check) + + for k, v in modules.weapongroups['sniper'].items(): + grp = db.session.query(MarketGroup).get(v) + if grp is None: + print('ERROR NONE sniper weapon grps', v) + check.ids.append(grp) + + # check dps by market group + check = ShipCheck( + checkName = 'SortToDpsByWeaponMarketGroup', + checkTargetID = dps_wl.id, + checkType = check_types.MODULE_CHECK_MARKETGROUP, + order = 2, + modifier = Decimal('1.00'), + checkTag = 'dps' + ) + collection.checks.append(check) + + for k, v in modules.weapongroups['dps'].items(): + if v == 2432: # skip Entropic Disintigrators + continue + grp = db.session.query(MarketGroup).get(v) + if grp is None: + print('ERROR NONE dps weapongroups', v) + check.ids.append(grp) + + # special rule for entropic disintigrators because it needs a higher modifier + check = ShipCheck( + checkName = 'SortToSniperEntropicDisintigrators', + checkTargetID = sniper_wl.id, + checkType = check_types.MODULE_CHECK_MARKETGROUP, + order = 2, + modifier = Decimal('4.00'), + checkTag = 'sniper' + ) + collection.checks.append(check) + check.ids.append(db.session.query(MarketGroup).get(2432)) + + # check dps by ship_type + check = ShipCheck( + checkName = 'SortToDpsByShipType', + checkTargetID = dps_wl.id, + checkType = check_types.SHIP_CHECK_TYPEID, + order = 3, + modifier = Decimal('1.00'), + checkTag = 'dps' + ) + collection.checks.append(check) + + for k, v in modules.dps_ships.items(): + inv_type = db.session.query(InvType).get(k) + if inv_type is None: + print('ERROR NONE', inv_type) + check.ids.append(inv_type) + + # sniper ships by typeid + check = ShipCheck( + checkName = 'SortToSniperByShipType', + checkTargetID = sniper_wl.id, + checkType = check_types.SHIP_CHECK_TYPEID, + order = 3, + modifier = Decimal('1.00'), + checkTag = 'sniper' + ) + collection.checks.append(check) + + for k, v in modules.sniper_ships.items(): + inv_type = db.session.query(InvType).get(k) + if inv_type is None: + print('ERROR NONE', inv_type) + check.ids.append(inv_type) + + # dps ships by market group id + check = ShipCheck( + checkName = 'SortToDpsByInvGroup', + checkTargetID = dps_wl.id, + checkType = check_types.SHIP_CHECK_INVGROUP, + order = 4, + modifier = Decimal('1.00'), + checkTag = 'dps' + ) + collection.checks.append(check) + + for k, v in modules.dps_groups.items(): + grp = db.session.query(InvGroup).get(k) + if grp is None: + print('ERROR NONE dps groups', k) + check.ids.append(grp) + + # logiships by marketgroup + check = ShipCheck( + checkName = 'SortToLogiByInvGroup', + checkTargetID = dps_wl.id, + checkType = check_types.SHIP_CHECK_INVGROUP, + order = 4, + modifier = Decimal('1.00'), + checkTag = 'logi' + ) + collection.checks.append(check) + + for k, v in modules.logi_groups.items(): + grp = db.session.query(InvGroup).get(k) + if grp is None: + print('ERROR NONE logi invgroups', k) + check.ids.append(grp) + + + +if __name__ == '__main__': + waitlistGroup = db.session.query(WaitlistGroup).filter(WaitlistGroup.groupName == 'default').one() + + logi_wl = None + dps_wl = None + sniper_wl = None + for wl in waitlistGroup.waitlists: + if wl.waitlistType == 'dps': + dps_wl = wl + if wl.waitlistType == 'logi': + logi_wl = wl + if wl.waitlistType == 'sniper': + sniper_wl = wl + + collection = ShipCheckCollection( + checkCollectionName = 'HQAssignments', + waitlistGroupID = waitlistGroup.groupID, + defaultTargetID = dps_wl.id, + defaultTag = 'other' + ) + + db.session.add(collection) + add_default_sorting(collection, logi_wl, dps_wl, sniper_wl) + db.session.commit() + + + waitlistGroup = db.session.query(WaitlistGroup).filter(WaitlistGroup.groupName == 'assault').one() + + logi_wl = None + dps_wl = None + sniper_wl = None + for wl in waitlistGroup.waitlists: + if wl.waitlistType == 'dps': + dps_wl = wl + if wl.waitlistType == 'logi': + logi_wl = wl + if wl.waitlistType == 'sniper': + sniper_wl = wl + + collection = ShipCheckCollection( + checkCollectionName = 'AssaultAssignments', + waitlistGroupID = waitlistGroup.groupID, + defaultTargetID = dps_wl.id, + defaultTag = 'other' + ) + + db.session.add(collection) + add_default_sorting(collection, logi_wl, dps_wl, sniper_wl) + db.session.commit() + + + waitlistGroup = db.session.query(WaitlistGroup).filter(WaitlistGroup.groupName == 'vanguard').one() + + logi_wl = None + dps_wl = None + sniper_wl = None + for wl in waitlistGroup.waitlists: + if wl.waitlistType == 'dps': + dps_wl = wl + if wl.waitlistType == 'logi': + logi_wl = wl + if wl.waitlistType == 'sniper': + sniper_wl = wl + + collection = ShipCheckCollection( + checkCollectionName = 'VanguardAssignments', + waitlistGroupID = waitlistGroup.groupID, + defaultTargetID = dps_wl.id, + defaultTag = 'other' + ) + + db.session.add(collection) + add_default_sorting(collection, logi_wl, dps_wl, sniper_wl) + db.session.commit() + diff --git a/static/js/ship_assignment/check_edit.js b/static/js/ship_assignment/check_edit.js new file mode 100644 index 00000000..f0bff3c4 --- /dev/null +++ b/static/js/ship_assignment/check_edit.js @@ -0,0 +1,31 @@ +'use strict'; +if (!waitlist) { + var waitlist = {}; +} +if (!waitlist.ship_assignment) { + waitlist.ship_assignment = {}; +} + +waitlist.ship_assignment.check_edit = (function () { + + function init() { + let check_select = $("#check_type"); + check_select.on("change", typeSelectHandler); + updateHiddenElements(parseInt(check_select.val(), 10)); + } + + function typeSelectHandler(event) { + updateHiddenElements(parseInt($(event.target).val(), 10)); + } + + function updateHiddenElements(type_id) { + if (isNaN(type_id)) return; + if (type_id > 3) { + $("#check_add_modifier, #check_add_rest_type_ids, #check_add_rest_invgroup_ids, #check_add_rest_mgroup_ids").parent().prop("hidden", false); + } else { + $("#check_add_modifier, #check_add_rest_type_ids, #check_add_rest_invgroup_ids, #check_add_rest_mgroup_ids").parent().prop("hidden", true); + } + } + + $(document).ready(init); +})(); diff --git a/static/js/ship_assignment/collection.js b/static/js/ship_assignment/collection.js new file mode 100644 index 00000000..3730acc8 --- /dev/null +++ b/static/js/ship_assignment/collection.js @@ -0,0 +1,36 @@ +'use strict'; +if (!waitlist) { + var waitlist = {}; +} +if (!waitlist.ship_assignment) { + waitlist.ship_assignment = {}; +} + +waitlist.ship_assignment.collection = (function () { + + function updateListSelect(group_select, waitlist_selector) { + // "#default_target_id" + const wl_select = $(waitlist_selector); + let enabled_options = wl_select.find("option:not([disabled])"); + enabled_options.prop("hidden", true); + enabled_options.prop("disabled", true); + let options_for_selection = wl_select.find("option[data-group=\"" + group_select.val() + "\"]"); + options_for_selection.prop("disabled", false); + options_for_selection.prop("hidden", false); + // now select one of the enabled options + let option = wl_select.find("option:not([disabled])").first(); + option.prop("selected", true); + } + + function addSubwaitlistPopulationHandler(group_selector, waitlist_selector) { + // "#wl_group_id_select" + $(group_selector).on("change", function(event){ updateListSelect($(event.target), waitlist_selector); }); + } + + function doInitialSubwaitlistPopulation(group_selector, waitlist_selector) { + const group_select = $(group_selector); + updateListSelect(group_select, waitlist_selector); + } + + return {'addSubwaitlistPopulationHandler': addSubwaitlistPopulationHandler, 'doInitialSubwaitlistPopulation': doInitialSubwaitlistPopulation}; +})(); diff --git a/static/js/ship_assignment/collection_edit.js b/static/js/ship_assignment/collection_edit.js new file mode 100644 index 00000000..235825fe --- /dev/null +++ b/static/js/ship_assignment/collection_edit.js @@ -0,0 +1,29 @@ +'use strict'; +if (!waitlist) { + var waitlist = {}; +} +if (!waitlist.ship_assignment) { + waitlist.ship_assignment = {}; +} + +waitlist.ship_assignment.collection_edit = (function () { + + let addSubwaitlistPopulationHandler = waitlist.ship_assignment.collection.addSubwaitlistPopulationHandler; + + function init() { + addSubwaitlistPopulationHandler("#wl_group_id_select", "#default_target_id"); + $("#check_type").on("change", typeSelectHandler); + } + + function typeSelectHandler(event) { + let type = parseInt($(event.target).val(), 10); + if (isNaN(type)) return; + if (type > 3) { + $("#check_add_modifier, #check_add_rest_type_ids, #check_add_rest_invgroup_ids, #check_add_rest_mgroup_ids").parent().prop("hidden", false); + } else { + $("#check_add_modifier, #check_add_rest_type_ids, #check_add_rest_invgroup_ids, #check_add_rest_mgroup_ids").parent().prop("hidden", true); + } + } + + $(document).ready(init); +})(); diff --git a/static/js/ship_assignment/collection_list.js b/static/js/ship_assignment/collection_list.js new file mode 100644 index 00000000..fa448540 --- /dev/null +++ b/static/js/ship_assignment/collection_list.js @@ -0,0 +1,20 @@ +'use strict'; +if (!waitlist) { + var waitlist = {}; +} +if (!waitlist.ship_assignment) { + waitlist.ship_assignment = {}; +} + +waitlist.ship_assignment.collection_list = (function () { + + let addSubwaitlistPopulationHandler = waitlist.ship_assignment.collection.addSubwaitlistPopulationHandler; + let doInitialSubwaitlistPopulation = waitlist.ship_assignment.collection.doInitialSubwaitlistPopulation; + + function init() { + doInitialSubwaitlistPopulation("#wl_group_id_select", "#default_target_id"); + addSubwaitlistPopulation("#wl_group_id_select", "#default_target_id"); + } + + $(document).ready(init); +})(); diff --git a/static/js/waitlist-dom.js b/static/js/waitlist-dom.js index e50f7fd8..85fec540 100644 --- a/static/js/waitlist-dom.js +++ b/static/js/waitlist-dom.js @@ -100,7 +100,7 @@ waitlist.listdom = (function(){ case "other": return "OTHER"; default: - return "UNKNOWN"; + return jsonFit.wl_type; } } @@ -822,4 +822,4 @@ waitlist.listdom = (function(){ setStatusDom: setStatusDom, clearWaitlists: clearWaitlists }; -})(); \ No newline at end of file +})(); diff --git a/templates/base.html b/templates/base.html index 17c9c679..728e44c8 100644 --- a/templates/base.html +++ b/templates/base.html @@ -50,7 +50,7 @@ -
{{ _('Name') }} | {{ _('Actions') }} | {{ _('Target') }} | {{ _('Type') }} | {{ _('Tag') }} | {{ _('Order') }} | {{ _('modifier') }} | {{ _('TypeIDs') }} | {{ _('R by Type') }} | {{ _('R by InvGroup') }} | {{ _('R by Market Group') }} + | + + {% for check in coll.checks %} +
---|---|---|---|---|---|---|---|---|---|---|
{{ check.checkName }} | +{{ _('Edit') }} | +{{ check.checkTargetID }} | +{{ check_type_map[check.checkType] }} | +{{ check.checkTag }} | +{{ check.order }} | +{{ check.modifier }} + | {% for tp in check.ids %}{{ get_pk(tp)[0] }}{% if not loop.last %},{% endif %}{% endfor %} | +{% for type in check.check_rest_types %}{{ get_pk(type)[0] }}{% if not loop.last %},{% endif %}{% endfor %} + | {% for type in check.check_rest_groups %}{{ get_pk(type)[0] }}{% if not loop.last %},{% endif %}{% endfor %} + | {% for type in check.check_rest_market_groups %}{{ get_pk(type)[0] }}{% if not loop.last %},{% endif %}{% endfor %} + |