Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pretix public registrations
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KIF
Pretix public registrations
Commits
a48e4118
Commit
a48e4118
authored
4 years ago
by
Felix Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
Favor quick returns over long if-else
parent
94affd1e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pretix_public_registrations/signals.py
+25
-28
25 additions, 28 deletions
pretix_public_registrations/signals.py
with
25 additions
and
28 deletions
pretix_public_registrations/signals.py
+
25
−
28
View file @
a48e4118
...
@@ -22,39 +22,36 @@ settings_hierarkey.add_default('public_registrations_show_item_name', False, boo
...
@@ -22,39 +22,36 @@ settings_hierarkey.add_default('public_registrations_show_item_name', False, boo
@receiver
(
html_head
,
dispatch_uid
=
"
public_registrations_html_head
"
)
@receiver
(
html_head
,
dispatch_uid
=
"
public_registrations_html_head
"
)
def
add_public_registrations_html_head
(
sender
,
request
=
None
,
**
kwargs
):
def
add_public_registrations_html_head
(
sender
,
request
=
None
,
**
kwargs
):
url
=
resolve
(
request
.
path_info
)
url
=
resolve
(
request
.
path_info
)
if
"
event.index
"
in
url
.
url_name
:
if
"
event.index
"
not
in
url
.
url_name
:
return
""
cached
=
sender
.
cache
.
get
(
'
public_registrations_html_head
'
)
cached
=
sender
.
cache
.
get
(
'
public_registrations_html_head
'
)
if
cached
is
None
:
if
cached
is
None
:
cached
=
get_template
(
"
pretix_public_registrations/head.html
"
).
render
()
cached
=
get_template
(
"
pretix_public_registrations/head.html
"
).
render
()
sender
.
cache
.
set
(
'
public_registrations_html_head
'
,
cached
)
sender
.
cache
.
set
(
'
public_registrations_html_head
'
,
cached
)
return
cached
return
cached
else
:
return
""
@receiver
(
question_form_fields
,
dispatch_uid
=
"
public_registration_question
"
)
@receiver
(
question_form_fields
,
dispatch_uid
=
"
public_registration_question
"
)
def
add_public_registration_question
(
sender
,
position
,
**
kwargs
):
def
add_public_registration_question
(
sender
,
position
,
**
kwargs
):
if
str
(
position
.
item
.
pk
)
in
sender
.
settings
.
get
(
'
public_registrations_items
'
):
if
str
(
position
.
item
.
pk
)
not
in
sender
.
settings
.
get
(
'
public_registrations_items
'
):
public_questions
=
sender
.
questions
.
filter
(
pk__in
=
sender
.
settings
.
get
(
'
public_registrations_questions
'
)
)
headers
=
(
[
_
(
"
Product
"
)]
if
sender
.
settings
.
get
(
'
public_registrations_show_item_name
'
)
else
[]
)
+
(
[
_
(
"
Name
"
)]
if
sender
.
settings
.
get
(
'
public_registrations_show_attendee_name
'
)
else
[]
)
+
[
q
.
question
for
q
in
public_questions
]
return
{
'
public_registrations_public_registration
'
:
forms
.
BooleanField
(
label
=
_
(
'
Public registration
'
),
required
=
False
,
help_text
=
_
(
'
A gravatar image based on a hash of your e-mail address as well as the answers to
'
'
the following questions will be publicly shown: %(qlist)s
'
)
%
{
'
qlist
'
:
"
,
"
.
join
(
str
(
h
)
for
h
in
headers
)},
)}
else
:
return
{}
return
{}
public_questions
=
sender
.
questions
.
filter
(
pk__in
=
sender
.
settings
.
get
(
'
public_registrations_questions
'
)
)
headers
=
(
[
_
(
"
Product
"
)]
if
sender
.
settings
.
get
(
'
public_registrations_show_item_name
'
)
else
[]
)
+
(
[
_
(
"
Name
"
)]
if
sender
.
settings
.
get
(
'
public_registrations_show_attendee_name
'
)
else
[]
)
+
[
q
.
question
for
q
in
public_questions
]
return
{
'
public_registrations_public_registration
'
:
forms
.
BooleanField
(
label
=
_
(
'
Public registration
'
),
required
=
False
,
help_text
=
_
(
'
A gravatar image based on a hash of your e-mail address as well as the answers to
'
'
the following questions will be publicly shown: %(qlist)s
'
)
%
{
'
qlist
'
:
"
,
"
.
join
(
str
(
h
)
for
h
in
headers
)},
)}
@receiver
(
signal
=
front_page_bottom
,
dispatch_uid
=
"
public_registrations_table
"
)
@receiver
(
signal
=
front_page_bottom
,
dispatch_uid
=
"
public_registrations_table
"
)
...
...
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