From 14cdb191c0fe8f4ce6c39b413b9eb404a05e57b0 Mon Sep 17 00:00:00 2001 From: Joliver Date: Sat, 21 Sep 2024 21:44:55 +0200 Subject: [PATCH 1/8] fix: slug now gets created separate to SlugField upon creation --- nablapps/events/models/event.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nablapps/events/models/event.py b/nablapps/events/models/event.py index 3da5d847..b2be701b 100644 --- a/nablapps/events/models/event.py +++ b/nablapps/events/models/event.py @@ -8,6 +8,7 @@ from django.core.exceptions import ValidationError from django.db import IntegrityError, models from django.urls import reverse +from django.utils.text import slugify from nablapps.core.models import TimeStamped, WithPicture from nablapps.jobs.models import Company @@ -124,6 +125,8 @@ def get_short_name(self): ) def save(self, *args, **kwargs): + if not self.slug: + self.slug = slugify(self.headline) super().save(*args, **kwargs) self.move_waiting_to_attending() From c7fe6b4f796164cd6f520c72eb0e77a00bc3aea0 Mon Sep 17 00:00:00 2001 From: Joliver Date: Sun, 22 Sep 2024 11:07:39 +0200 Subject: [PATCH 2/8] update: headline is limited to 50 characters --- .../migrations/0015_alter_event_headline.py | 18 ++++++++++++++++++ nablapps/events/models/event.py | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 nablapps/events/migrations/0015_alter_event_headline.py diff --git a/nablapps/events/migrations/0015_alter_event_headline.py b/nablapps/events/migrations/0015_alter_event_headline.py new file mode 100644 index 00000000..40de26aa --- /dev/null +++ b/nablapps/events/migrations/0015_alter_event_headline.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.25 on 2024-09-22 10:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("events", "0014_auto_20220702_1315"), + ] + + operations = [ + migrations.AlterField( + model_name="event", + name="headline", + field=models.CharField(blank=True, max_length=50, verbose_name="tittel"), + ), + ] diff --git a/nablapps/events/models/event.py b/nablapps/events/models/event.py index b2be701b..b56310c2 100644 --- a/nablapps/events/models/event.py +++ b/nablapps/events/models/event.py @@ -30,6 +30,8 @@ class Event( Dukker opp som nyheter på forsiden. """ + headline = models.CharField(blank=True, max_length=50, verbose_name="tittel") + # Penalty_rules is a dict where key is an integer and value is # a tuple with the name of the rule as first element and # a dictionary with the rules as second element. From 95d1f086ed8cb112a5a43b298b27ffd7ed7ced71 Mon Sep 17 00:00:00 2001 From: Joliver Date: Sun, 22 Sep 2024 11:40:43 +0200 Subject: [PATCH 3/8] Revert "fix: slug now gets created separate to SlugField upon creation" This reverts commit 14cdb191c0fe8f4ce6c39b413b9eb404a05e57b0. --- nablapps/events/models/event.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/nablapps/events/models/event.py b/nablapps/events/models/event.py index b56310c2..c8981a60 100644 --- a/nablapps/events/models/event.py +++ b/nablapps/events/models/event.py @@ -8,7 +8,6 @@ from django.core.exceptions import ValidationError from django.db import IntegrityError, models from django.urls import reverse -from django.utils.text import slugify from nablapps.core.models import TimeStamped, WithPicture from nablapps.jobs.models import Company @@ -127,8 +126,6 @@ def get_short_name(self): ) def save(self, *args, **kwargs): - if not self.slug: - self.slug = slugify(self.headline) super().save(*args, **kwargs) self.move_waiting_to_attending() From 4063af9e15f8d5ce100730e557944b1b4be43498 Mon Sep 17 00:00:00 2001 From: Joliver Date: Sun, 22 Sep 2024 11:41:32 +0200 Subject: [PATCH 4/8] Reapply "fix: slug now gets created separate to SlugField upon creation" This reverts commit 95d1f086ed8cb112a5a43b298b27ffd7ed7ced71. --- nablapps/events/models/event.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nablapps/events/models/event.py b/nablapps/events/models/event.py index c8981a60..b56310c2 100644 --- a/nablapps/events/models/event.py +++ b/nablapps/events/models/event.py @@ -8,6 +8,7 @@ from django.core.exceptions import ValidationError from django.db import IntegrityError, models from django.urls import reverse +from django.utils.text import slugify from nablapps.core.models import TimeStamped, WithPicture from nablapps.jobs.models import Company @@ -126,6 +127,8 @@ def get_short_name(self): ) def save(self, *args, **kwargs): + if not self.slug: + self.slug = slugify(self.headline) super().save(*args, **kwargs) self.move_waiting_to_attending() From 940d4f3b81c935bfbfb25d6e8fb35cf43e7f4f82 Mon Sep 17 00:00:00 2001 From: Joliver Date: Sun, 22 Sep 2024 11:43:21 +0200 Subject: [PATCH 5/8] rm: migration not working with db --- .../migrations/0015_alter_event_headline.py | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 nablapps/events/migrations/0015_alter_event_headline.py diff --git a/nablapps/events/migrations/0015_alter_event_headline.py b/nablapps/events/migrations/0015_alter_event_headline.py deleted file mode 100644 index 40de26aa..00000000 --- a/nablapps/events/migrations/0015_alter_event_headline.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.2.25 on 2024-09-22 10:59 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("events", "0014_auto_20220702_1315"), - ] - - operations = [ - migrations.AlterField( - model_name="event", - name="headline", - field=models.CharField(blank=True, max_length=50, verbose_name="tittel"), - ), - ] From a193d9bad2567aa708140270b90f2222e39f276e Mon Sep 17 00:00:00 2001 From: Joliver Date: Sun, 22 Sep 2024 11:52:14 +0200 Subject: [PATCH 6/8] feat: allows 100 characters for slug --- .../events/migrations/0015_alter_event_slug.py | 18 ++++++++++++++++++ nablapps/events/models/event.py | 4 +--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 nablapps/events/migrations/0015_alter_event_slug.py diff --git a/nablapps/events/migrations/0015_alter_event_slug.py b/nablapps/events/migrations/0015_alter_event_slug.py new file mode 100644 index 00000000..3bb2b747 --- /dev/null +++ b/nablapps/events/migrations/0015_alter_event_slug.py @@ -0,0 +1,18 @@ +# Generated by Django 3.2.25 on 2024-09-22 11:50 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("events", "0014_auto_20220702_1315"), + ] + + operations = [ + migrations.AlterField( + model_name="event", + name="slug", + field=models.CharField(blank=True, max_length=100, null=True), + ), + ] diff --git a/nablapps/events/models/event.py b/nablapps/events/models/event.py index b56310c2..c93f70aa 100644 --- a/nablapps/events/models/event.py +++ b/nablapps/events/models/event.py @@ -30,7 +30,7 @@ class Event( Dukker opp som nyheter på forsiden. """ - headline = models.CharField(blank=True, max_length=50, verbose_name="tittel") + slug = models.CharField(blank=True, null=True, max_length=100) # Penalty_rules is a dict where key is an integer and value is # a tuple with the name of the rule as first element and @@ -127,8 +127,6 @@ def get_short_name(self): ) def save(self, *args, **kwargs): - if not self.slug: - self.slug = slugify(self.headline) super().save(*args, **kwargs) self.move_waiting_to_attending() From 262d1d478fd088abbf2579519a14c6582ddfb672 Mon Sep 17 00:00:00 2001 From: Joliver Date: Sun, 22 Sep 2024 11:57:38 +0200 Subject: [PATCH 7/8] chore: remove unnecessary code --- nablapps/events/models/event.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/nablapps/events/models/event.py b/nablapps/events/models/event.py index c6f2444f..c6446639 100644 --- a/nablapps/events/models/event.py +++ b/nablapps/events/models/event.py @@ -8,7 +8,6 @@ from django.core.exceptions import ValidationError from django.db import IntegrityError, models from django.urls import reverse -from django.utils.text import slugify from nablapps.core.models import TimeStamped, WithPicture from nablapps.jobs.models import Company @@ -32,7 +31,6 @@ class Event( slug = models.CharField(blank=True, null=True, max_length=100) - # Penalty_rules is a dict where key is an integer and value is # a tuple with the name of the rule as first element and # a dictionary with the rules as second element. @@ -128,8 +126,6 @@ def get_short_name(self): ) def save(self, *args, **kwargs): - if not self.slug: - self.slug = slugify(self.headline) super().save(*args, **kwargs) self.move_waiting_to_attending() From f46aa7667fec0ce71c2c26f2069255c78c470d16 Mon Sep 17 00:00:00 2001 From: Joliver Date: Sun, 22 Sep 2024 11:58:22 +0200 Subject: [PATCH 8/8] rm: non working migration --- .../migrations/0015_alter_event_headline.py | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 nablapps/events/migrations/0015_alter_event_headline.py diff --git a/nablapps/events/migrations/0015_alter_event_headline.py b/nablapps/events/migrations/0015_alter_event_headline.py deleted file mode 100644 index 40de26aa..00000000 --- a/nablapps/events/migrations/0015_alter_event_headline.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 3.2.25 on 2024-09-22 10:59 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("events", "0014_auto_20220702_1315"), - ] - - operations = [ - migrations.AlterField( - model_name="event", - name="headline", - field=models.CharField(blank=True, max_length=50, verbose_name="tittel"), - ), - ]