Add text limit to about fields

This commit is contained in:
cuom1999 2024-04-12 12:09:40 -05:00
parent 208a4e4ef7
commit 08eef6408f
2 changed files with 49 additions and 2 deletions

View file

@ -0,0 +1,43 @@
# Generated by Django 3.2.18 on 2024-04-12 17:04
from django.db import migrations, models
def truncate_about_text(apps, schema_editor):
Organization = apps.get_model("judge", "Organization")
Profile = apps.get_model("judge", "Profile")
for org in Organization.objects.all():
if len(org.about) > 10000:
org.about = org.about[:10000]
org.save()
for profile in Profile.objects.all():
if profile.about and len(profile.about) > 10000:
profile.about = profile.about[:10000]
profile.save()
class Migration(migrations.Migration):
dependencies = [
("judge", "0185_rename_org_profile_colum"),
]
operations = [
migrations.RunPython(truncate_about_text),
migrations.AlterField(
model_name="organization",
name="about",
field=models.CharField(
max_length=10000, verbose_name="organization description"
),
),
migrations.AlterField(
model_name="profile",
name="about",
field=models.CharField(
blank=True, max_length=10000, null=True, verbose_name="self-description"
),
),
]

View file

@ -55,7 +55,9 @@ class Organization(models.Model):
verbose_name=_("short name"),
help_text=_("Displayed beside user name during contests"),
)
about = models.TextField(verbose_name=_("organization description"))
about = models.CharField(
max_length=10000, verbose_name=_("organization description")
)
registrant = models.ForeignKey(
"Profile",
verbose_name=_("registrant"),
@ -154,7 +156,9 @@ class Profile(models.Model):
user = models.OneToOneField(
User, verbose_name=_("user associated"), on_delete=models.CASCADE
)
about = models.TextField(verbose_name=_("self-description"), null=True, blank=True)
about = models.CharField(
max_length=10000, verbose_name=_("self-description"), null=True, blank=True
)
timezone = models.CharField(
max_length=50,
verbose_name=_("location"),