From dca019c0b5525c9d995422e1d10c9620e04ae0cd Mon Sep 17 00:00:00 2001
From: "N. Geisler" <ngeisler@fachschaft.informatik.tu-darmstadt.de>
Date: Fri, 25 Oct 2019 14:29:15 +0200
Subject: [PATCH] rework AK short name generation

if ': ' cut off starting there
if ' - ' cut off starting there
if ' (' cut off starting there
cut to appropriate length
---
 AKSubmission/forms.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/AKSubmission/forms.py b/AKSubmission/forms.py
index 3bf2bd64..57b94341 100644
--- a/AKSubmission/forms.py
+++ b/AKSubmission/forms.py
@@ -72,7 +72,11 @@ class AKForm(forms.ModelForm):
         # Generate short name if not given
         short_name = self.cleaned_data["short_name"]
         if len(short_name) == 0:
-            cleaned_data["short_name"] = ''.join(x for x in self.cleaned_data["name"].title() if x.isalnum())
+            short_name = self.cleaned_data['name']
+            short_name = short_name.partition(':')[0]
+            short_name = short_name.partition(' - ')[0]
+            short_name = short_name.partition(' (')[0]
+            cleaned_data["short_name"] = short_name[:AK._meta.get_field('short_name').max_length]
 
         # Get tag names from raw tags
         cleaned_data["tag_names"] = [name.strip().lower() for name in cleaned_data["tags_raw"].split(";")]
-- 
GitLab