Skip to content

Commit

Permalink
Ensure person name is longer than 0 on db level
Browse files Browse the repository at this point in the history
  • Loading branch information
derneuere committed Jun 26, 2023
1 parent 16ce656 commit d59a6ce
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 21 additions & 0 deletions api/migrations/0052_alter_person_name.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.1 on 2023-06-26 12:14

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("api", "0051_set_person_defaults"),
]

operations = [
migrations.AlterField(
model_name="person",
name="name",
field=models.CharField(
max_length=128,
validators=[django.core.validators.MinLengthValidator(1)],
),
),
]
5 changes: 4 additions & 1 deletion api/models/person.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import datetime

import pytz
from django.core.validators import MinLengthValidator
from django.db import models
from django.db.models import Prefetch

Expand All @@ -20,7 +21,9 @@ class Person(models.Model):
(KIND_CLUSTER, "Cluster ID"),
(KIND_UNKNOWN, "Unknown Person"),
)
name = models.CharField(blank=False, max_length=128)
name = models.CharField(
blank=False, max_length=128, validators=[MinLengthValidator(1)]
)
kind = models.CharField(choices=KIND_CHOICES, max_length=10)
cover_photo = models.ForeignKey(
Photo, related_name="person", on_delete=models.SET_NULL, blank=False, null=True
Expand Down

0 comments on commit d59a6ce

Please sign in to comment.