Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AlekSIS-App-Paweljong
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Teckids
Projekt Hack-n-Fun
AlekSIS-App-Paweljong
Commits
e6e2a873
Commit
e6e2a873
authored
3 years ago
by
Tom Teichler
Browse files
Options
Downloads
Patches
Plain Diff
Set slug in save method
parent
561e5300
No related branches found
No related tags found
1 merge request
!6
Resolve "Slug for event must not be the short_name of the group"
Pipeline
#56296
failed
3 years ago
Stage: prepare
Stage: test
Stage: build
Stage: publish
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
aleksis/apps/paweljong/migrations/0012_event_slug.py
+1
-1
1 addition, 1 deletion
aleksis/apps/paweljong/migrations/0012_event_slug.py
aleksis/apps/paweljong/models.py
+10
-0
10 additions, 0 deletions
aleksis/apps/paweljong/models.py
with
11 additions
and
1 deletion
aleksis/apps/paweljong/migrations/0012_event_slug.py
+
1
−
1
View file @
e6e2a873
...
...
@@ -13,7 +13,7 @@ class Migration(migrations.Migration):
migrations
.
AddField
(
model_name
=
'
event
'
,
name
=
'
slug
'
,
field
=
models
.
SlugField
(
default
=
''
,
max_length
=
255
,
verbose_name
=
'
Slug
'
),
field
=
models
.
SlugField
(
max_length
=
255
,
verbose_name
=
'
Slug
'
),
preserve_default
=
False
,
),
]
This diff is collapsed.
Click to expand it.
aleksis/apps/paweljong/models.py
+
10
−
0
View file @
e6e2a873
...
...
@@ -4,6 +4,7 @@ from django.db import models
from
django.urls
import
reverse
from
django.utils.timezone
import
now
from
django.utils.translation
import
gettext_lazy
as
_
from
django.utils.text
import
slugify
from
ckeditor.fields
import
RichTextField
from
django_iban.fields
import
IBANField
...
...
@@ -44,6 +45,15 @@ class Event(ExtensibleModel):
information
=
RichTextField
(
verbose_name
=
_
(
"
Information about the event
"
))
terms
=
models
.
ManyToManyField
(
Terms
,
verbose_name
=
_
(
"
Terms
"
),
related_name
=
"
event
"
,
blank
=
True
)
def
save
(
self
.
*
args
,
**
kwargs
):
if
not
self
.
slug
:
if
self
.
linked_group
.
short_name
:
self
.
slug
=
slugify
(
self
.
linked_group
.
short_name
)
else
:
self
.
slug
=
slugify
(
self
.
display_name
)
return
super
().
save
(
*
args
,
**
kwargs
)
def
__str__
(
self
)
->
str
:
return
self
.
display_name
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment