Skip to content

Commit

Permalink
Merge pull request #232 from aiarena/allow_map_disabled
Browse files Browse the repository at this point in the history
Allow maps to be disabled
  • Loading branch information
lladdy authored Mar 24, 2021
2 parents f7be0e6 + e5efc61 commit 1cdb693
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
18 changes: 18 additions & 0 deletions aiarena/core/migrations/0026_map_enabled.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.0.8 on 2021-03-24 20:10

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0025_delete_websitenotice'),
]

operations = [
migrations.AddField(
model_name='map',
name='enabled',
field=models.BooleanField(default=True),
),
]
18 changes: 18 additions & 0 deletions aiarena/core/migrations/0027_mappool_enabled.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.0.8 on 2021-03-24 20:16

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0026_map_enabled'),
]

operations = [
migrations.AddField(
model_name='mappool',
name='enabled',
field=models.BooleanField(default=True),
),
]
4 changes: 4 additions & 0 deletions aiarena/core/models/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ class Map(models.Model):
game_mode = models.ForeignKey(GameMode, on_delete=models.CASCADE, related_name='maps')
competitions = models.ManyToManyField(Competition, related_name='maps', blank=True)
"""The competitions this map is used in."""
enabled = models.BooleanField(default=True)
"""Whether this map is enabled for play.
Note that when this is set to false, it doesn't necessarily mean that the map isn't in a competition's map pool.
In this way the map could still be used for matches."""

def __str__(self):
return self.name
2 changes: 2 additions & 0 deletions aiarena/core/models/map_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
class MapPool(models.Model):
name = models.CharField(max_length=50, unique=True)
maps = models.ManyToManyField(Map, related_name='map_pools')
enabled = models.BooleanField(default=True)
"""Whether this map pool is enabled for play. Currently this only effects match requests."""

def __str__(self):
return self.name
4 changes: 2 additions & 2 deletions aiarena/frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,10 +864,10 @@ class RequestMatchForm(forms.Form):
map_selection_type = forms.ChoiceField(choices=MAP_SELECTION_TYPE,
widget=Select2Widget,
required=True, initial='map_pool')
map = forms.ModelChoiceField(queryset=Map.objects.only('name').order_by('name'),
map = forms.ModelChoiceField(queryset=Map.objects.filter(enabled=True).only('name').order_by('name'),
widget=Select2Widget,
required=False)
map_pool = forms.ModelChoiceField(queryset=MapPool.objects.filter(maps__isnull=False).distinct().only('name').order_by('name'),
map_pool = forms.ModelChoiceField(queryset=MapPool.objects.filter(maps__isnull=False, enabled=True).distinct().only('name').order_by('name'),
widget=Select2Widget,
required=False)

Expand Down

0 comments on commit 1cdb693

Please sign in to comment.