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

rework AK short name generation

if ': ' cut off starting there
if ' - ' cut off starting there
if ' (' cut off starting there
cut to appropriate length
parent e5ca5640
No related branches found
No related tags found
No related merge requests found
......@@ -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(";")]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment