Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
radiopanik
django-panik-emissions
Commits
e9bb99e3
Commit
e9bb99e3
authored
Jan 05, 2022
by
fred
Browse files
select newsitem category by default if there is only one
parent
607172e7
Changes
1
Hide whitespace changes
Inline
Side-by-side
emissions/views.py
View file @
e9bb99e3
...
...
@@ -518,6 +518,8 @@ class EmissionNewsItemAdd(CreateView):
initial
[
'emission'
]
=
Emission
.
objects
.
get
(
slug
=
self
.
kwargs
.
get
(
'emission_slug'
))
initial
[
'date'
]
=
datetime
.
datetime
.
today
()
initial
[
'user'
]
=
self
.
request
.
user
if
NewsCategory
.
objects
.
all
().
count
()
==
1
:
initial
[
'category'
]
=
NewsCategory
.
objects
.
select
()[
0
]
return
initial
def
get_context_data
(
self
,
**
kwargs
):
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment