Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
35d9c05a
Verified
Commit
35d9c05a
authored
Sep 29, 2019
by
Sli
Browse files
trombi: fix trombi tools if user has a trombi profile but no trombi linked
parent
fcb3035b
Pipeline
#2037
passed with stage
in 45 minutes and 12 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
trombi/templates/trombi/user_tools.jinja
View file @
35d9c05a
...
...
@@ -12,7 +12,8 @@
{{
subscribe_form.as_p
()
}}
<p><input
type=
"submit"
value=
"
{%
trans
%}
Save
{%
endtrans
%}
"
/></p>
</form>
{%
else
%}
{%
endif
%}
{%
if
trombi
%}
<p>
{%
trans
trombi
=
user.trombi_user.trombi
%}
You are subscribed to the Trombi
{{
trombi
}}{%
endtrans
%}
</p>
<hr>
{%
set
can_comment
=
trombi.subscription_deadline
<
date.today
()
and
...
...
trombi/views.py
View file @
35d9c05a
...
...
@@ -313,9 +313,13 @@ class UserTrombiToolsView(QuickNotifMixin, TrombiTabsMixin, TemplateView):
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
self
.
form
=
UserTrombiForm
(
request
.
POST
)
if
self
.
form
.
is_valid
():
trombi_user
=
TrombiUser
(
user
=
request
.
user
,
trombi
=
self
.
form
.
cleaned_data
[
"trombi"
]
)
if
hasattr
(
request
.
user
,
"trombi_user"
):
trombi_user
=
request
.
user
.
trombi_user
trombi_user
.
trombi
=
self
.
form
.
cleaned_data
[
"trombi"
]
else
:
trombi_user
=
TrombiUser
(
user
=
request
.
user
,
trombi
=
self
.
form
.
cleaned_data
[
"trombi"
]
)
trombi_user
.
save
()
self
.
quick_notif_list
+=
[
"qn_success"
]
return
super
(
UserTrombiToolsView
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
...
...
@@ -323,7 +327,10 @@ class UserTrombiToolsView(QuickNotifMixin, TrombiTabsMixin, TemplateView):
def
get_context_data
(
self
,
**
kwargs
):
kwargs
=
super
(
UserTrombiToolsView
,
self
).
get_context_data
(
**
kwargs
)
kwargs
[
"user"
]
=
self
.
request
.
user
if
not
hasattr
(
self
.
request
.
user
,
"trombi_user"
):
if
not
(
hasattr
(
self
.
request
.
user
,
"trombi_user"
)
and
self
.
request
.
user
.
trombi_user
.
trombi
):
kwargs
[
"subscribe_form"
]
=
UserTrombiForm
()
else
:
kwargs
[
"trombi"
]
=
self
.
request
.
user
.
trombi_user
.
trombi
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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