From 3caaa1bd54e5ca714b04e6b271aaba448f9286ec Mon Sep 17 00:00:00 2001 From: lladdy Date: Mon, 28 Feb 2022 16:03:15 +1030 Subject: [PATCH 1/7] Add closing, paused and frozen competitions to the front page. --- aiarena/frontend/views.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aiarena/frontend/views.py b/aiarena/frontend/views.py index 09806f20..79dd978a 100644 --- a/aiarena/frontend/views.py +++ b/aiarena/frontend/views.py @@ -799,7 +799,9 @@ def get_context_data(self, **kwargs): context['events'] = events context['news'] = News.objects.all().order_by('-created') - competitions = Competition.objects.filter(status='open').annotate(num_participants=Count('participations')) + competitions = Competition.objects.filter( + status__in=['frozen','paused','open','closing'])\ + .annotate(num_participants=Count('participations')) # Count active bots of the user in each competition if self.request.user.is_authenticated: competitions = (competitions.annotate(n_active_bots=Sum(Case( From c1ab96df87b95650b049ce572341db50f85b17d9 Mon Sep 17 00:00:00 2001 From: tommy Date: Tue, 8 Mar 2022 17:19:56 +0300 Subject: [PATCH 2/7] Fix hover link color in bot bio --- aiarena/frontend/static/style.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/aiarena/frontend/static/style.css b/aiarena/frontend/static/style.css index d0f75160..ee9a2db4 100644 --- a/aiarena/frontend/static/style.css +++ b/aiarena/frontend/static/style.css @@ -241,6 +241,14 @@ a:hover { text-align: left; } +#bot_bio tr:hover a { + color: #86c232; +} + +#bot_bio tr:hover a:hover { + color: #ffffff; +} + #bot_wiki_article { padding: 0 10px 0 10px; } From 86375a28d3e9a803cc715062842f85092c0578de Mon Sep 17 00:00:00 2001 From: lladdy Date: Fri, 11 Mar 2022 00:55:44 +1030 Subject: [PATCH 3/7] Pre fill match request map pool selection --- aiarena/frontend/views.py | 7 +++++++ aiarena/settings.py | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/aiarena/frontend/views.py b/aiarena/frontend/views.py index 79dd978a..a9ce281e 100644 --- a/aiarena/frontend/views.py +++ b/aiarena/frontend/views.py @@ -995,6 +995,13 @@ def label_from_instance(self, bot_object): class RequestMatchForm(forms.Form): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # Pre fill the map pool selection, for user convenience + self.initial['map_pool'] = MapPool.objects.filter(id=config.MATCH_REQUESTS_PREFILL_MAP_POOL_ID).first() + + MATCHUP_TYPE_CHOICES = ( ('specific_matchup', 'Specific Matchup'), ('random_ladder_bot', 'Random Ladder Bot'), diff --git a/aiarena/settings.py b/aiarena/settings.py index 37228e57..9693471e 100644 --- a/aiarena/settings.py +++ b/aiarena/settings.py @@ -216,6 +216,8 @@ 'MATCH_REQUEST_LIMIT_PLATINUM_TIER': ( 2000, 'The periodic limit of match requests for a platinum patreon tier user.'), 'MATCH_REQUEST_LIMIT_DIAMOND_TIER': (8000, 'The periodic limit of match requests for a diamond patreon tier user.'), + 'MATCH_REQUESTS_PREFILL_MAP_POOL_ID': (0, 'The ID of the map pool that should be selected by default ' + 'when requesting matches.'), 'REQUESTED_MATCHES_LIMIT_PERIOD': ( timedelta(days=30), 'The period length for which a user''s match request limit applies.', timedelta), 'BOT_ZIP_SIZE_LIMIT_IN_MB_FREE_TIER': ( @@ -260,7 +262,7 @@ 'Match Requests': ('MATCH_REQUEST_LIMIT_FREE_TIER', 'MATCH_REQUEST_LIMIT_BRONZE_TIER', 'MATCH_REQUEST_LIMIT_SILVER_TIER', 'MATCH_REQUEST_LIMIT_GOLD_TIER', 'MATCH_REQUEST_LIMIT_PLATINUM_TIER', 'MATCH_REQUEST_LIMIT_DIAMOND_TIER', - 'REQUESTED_MATCHES_LIMIT_PERIOD',), + 'REQUESTED_MATCHES_LIMIT_PERIOD', 'MATCH_REQUESTS_PREFILL_MAP_POOL_ID',), 'File size limits': ('BOT_ZIP_SIZE_LIMIT_IN_MB_FREE_TIER', 'BOT_ZIP_SIZE_LIMIT_IN_MB_BRONZE_TIER', 'BOT_ZIP_SIZE_LIMIT_IN_MB_SILVER_TIER', 'BOT_ZIP_SIZE_LIMIT_IN_MB_GOLD_TIER', 'BOT_ZIP_SIZE_LIMIT_IN_MB_PLATINUM_TIER', 'BOT_ZIP_SIZE_LIMIT_IN_MB_DIAMOND_TIER',), From 2310292e2051e5e69a3d2213cd280c104c8ab0d8 Mon Sep 17 00:00:00 2001 From: Raoni Campos Date: Sat, 19 Mar 2022 18:06:18 +0100 Subject: [PATCH 4/7] Docker local setup --- aiarena/example-dev-env.py | 18 ----------- aiarena/settings.py | 11 ++++--- dockerfile | 14 +++++++++ local/.env | 7 +++++ local/docker-compose.yml | 61 +++++++++++++++++++++++++++++++++++++ local/mysql/custom_init.sql | 3 ++ 6 files changed, 91 insertions(+), 23 deletions(-) delete mode 100644 aiarena/example-dev-env.py create mode 100644 dockerfile create mode 100644 local/.env create mode 100644 local/docker-compose.yml create mode 100644 local/mysql/custom_init.sql diff --git a/aiarena/example-dev-env.py b/aiarena/example-dev-env.py deleted file mode 100644 index c474c43f..00000000 --- a/aiarena/example-dev-env.py +++ /dev/null @@ -1,18 +0,0 @@ -# MAKE A COPY OF THIS FILE CALLED env.py AND CHANGE ANY ENVIRONMENT SETTINGS AS APPROPRIATE - -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'aiarena', - 'USER': 'aiarena', - 'PASSWORD': 'aiarena', - 'HOST': 'localhost', # Or an IP Address that your DB is hosted on - 'PORT': '32768', - 'OPTIONS': { - 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", - }, - # todo: having this enabled will open a transaction for every request and therefore slow down the site - # todo: ideally we will eventually remove this and specify each individual view that needs its own transaction. - 'ATOMIC_REQUESTS': True, - } -} diff --git a/aiarena/settings.py b/aiarena/settings.py index 9693471e..5e1b4632 100644 --- a/aiarena/settings.py +++ b/aiarena/settings.py @@ -48,17 +48,18 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', - 'NAME': 'aiarena', - 'USER': 'aiarena', - 'PASSWORD': 'aiarena', - 'HOST': '127.0.0.1', # Or an IP Address that your DB is hosted on - 'PORT': '3306', + 'NAME': os.getenv('MYSQL_DATABASE', 'aiarena'), + 'USER': os.getenv('MYSQL_USER', 'aiarena'), + 'PASSWORD': os.getenv('MYSQL_PASSWORD', 'aiarena'), + 'HOST': os.getenv('MYSQL_HOST', 'localhost'), + 'PORT': os.getenv('MYSQL_PORT', '3306'), 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", }, } } + # Application definition INSTALLED_APPS = [ diff --git a/dockerfile b/dockerfile new file mode 100644 index 00000000..8e4faeb0 --- /dev/null +++ b/dockerfile @@ -0,0 +1,14 @@ +FROM python:3.7-slim + +RUN apt-get update \ + && apt-get install -y gcc libmariadb-dev + +COPY . /app + +WORKDIR /app/pip +RUN pip install --upgrade pip +RUN python pip-install.py +RUN pip install -r requirements.txt +RUN pip install -r requirements.DEVELOPMENT.txt + +WORKDIR /app \ No newline at end of file diff --git a/local/.env b/local/.env new file mode 100644 index 00000000..c3808b09 --- /dev/null +++ b/local/.env @@ -0,0 +1,7 @@ +# PERSISTENCE LOCAL SETUP +MYSQL_DATABASE=aiarena +MYSQL_USER=aiarena +MYSQL_PASSWORD=aiarena +MYSQL_HOST=aiarena-mysql +MYSQL_PORT=3306 +MYSQL_ROOT_PASSWORD=root_password \ No newline at end of file diff --git a/local/docker-compose.yml b/local/docker-compose.yml new file mode 100644 index 00000000..17d49b87 --- /dev/null +++ b/local/docker-compose.yml @@ -0,0 +1,61 @@ +version: '3.8' + +services: + + aiarena-redis: + image: redis:latest + container_name: aiarena-redis + restart: unless-stopped + ports: + - "6379:6379" + networks: + - aiarena-network + volumes: + - aiarena-redis-data:/data + + aiarena-mysql: + image: mysql:5.7 + container_name: aiarena-mysql + restart: unless-stopped + env_file: + - .env + ports: + - "3306:3306" + networks: + - aiarena-network + volumes: + - ./mysql/custom_init.sql:/docker-entrypoint-initdb.d/1.sql + - aiarena-mysql-data:/var/lib/mysql + + aiarena-web: + build: ../. + container_name: aiarena-web + restart: unless-stopped + env_file: + - .env + ports: + - "8000:8000" + networks: + - aiarena-network + volumes: + - aiarena-web-data:/data + - ../.:/app + depends_on: + - aiarena-redis + - aiarena-mysql + command: > + sh -c "python /app/manage.py collectstatic --noinput && + python /app/manage.py migrate && + python /app/manage.py runserver 0.0.0.0:8000" + + +volumes: + aiarena-redis-data: + name: aiarena-redis-data + aiarena-mysql-data: + name: aiarena-mysql-data + aiarena-web-data: + name: aiarena-web-data + +networks: + aiarena-network: \ No newline at end of file diff --git a/local/mysql/custom_init.sql b/local/mysql/custom_init.sql new file mode 100644 index 00000000..12723894 --- /dev/null +++ b/local/mysql/custom_init.sql @@ -0,0 +1,3 @@ +CREATE DATABASE aiarena; +CREATE USER aiarena IDENTIFIED BY 'aiarena'; +GRANT ALL PRIVILEGES ON aiarena.* TO aiarena WITH GRANT OPTION; \ No newline at end of file From 152c703cdef529de8a991405a33e15c0a5d94c69 Mon Sep 17 00:00:00 2001 From: Raoni Campos Date: Sun, 20 Mar 2022 17:03:19 +0100 Subject: [PATCH 5/7] Moving all new files to docker folder. --- dockerfile => docker/Dockerfile | 0 {local => docker/local}/.env | 0 {local => docker/local}/docker-compose.yml | 4 +++- {local => docker/local}/mysql/custom_init.sql | 0 4 files changed, 3 insertions(+), 1 deletion(-) rename dockerfile => docker/Dockerfile (100%) rename {local => docker/local}/.env (100%) rename {local => docker/local}/docker-compose.yml (94%) rename {local => docker/local}/mysql/custom_init.sql (100%) diff --git a/dockerfile b/docker/Dockerfile similarity index 100% rename from dockerfile rename to docker/Dockerfile diff --git a/local/.env b/docker/local/.env similarity index 100% rename from local/.env rename to docker/local/.env diff --git a/local/docker-compose.yml b/docker/local/docker-compose.yml similarity index 94% rename from local/docker-compose.yml rename to docker/local/docker-compose.yml index 17d49b87..02e27455 100644 --- a/local/docker-compose.yml +++ b/docker/local/docker-compose.yml @@ -28,7 +28,9 @@ services: - aiarena-mysql-data:/var/lib/mysql aiarena-web: - build: ../. + build: + dockerfile: ./docker/Dockerfile + context: ../../ container_name: aiarena-web restart: unless-stopped env_file: diff --git a/local/mysql/custom_init.sql b/docker/local/mysql/custom_init.sql similarity index 100% rename from local/mysql/custom_init.sql rename to docker/local/mysql/custom_init.sql From 321cb1e1c662f7c379f82d2c0d8cd1b012a02a0c Mon Sep 17 00:00:00 2001 From: lladdy Date: Mon, 21 Mar 2022 03:16:06 +1030 Subject: [PATCH 6/7] Re-add example-dev-env.py --- aiarena/example-dev-env.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 aiarena/example-dev-env.py diff --git a/aiarena/example-dev-env.py b/aiarena/example-dev-env.py new file mode 100644 index 00000000..c474c43f --- /dev/null +++ b/aiarena/example-dev-env.py @@ -0,0 +1,18 @@ +# MAKE A COPY OF THIS FILE CALLED env.py AND CHANGE ANY ENVIRONMENT SETTINGS AS APPROPRIATE + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.mysql', + 'NAME': 'aiarena', + 'USER': 'aiarena', + 'PASSWORD': 'aiarena', + 'HOST': 'localhost', # Or an IP Address that your DB is hosted on + 'PORT': '32768', + 'OPTIONS': { + 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", + }, + # todo: having this enabled will open a transaction for every request and therefore slow down the site + # todo: ideally we will eventually remove this and specify each individual view that needs its own transaction. + 'ATOMIC_REQUESTS': True, + } +} From 5f70dd420c76e899e496d7d3cdea161a80359178 Mon Sep 17 00:00:00 2001 From: lladdy Date: Mon, 21 Mar 2022 03:21:56 +1030 Subject: [PATCH 7/7] Revert settings change to try to fix tests --- aiarena/settings.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/aiarena/settings.py b/aiarena/settings.py index 5e1b4632..606b2cfd 100644 --- a/aiarena/settings.py +++ b/aiarena/settings.py @@ -48,11 +48,11 @@ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', - 'NAME': os.getenv('MYSQL_DATABASE', 'aiarena'), - 'USER': os.getenv('MYSQL_USER', 'aiarena'), - 'PASSWORD': os.getenv('MYSQL_PASSWORD', 'aiarena'), - 'HOST': os.getenv('MYSQL_HOST', 'localhost'), - 'PORT': os.getenv('MYSQL_PORT', '3306'), + 'NAME': 'aiarena', + 'USER': 'aiarena', + 'PASSWORD': 'aiarena', + 'HOST': '127.0.0.1', # Or an IP Address that your DB is hosted on + 'PORT': '3306', 'OPTIONS': { 'init_command': "SET sql_mode='STRICT_TRANS_TABLES'", },