diff --git a/AKModel/migrations/0009_add_event_slug_field.py b/AKModel/migrations/0009_add_event_slug_field.py new file mode 100644 index 0000000000000000000000000000000000000000..197e88c4825c7431fa396b9271c2c6d76c318f1b --- /dev/null +++ b/AKModel/migrations/0009_add_event_slug_field.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.6 on 2019-10-16 18:41 + + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('AKModel', '0008_akmodel_reuired_attributes'), + ] + + operations = [ + migrations.AddField( + model_name='event', + name='slug', + field=models.SlugField(help_text='Short name of letters/numbers/dots/dashes/underscores used in URLs.', + max_length=32, null=True, verbose_name='Short Form'), + ), + ] diff --git a/AKModel/migrations/0010_populate_event_slug_field.py b/AKModel/migrations/0010_populate_event_slug_field.py new file mode 100644 index 0000000000000000000000000000000000000000..e797219730b081a7edb8f0049daeec2288d9cb8c --- /dev/null +++ b/AKModel/migrations/0010_populate_event_slug_field.py @@ -0,0 +1,20 @@ +# Generated by Django 2.2.6 on 2019-10-16 18:41 + +from django.db import migrations + + +def gen_slug(apps, schema_editor): + event = apps.get_model('AKModel', 'Event') + for row in event.objects.all(): + row.slug = ''.join(filter(str.isalnum, row.name.lower())) + row.save(update_fields=['slug']) + + +class Migration(migrations.Migration): + dependencies = [ + ('AKModel', '0009_add_event_slug_field'), + ] + + operations = [ + migrations.RunPython(gen_slug, reverse_code=migrations.RunPython.noop) + ] diff --git a/AKModel/migrations/0011_remove_null_event_slug_field.py b/AKModel/migrations/0011_remove_null_event_slug_field.py new file mode 100644 index 0000000000000000000000000000000000000000..ab01b67573d20c4ae9d7095816d439cff51340fd --- /dev/null +++ b/AKModel/migrations/0011_remove_null_event_slug_field.py @@ -0,0 +1,19 @@ +# Generated by Django 2.2.6 on 2019-10-16 18:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ('AKModel', '0010_populate_event_slug_field'), + ] + + operations = [ + migrations.AlterField( + model_name='event', + name='slug', + field=models.SlugField(help_text='Short name of letters/numbers/dots/dashes/underscores used in URLs.', + max_length=32, unique=True, verbose_name='Short Form'), + ), + + ] diff --git a/AKModel/models.py b/AKModel/models.py index 0a3d69dd6028eda0b5fa5d01a77ec63ba373cca1..90ca93f1bb9c554c2e614b072f8f8fb1241a2397 100644 --- a/AKModel/models.py +++ b/AKModel/models.py @@ -1,5 +1,4 @@ # Create your models here. - from django.db import models from django.utils.translation import gettext_lazy as _ @@ -9,6 +8,8 @@ class Event(models.Model): """ name = models.CharField(max_length=64, unique=True, verbose_name=_('Name'), help_text=_('Name or iteration of the event')) + slug = models.SlugField(max_length=32, unique=True, verbose_name=_('Short Form'), + help_text=_('Short name of letters/numbers/dots/dashes/underscores used in URLs.')) start = models.DateTimeField(verbose_name=_('Start'), help_text=_('Time the event begins')) end = models.DateTimeField(verbose_name=_('End'), help_text=_('Time the event ends')) place = models.CharField(max_length=128, blank=True, verbose_name=_('Place'),