Skip to content

Commit 66d2fa7

Browse files
philippemilinkartragis
authored andcommitted
Factorisation de code
1 parent a92dcf2 commit 66d2fa7

File tree

1 file changed

+3
-21
lines changed

1 file changed

+3
-21
lines changed

zds/member/forms.py

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -277,27 +277,9 @@ def __init__(self, *args, **kwargs):
277277
# to get initial value form checkbox show email
278278
initial = kwargs.get("initial", {})
279279
self.fields["options"].initial = ""
280-
281-
if "show_sign" in initial and initial["show_sign"]:
282-
self.fields["options"].initial += "show_sign"
283-
284-
if "is_hover_enabled" in initial and initial["is_hover_enabled"]:
285-
self.fields["options"].initial += "is_hover_enabled"
286-
287-
if "allow_temp_visual_changes" in initial and initial["allow_temp_visual_changes"]:
288-
self.fields["options"].initial += "allow_temp_visual_changes"
289-
290-
if "show_markdown_help" in initial and initial["show_markdown_help"]:
291-
self.fields["options"].initial += "show_markdown_help"
292-
293-
if "email_for_answer" in initial and initial["email_for_answer"]:
294-
self.fields["options"].initial += "email_for_answer"
295-
296-
if "email_for_new_mp" in initial and initial["email_for_new_mp"]:
297-
self.fields["options"].initial += "email_for_new_mp"
298-
299-
if "hide_forum_activity" in initial and initial["hide_forum_activity"]:
300-
self.fields["options"].initial += "hide_forum_activity"
280+
for option in [m[0] for m in self.multi_choices]:
281+
if option in initial and initial[option]:
282+
self.fields["options"].initial += option
301283

302284
layout = Layout(
303285
IncludeEasyMDE(),

0 commit comments

Comments
 (0)