Skip to content

Commit

Permalink
Add Blocklist Support (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kraust authored Jan 25, 2025
1 parent 49be318 commit 45d7a86
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 3 deletions.
13 changes: 12 additions & 1 deletion combatlog/models/combatlog.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from rest_framework.exceptions import APIException

from core.models import BaseModel
from ladder.models import Ladder, LadderEntry
from ladder.models import BlockedHandle, Ladder, LadderEntry

from .metadata import Metadata

Expand Down Expand Up @@ -212,6 +212,17 @@ def update_metadata_file(self, file, force=False):
)
continue

if BlockedHandle.objects.filter(handle=player["handle"]).count():
results.append(
{
"name": full_name,
"updated": False,
"detail": f"{full_name} is banned from the ladder.",
"value": combat_time,
}
)
continue

if (
ladder.manual_review_threshold
and player.get(ladder.metric) > ladder.manual_review_threshold
Expand Down
9 changes: 7 additions & 2 deletions ladder/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from django.db.models import JSONField
from django_json_widget.widgets import JSONEditorWidget

from .models import Ladder, LadderEntry, Variant
from .models import BlockedHandle, Ladder, LadderEntry, Variant


@admin.register(LadderEntry)
class LadderEntryAdmin(admin.ModelAdmin):
exclude = [ "combatlog" ]
exclude = ["combatlog"]
list_display = [
"player",
"ladder__name",
Expand Down Expand Up @@ -76,3 +76,8 @@ class LadderAdmin(admin.ModelAdmin):
@admin.register(Variant)
class VarientAdmin(admin.ModelAdmin):
search_fields = []


@admin.register(BlockedHandle)
class BlockedHandle(admin.ModelAdmin):
search_fields = ["handle"]
33 changes: 33 additions & 0 deletions ladder/migrations/0005_blockedhandle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 4.2.9 on 2025-01-25 16:18

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("ladder", "0004_variant_combat_time_source_and_more"),
]

operations = [
migrations.CreateModel(
name="BlockedHandle",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
(
"handle",
models.TextField(
help_text="Player's @handle. You need to include the '@'"
),
),
],
),
]
1 change: 1 addition & 0 deletions ladder/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .ladder import *
from .ladder_entry import *
from .variant import *
from .blocked_handle import *
12 changes: 12 additions & 0 deletions ladder/models/blocked_handle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""BlockedHandle Models"""

from django.db import models


class BlockedHandle(models.Model):
"""BlockedHandle Model"""

handle = models.TextField(help_text="Player's @handle. You need to include the '@'")

def __str__(self):
return f"{self.handle}"

0 comments on commit 45d7a86

Please sign in to comment.