Attendee ticket page: Allow to hide prices (#3104)

Co-authored-by: Richard Schreiber <schreiber@rami.io>
This commit is contained in:
Raphael Michel
2023-02-09 14:37:10 +01:00
committed by GitHub
parent fba55f0292
commit 18986caa49
7 changed files with 165 additions and 123 deletions

View File

@@ -662,6 +662,7 @@ class EventSettingsSerializer(SettingsSerializer):
'show_times',
'show_items_outside_presale_period',
'display_net_prices',
'hide_prices_from_attendees',
'presale_start_show_date',
'locales',
'locale',

View File

@@ -195,6 +195,19 @@ DEFAULTS = {
)
},
'hide_prices_from_attendees': {
'default': 'True',
'type': bool,
'form_class': forms.BooleanField,
'serializer_class': serializers.BooleanField,
'form_kwargs': dict(
label=_("Hide prices on attendee ticket page"),
help_text=_("If a person buys multiple tickets and you send emails to all of the attendees, with this "
"option the ticket price will not be shown on the ticket page of the individual attendees. "
"The ticket buyer will of course see the price."),
)
},
'system_question_order': {
'default': {},
'type': dict,

View File

@@ -486,6 +486,7 @@ class EventSettingsForm(SettingsForm):
'show_times',
'show_items_outside_presale_period',
'display_net_prices',
'hide_prices_from_attendees',
'presale_start_show_date',
'locales',
'locale',

View File

@@ -235,6 +235,7 @@
{% bootstrap_field sform.show_times layout="control" %}
{% bootstrap_field sform.show_quota_left layout="control" %}
{% bootstrap_field sform.display_net_prices layout="control" %}
{% bootstrap_field sform.hide_prices_from_attendees layout="control" %}
{% bootstrap_field sform.show_variations_expanded layout="control" %}
{% bootstrap_field sform.hide_sold_out layout="control" %}

View File

@@ -10,15 +10,17 @@
<span role="columnheader" aria-sort="none">{% trans "Product" %}</span>
{% if download %}
<span role="columnheader" aria-sort="none">{% trans "Ticket download" %}</span>
{% else %}
{% elif not hide_prices %}
<span role="columnheader" aria-sort="none">{% trans "Price per item" %}</span>
{% endif %}
<span role="columnheader" aria-sort="none">{% trans "Price total" %}</span>
{% if not hide_prices %}
<span role="columnheader" aria-sort="none">{% trans "Price total" %}</span>
{% endif %}
</div>
</div>
<div role="rowgroup" class="firstchild-in-panel">
{% for line in cart.positions %}
<div role="row" class="row cart-row {% if download %}has-downloads{% endif %}{% if editable %}editable{% endif %}">
<div role="row" class="row cart-row {% if hide_prices %}hide-prices{% endif %} {% if download %}has-downloads{% endif %}{% if editable %}editable{% endif %}">
<div role="cell" class="product">
<p>
{% if line.addon_to %}
@@ -255,20 +257,22 @@
</div>
{% elif line.addon_to %}
<div role="cell" class="count">{% if line.count == 1 %}&nbsp;{% else %}{{ line.count }}{% endif %}</div>
<div role="cell" class="singleprice price">
{% if event.settings.display_net_prices %}
{{ line.net_price|money:event.currency }}
{% else %}
{{ line.price|money:event.currency }}
{% endif %}
{% if line.discount and line.line_price_gross != line.price %}
<span class="text-success discounted" data-toggle="tooltip" title="{% trans "The price of this product was reduced because of an automatic discount." %}">
<br>
<span class="fa fa-percent fa-fw" aria-hidden="true"></span>
{% trans "Discounted" %}
</span>
{% endif %}
</div>
{% if not hide_prices %}
<div role="cell" class="singleprice price">
{% if event.settings.display_net_prices %}
{{ line.net_price|money:event.currency }}
{% else %}
{{ line.price|money:event.currency }}
{% endif %}
{% if line.discount and line.line_price_gross != line.price %}
<span class="text-success discounted" data-toggle="tooltip" title="{% trans "The price of this product was reduced because of an automatic discount." %}">
<br>
<span class="fa fa-percent fa-fw" aria-hidden="true"></span>
{% trans "Discounted" %}
</span>
{% endif %}
</div>
{% endif %}
{% else %}
<div role="cell" class="count">
{% if editable %}
@@ -320,44 +324,48 @@
</form>
{% endif %}
</div>
<div role="cell" class="singleprice price">
{% if not hide_prices %}
<div role="cell" class="singleprice price">
{% if event.settings.display_net_prices %}
{{ line.net_price|money:event.currency }}
{% else %}
{{ line.price|money:event.currency }}
{% endif %}
{% if line.discount and line.line_price_gross != line.price %}
<span class="text-success discounted" data-toggle="tooltip" title="{% trans "The price of this product was reduced because of an automatic discount." %}">
<br>
<span class="fa fa-percent fa-fw" aria-hidden="true"></span>
{% trans "Discounted" %}
</span>
{% endif %}
</div>
{% endif %}
{% endif %}
{% if not hide_prices %}
<div role="cell" class="totalprice price">
{% if event.settings.display_net_prices %}
{{ line.net_price|money:event.currency }}
<strong>{{ line.net_total|money:event.currency }}</strong>
{% if line.tax_rate and line.total %}
<br />
<small>
{% blocktrans trimmed with rate=line.tax_rate|floatformat:-2 taxname=line.tax_rule.name|default:s_taxes %}
<strong>plus</strong> {{ rate }}% {{ taxname }}
{% endblocktrans %}
</small>
{% endif %}
{% else %}
{{ line.price|money:event.currency }}
{% endif %}
{% if line.discount and line.line_price_gross != line.price %}
<span class="text-success discounted" data-toggle="tooltip" title="{% trans "The price of this product was reduced because of an automatic discount." %}">
<br>
<span class="fa fa-percent fa-fw" aria-hidden="true"></span>
{% trans "Discounted" %}
</span>
<strong>{{ line.total|money:event.currency }}</strong>
{% if line.tax_rate and line.total %}
<br />
<small>
{% blocktrans trimmed with rate=line.tax_rate|floatformat:-2 taxname=line.tax_rule.name|default:s_taxes %}
incl. {{ rate }}% {{ taxname }}
{% endblocktrans %}
</small>
{% endif %}
{% endif %}
</div>
{% endif %}
<div role="cell" class="totalprice price">
{% if event.settings.display_net_prices %}
<strong>{{ line.net_total|money:event.currency }}</strong>
{% if line.tax_rate and line.total %}
<br />
<small>
{% blocktrans trimmed with rate=line.tax_rate|floatformat:-2 taxname=line.tax_rule.name|default:s_taxes %}
<strong>plus</strong> {{ rate }}% {{ taxname }}
{% endblocktrans %}
</small>
{% endif %}
{% else %}
<strong>{{ line.total|money:event.currency }}</strong>
{% if line.tax_rate and line.total %}
<br />
<small>
{% blocktrans trimmed with rate=line.tax_rate|floatformat:-2 taxname=line.tax_rule.name|default:s_taxes %}
incl. {{ rate }}% {{ taxname }}
{% endblocktrans %}
</small>
{% endif %}
{% endif %}
</div>
<div class="clearfix"></div>
</div>
{% endfor %}
@@ -366,85 +374,89 @@
<div class="col-md-4 col-xs-6">
<strong>{{ fee.get_fee_type_display }}</strong>
</div>
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
{% if event.settings.display_net_prices %}
<strong>{{ fee.net_value|money:event.currency }}</strong>
{% if fee.tax_rate %}
<br />
<small>
{% blocktrans trimmed with rate=fee.tax_rate|floatformat:-2 taxname=fee.tax_rule.name|default:s_taxes %}
<strong>plus</strong> {{ rate }}% {{ taxname }}
{% endblocktrans %}
</small>
{% if not hide_prices %}
<div class="col-md-3 col-xs-6 col-md-offset-5 price">
{% if event.settings.display_net_prices %}
<strong>{{ fee.net_value|money:event.currency }}</strong>
{% if fee.tax_rate %}
<br />
<small>
{% blocktrans trimmed with rate=fee.tax_rate|floatformat:-2 taxname=fee.tax_rule.name|default:s_taxes %}
<strong>plus</strong> {{ rate }}% {{ taxname }}
{% endblocktrans %}
</small>
{% endif %}
{% else %}
<strong>{{ fee.value|money:event.currency }}</strong>
{% if fee.tax_rate %}
<br />
<small>
{% blocktrans trimmed with rate=fee.tax_rate|floatformat:-2 taxname=fee.tax_rule.name|default:s_taxes %}
incl. {{ rate }}% {{ taxname }}
{% endblocktrans %}
</small>
{% endif %}
{% endif %}
{% else %}
<strong>{{ fee.value|money:event.currency }}</strong>
{% if fee.tax_rate %}
<br />
<small>
{% blocktrans trimmed with rate=fee.tax_rate|floatformat:-2 taxname=fee.tax_rule.name|default:s_taxes %}
incl. {{ rate }}% {{ taxname }}
{% endblocktrans %}
</small>
{% endif %}
{% endif %}
</div>
</div>
{% endif %}
<div class="clearfix"></div>
</div>
{% endfor %}
</div>
<div role="rowgroup">
{% if event.settings.display_net_prices and cart.tax_total %}
<div role="row" class="row cart-row">
<div role="cell" class="product">
<strong>{% trans "Net total" %}</strong>
{% if not hide_prices %}
<div role="rowgroup" class="cart-rowgroup-total">
{% if event.settings.display_net_prices and cart.tax_total %}
<div role="row" class="row cart-row">
<div role="cell" class="product">
<strong>{% trans "Net total" %}</strong>
</div>
<div role="cell" class="count hidden-xs hidden-sm"></div>
<div role="cell" class="singleprice price"></div>
<div role="cell" class="totalprice price">
{{ cart.net_total|money:event.currency }}
</div>
<div class="clearfix"></div>
</div>
<div role="cell" class="count hidden-xs hidden-sm"></div>
<div role="cell" class="singleprice price"></div>
<div role="cell" class="totalprice price">
{{ cart.net_total|money:event.currency }}
<div role="row" class="row cart-row">
<div role="cell" class="product">
<strong>{% trans "Taxes" %}</strong>
</div>
<div role="cell" class="count hidden-xs hidden-sm"></div>
<div role="cell" class="singleprice price"></div>
<div role="cell" class="totalprice price">
{{ cart.tax_total|money:event.currency }}
</div>
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
</div>
<div role="row" class="row cart-row">
<div role="cell" class="product">
<strong>{% trans "Taxes" %}</strong>
{% endif %}
<div role="row" class="row cart-row total">
<div role="cell" class="product">
<strong>{% trans "Total" %}</strong><br>
<span class="text-muted">
{% blocktrans trimmed count num=cart.itemcount %}
One product
{% plural %}
{{ num }} products
{% endblocktrans %}
</span>
</div>
<div role="cell" class="count hidden-xs hidden-sm"></div>
<div role="cell" class="singleprice price"></div>
<div role="cell" class="totalprice price">
<strong>{{ cart.total|money:event.currency }}</strong>
{% if not event.settings.display_net_prices and cart.tax_total %}
<small class="text-muted">
{% blocktrans trimmed with tax_sum=cart.tax_total|money:event.currency %}
incl. {{ tax_sum }} taxes
{% endblocktrans %}
</small>
{% endif %}
</div>
<div class="clearfix"></div>
</div>
<div role="cell" class="count hidden-xs hidden-sm"></div>
<div role="cell" class="singleprice price"></div>
<div role="cell" class="totalprice price">
{{ cart.tax_total|money:event.currency }}
</div>
<div class="clearfix"></div>
</div>
{% endif %}
<div role="row" class="row cart-row total">
<div role="cell" class="product">
<strong>{% trans "Total" %}</strong><br>
<span class="text-muted">
{% blocktrans trimmed count num=cart.itemcount %}
One product
{% plural %}
{{ num }} products
{% endblocktrans %}
</span>
</div>
<div role="cell" class="count hidden-xs hidden-sm"></div>
<div role="cell" class="singleprice price"></div>
<div role="cell" class="totalprice price">
<strong>{{ cart.total|money:event.currency }}</strong>
{% if not event.settings.display_net_prices and cart.tax_total %}
<small class="text-muted">
{% blocktrans trimmed with tax_sum=cart.tax_total|money:event.currency %}
incl. {{ tax_sum }} taxes
{% endblocktrans %}
</small>
{% endif %}
</div>
<div class="clearfix"></div>
</div>
</div>
</div>
<div class="row">

View File

@@ -32,7 +32,7 @@
</h3>
</div>
<div class="panel-body">
{% include "pretixpresale/event/fragment_cart.html" with cart=cart event=request.event download=can_download position_page=True editable=False %}
{% include "pretixpresale/event/fragment_cart.html" with cart=cart event=request.event download=can_download position_page=True editable=False hide_prices=request.event.settings.hide_prices_from_attendees %}
</div>
</div>
<div class="panel panel-primary">

View File

@@ -64,9 +64,15 @@
.singleprice, .totalprice {
width: percentage((3 / $grid-columns));
}
&.hide-prices .product {
width: percentage((10 / $grid-columns));
}
&.has-downloads .product {
width: percentage((5 / $grid-columns));
}
&.has-downloads.hide-prices .product {
width: percentage((8 / $grid-columns));
}
.addon-signifier {
display: inline-block;
padding-left: 10px;
@@ -103,7 +109,7 @@
.cart .firstchild-in-panel .cart-row:first-child {
padding-top: 0;
}
.cart [role=rowgroup]:last-child {
.cart .cart-rowgroup-total {
border-top: 1px solid $table-border-color;
}
.cart .total strong {
@@ -196,15 +202,23 @@
.totalprice {
width: 50%;
}
.product, &.has-downloads .product {
&.hide-prices .product {
width: 75%;
}
.product, &.has-downloads .product, &.has-downloads.hide-prices .product {
width: 100%;
}
&.has-downloads.hide-prices .download-desktop {
margin-left: 50%;
}
&.total .product {
width: 50%;
}
.count {
clear: both;
width: 25%;
}
&:not(.hide-prices) .count {
clear: both;
text-align: left;
}
.singleprice {