Skip to content
Snippets Groups Projects
Commit 170c17ef authored by Nadja Geisler's avatar Nadja Geisler :sunny:
Browse files

fix short name

truncate before numbering
remove debug print statements
parent cead814c
No related branches found
No related tags found
No related merge requests found
...@@ -78,15 +78,13 @@ class AKForm(forms.ModelForm): ...@@ -78,15 +78,13 @@ class AKForm(forms.ModelForm):
short_name = short_name.partition(':')[0] short_name = short_name.partition(':')[0]
short_name = short_name.partition(' - ')[0] short_name = short_name.partition(' - ')[0]
short_name = short_name.partition(' (')[0] short_name = short_name.partition(' (')[0]
short_name = short_name[:AK._meta.get_field('short_name').max_length]
for i in itertools.count(1): for i in itertools.count(1):
if not AK.objects.filter(short_name=short_name, event=self.cleaned_data["event"]).exists(): if not AK.objects.filter(short_name=short_name, event=self.cleaned_data["event"]).exists():
break break
print(short_name)
digits = len(str(i)) digits = len(str(i))
print(digits)
short_name = '{}-{}'.format(short_name[:-(digits + 1)], i) short_name = '{}-{}'.format(short_name[:-(digits + 1)], i)
print(short_name) cleaned_data["short_name"] = short_name
cleaned_data["short_name"] = short_name[:AK._meta.get_field('short_name').max_length]
# Get tag names from raw tags # Get tag names from raw tags
cleaned_data["tag_names"] = [name.strip().lower() for name in cleaned_data["tags_raw"].split(";")] cleaned_data["tag_names"] = [name.strip().lower() for name in cleaned_data["tags_raw"].split(";")]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment