Skip to content

Commit

Permalink
Implement option for organisers to deactivate "Continue as a Guest" (f…
Browse files Browse the repository at this point in the history
…ossasia#349)

* Add option for scroll-over color for menu items

* Implement option for organisers to deactivate Continue as a Guest

* Code refactoring

---------

Co-authored-by: Mario Behling <[email protected]>
  • Loading branch information
odkhang and mariobehling authored Oct 2, 2024
1 parent 989d392 commit b875a1e
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 25 deletions.
1 change: 1 addition & 0 deletions src/pretix/api/serializers/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ class EventSettingsSerializer(SettingsSerializer):
'ticket_download_nonadm',
'ticket_download_pending',
'ticket_download_require_validated_email',
'require_registered_account_for_tickets',
'mail_prefix',
'mail_from',
'mail_from_name',
Expand Down
10 changes: 10 additions & 0 deletions src/pretix/base/configurations/default_setting.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,6 +1117,16 @@ def primary_font_kwargs():
"the email. Does not affect orders performed through other sales channels."),
)
},
'require_registered_account_for_tickets' : {
'default': 'False',
'type': bool,
'serializer_class': serializers.BooleanField,
'form_class': forms.BooleanField,
'form_kwargs': dict(
label=_("Only allow registered accounts to get a ticket"),
help_text=_("If this option is turned on, only registered accounts will be allowed to purchase tickets. The 'Continue as a Guest' option will not be available for attendees."),
)
},
'event_list_availability': {
'default': 'True',
'type': bool,
Expand Down
1 change: 1 addition & 0 deletions src/pretix/control/forms/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ class TicketSettingsForm(SettingsForm):
'ticket_download_nonadm',
'ticket_download_pending',
'ticket_download_require_validated_email',
'require_registered_account_for_tickets'
]
ticket_secret_generator = forms.ChoiceField(
label=_("Ticket code generator"),
Expand Down
4 changes: 4 additions & 0 deletions src/pretix/control/templates/pretixcontrol/event/tickets.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ <h3 class="panel-title">
<legend>{% trans "Ticket codes" %}</legend>
{% bootstrap_field form.ticket_secret_generator layout="control" %}
</fieldset>
<fieldset>
<legend>{% trans "Ticket buying settings" %}</legend>
{% bootstrap_field form.require_registered_account_for_tickets layout="control" %}
</fieldset>
</div>
<div class="form-group submit-group">
<button type="submit" class="btn btn-primary btn-save">
Expand Down
6 changes: 4 additions & 2 deletions src/pretix/presale/checkoutflowstep/customer_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def signup_allowed(self):

@cached_property
def guest_allowed(self):
# To Do - check if guest checkout is allowed
return True
if not self.request.event.settings.require_registered_account_for_tickets:
return True
return False

@cached_property
def register_form(self):
Expand Down Expand Up @@ -120,6 +121,7 @@ def post(self, request):
self.cart_session['customer_mode'] = 'guest'
return redirect_to_url(self.get_next_url(request))
else:
messages.error(request, _('By continue, please log in or continue as guest.'))
return self.render()

def is_completed(self, request, warn=False):
Expand Down
49 changes: 26 additions & 23 deletions src/pretix/presale/templates/pretixpresale/event/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -377,29 +377,32 @@ <h3 id="redeem-a-voucher">{% trans "Redeem a voucher" %}</h3>
</form>
</aside>
{% endif %}
{% if not cart_namespace %}
{% eventsignal event "pretix.presale.signals.front_page_bottom" subevent=subevent request=request %}
<aside class="front-page" aria-labelledby="if-you-already-ordered-a-ticket">
<h3 id="if-you-already-ordered-a-ticket">{% trans "If you already ordered a ticket" %}</h3>
<div>
<div class="col-md-8 col-xs-12">
<p>
{% blocktrans trimmed %}
If you want to see or change the status and details of your order, click on the link in one of the
emails we sent you during the order process. If you cannot find the link, click on the
following button to request the link to your order to be sent to you again.
{% endblocktrans %}
</p>
</div>
<div class="col-md-4 col-xs-12">
<a class="btn btn-block btn-default" href="{% eventurl event "presale:event.resend_link" %}">
{% trans "Resend order links" %}
</a>
{% if guest_checkout_allowed %}
{% if not cart_namespace %}
{% eventsignal event "pretix.presale.signals.front_page_bottom" subevent=subevent request=request %}
<aside class="front-page" aria-labelledby="if-you-already-ordered-a-ticket">
<h3 id="if-you-already-ordered-a-ticket">{% trans "If you already ordered a ticket" %}</h3>
<div>
<div class="col-md-8 col-xs-12">
<p>
{% blocktrans trimmed %}
If you want to see or change the status and details of your order, click on the link in
one of the
emails we sent you during the order process. If you cannot find the link, click on the
following button to request the link to your order to be sent to you again.
{% endblocktrans %}
</p>
</div>
<div class="col-md-4 col-xs-12">
<a class="btn btn-block btn-default" href="{% eventurl event "presale:event.resend_link" %}">
{% trans "Resend order links" %}
</a>
</div>
<div class="clearfix"></div>
</div>
<div class="clearfix"></div>
</div>
</aside>
{% else %}
{% eventsignal event "pretix.presale.signals.front_page_bottom_widget" subevent=subevent request=request %}
</aside>
{% else %}
{% eventsignal event "pretix.presale.signals.front_page_bottom_widget" subevent=subevent request=request %}
{% endif %}
{% endif %}
{% endblock %}
2 changes: 2 additions & 0 deletions src/pretix/presale/views/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,8 @@ def get_context_data(self, **kwargs):
if pretix_venueless.apps.PluginApp.name in self.request.event.get_plugins():
context['is_video_plugin_enabled'] = True

context['guest_checkout_allowed'] = not self.request.event.settings.require_registered_account_for_tickets

return context

def _subevent_list_context(self):
Expand Down

0 comments on commit b875a1e

Please sign in to comment.