Skip to content

Commit

Permalink
Merge pull request #1443 from laws-africa/unique
Browse files Browse the repository at this point in the history
Uniqueness for judges and order outcomes
  • Loading branch information
longhotsummer authored Aug 15, 2023
2 parents 33b15d2 + b480816 commit 2f14860
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
10 changes: 9 additions & 1 deletion peachjam/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,8 @@ class DocumentNatureAdmin(admin.ModelAdmin):
@admin.register(Court)
class CourtAdmin(admin.ModelAdmin):
inlines = [EntityProfileInline]
list_display = ("name", "code")
search_fields = ("name", "code")


@admin.register(Author)
Expand Down Expand Up @@ -913,13 +915,19 @@ class LabelAdmin(admin.ModelAdmin):
class LocalityAdmin(admin.ModelAdmin):
list_display = ("name", "jurisdiction", "code")
prepopulated_fields = {"code": ("name",)}
search_fields = ("name", "code")


@admin.register(Judge)
class JudgeAdmin(admin.ModelAdmin):
list_display = ("name",)
search_fields = ("name",)


admin.site.register(
[
CitationLink,
Attorney,
Judge,
MatterType,
CourtClass,
AttachedFileNature,
Expand Down
51 changes: 51 additions & 0 deletions peachjam/migrations/0096_auto_20230814_1557.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Generated by Django 3.2.20 on 2023-08-14 15:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("peachjam", "0095_api_perms"),
]

operations = [
migrations.AlterField(
model_name="judge",
name="name",
field=models.CharField(max_length=1024, unique=True, verbose_name="name"),
),
migrations.AlterField(
model_name="orderoutcome",
name="name",
field=models.CharField(max_length=1024, unique=True, verbose_name="name"),
),
migrations.AlterField(
model_name="orderoutcome",
name="name_en",
field=models.CharField(
max_length=1024, null=True, unique=True, verbose_name="name"
),
),
migrations.AlterField(
model_name="orderoutcome",
name="name_fr",
field=models.CharField(
max_length=1024, null=True, unique=True, verbose_name="name"
),
),
migrations.AlterField(
model_name="orderoutcome",
name="name_pt",
field=models.CharField(
max_length=1024, null=True, unique=True, verbose_name="name"
),
),
migrations.AlterField(
model_name="orderoutcome",
name="name_sw",
field=models.CharField(
max_length=1024, null=True, unique=True, verbose_name="name"
),
),
]
8 changes: 6 additions & 2 deletions peachjam/models/judgment.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ def __str__(self):


class Judge(models.Model):
name = models.CharField(_("name"), max_length=1024, null=False, blank=False)
name = models.CharField(
_("name"), max_length=1024, null=False, blank=False, unique=True
)
description = models.TextField(_("description"), blank=True)

class Meta:
Expand All @@ -39,7 +41,9 @@ def __str__(self):


class OrderOutcome(models.Model):
name = models.CharField(_("name"), max_length=1024, null=False, blank=False)
name = models.CharField(
_("name"), max_length=1024, null=False, blank=False, unique=True
)
description = models.TextField(_("description"), blank=True)

class Meta:
Expand Down

0 comments on commit 2f14860

Please sign in to comment.