Skip to content

Commit

Permalink
Use get_host instead of request META
Browse files Browse the repository at this point in the history
  • Loading branch information
rebkwok committed Aug 16, 2024
1 parent 20dec5d commit 5596cfc
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def form_valid(self, form):
disclaimer = form.save(commit=False)
disclaimer.version = form.disclaimer_content.version
email = disclaimer.email
host = 'https://{}'.format(self.request.META.get('HTTP_HOST'))
host = 'https://{}'.format(self.request.get_host())
ctx = {
'host': host,
'contact_email': settings.DEFAULT_STUDIO_EMAIL
Expand Down
2 changes: 1 addition & 1 deletion booking/views/block_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def form_valid(self, form):
)
)

host = 'http://{}'.format(self.request.META.get('HTTP_HOST'))
host = 'http://{}'.format(self.request.get_host())
# send email to user
ctx = {
'host': host,
Expand Down
10 changes: 5 additions & 5 deletions booking/views/booking_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def form_valid(self, form):
if booking.block:
# send email to user if they used block to book (paypal payment
# sends separate emails
host = 'http://{}'.format(self.request.META.get('HTTP_HOST'))
host = 'http://{}'.format(self.request.get_host())
if booking.event.event_type.event_type == 'EV':
ev_type = 'event'
elif booking.event.event_type.event_type == 'CL':
Expand Down Expand Up @@ -366,7 +366,7 @@ def _email_free_class_request(request, booking, booking_status):
booking.block = None

# send email and set messages
host = 'http://{}'.format(request.META.get('HTTP_HOST'))
host = 'http://{}'.format(request.get_host())
# send email to studio
ctx = {
'host': host,
Expand Down Expand Up @@ -452,7 +452,7 @@ def form_valid(self, _form):
# Check here so we can adjust the email message
block_or_membership_booked_within_allowed_time = self._block_or_membership_booked_within_allowed_time(booking)

host = 'http://{}'.format(self.request.META.get('HTTP_HOST'))
host = 'http://{}'.format(self.request.get_host())

# email if this isn't an unpaid/non-rebooked booking
# send email to user
Expand Down Expand Up @@ -650,7 +650,7 @@ def form_valid(self, _form):
send_waiting_list_email(
event,
[wluser.user for wluser in waiting_list_users],
host='http://{}'.format(self.request.META.get('HTTP_HOST'))
host='http://{}'.format(self.request.get_host())
)
ActivityLog.objects.create(
log='Waiting list email sent to user(s) {} for '
Expand Down Expand Up @@ -917,7 +917,7 @@ def assign_block(booking):
booking.event, booking.user.username)
)

host = 'http://{}'.format(request.META.get('HTTP_HOST'))
host = 'http://{}'.format(request.get_host())

# send email to user ONLY IF PAID
# If it's unpaid, they'll get the email with payment/update
Expand Down
2 changes: 1 addition & 1 deletion booking/views/shopping_basket_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def update_block_bookings(request):
messages.info(request, "Blocks used for {} bookings".format(len(block_booked)))

# send email to user
host = 'http://{}'.format(request.META.get('HTTP_HOST'))
host = 'http://{}'.format(request.get_host())
ctx = {
'host': host,
'bookings': block_booked,
Expand Down
4 changes: 2 additions & 2 deletions booking/views/ticketed_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def post(self, request, *args, **kwargs):
)
)

host = 'http://{}'.format(request.META.get('HTTP_HOST'))
host = 'http://{}'.format(request.get_host())
ctx = {
'host': host,
'ticketed_event': self.ticketed_event,
Expand Down Expand Up @@ -516,7 +516,7 @@ def form_valid(self, form):

try:
# send email and set messages
host = 'http://{}'.format(self.request.META.get('HTTP_HOST'))
host = 'http://{}'.format(self.request.get_host())
# send email to user; no need to send to studio as cancelled
# before payment
ctx = {
Expand Down
2 changes: 1 addition & 1 deletion studioadmin/views/email_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def email_users_view(request, mailing_list=False,
for i in range(0, email_count, 99)
]

host = 'http://{}'.format(request.META.get('HTTP_HOST'))
host = 'http://{}'.format(request.get_host())

try:
for i, email_list in enumerate(email_lists):
Expand Down
4 changes: 2 additions & 2 deletions studioadmin/views/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ def cancel_event_view(request, slug):

try:
# send notification email to user
host = 'http://{}'.format(request.META.get('HTTP_HOST'))
host = 'http://{}'.format(request.get_host())
ctx = {
'host': host,
'event_type': ev_type,
Expand Down Expand Up @@ -426,7 +426,7 @@ def cancel_event_view(request, slug):
# deposits as we don't create
# transfer blocks for deposit-only
try:
host = 'http://{}'.format(request.META.get('HTTP_HOST'))
host = 'http://{}'.format(request.get_host())
# send email to studio
ctx = {
'host': host,
Expand Down
4 changes: 2 additions & 2 deletions studioadmin/views/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def form_valid(self, form):

ctx = {
'event': booking.event,
'host': 'http://{}'.format(self.request.META.get('HTTP_HOST')),
'host': 'http://{}'.format(self.request.get_host()),
'payment_status': payment_status
}
try:
Expand Down Expand Up @@ -147,7 +147,7 @@ def form_valid(self, form):

ctx = {
'event': booking.event,
'host': 'http://{}'.format(self.request.META.get('HTTP_HOST')),
'host': 'http://{}'.format(self.request.get_host()),
'free': free
}

Expand Down
2 changes: 1 addition & 1 deletion studioadmin/views/register.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ def ajax_toggle_attended(request, booking_id):
send_waiting_list_email(
booking.event,
[wluser.user for wluser in waiting_list_users],
host='http://{}'.format(request.META.get('HTTP_HOST'))
host='http://{}'.format(request.get_host())
)
ActivityLog.objects.create(
log='Waiting list email sent to user(s) {} for event {}'.format(
Expand Down
6 changes: 3 additions & 3 deletions studioadmin/views/ticketed_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def post(self, request, *args, **kwargs):
def _send_confirmation_email(self, request, ticket_booking, action):
try:
# send confirmation email
host = 'http://{}'.format(request.META.get('HTTP_HOST'))
host = 'http://{}'.format(request.get_host())
# send email to studio
ctx = {
'host': host,
Expand Down Expand Up @@ -498,7 +498,7 @@ def cancel_ticketed_event_view(request, slug):
if request.method == 'POST':
if 'confirm' in request.POST:

host = 'http://{}'.format(request.META.get('HTTP_HOST'))
host = 'http://{}'.format(request.get_host())

for booking in open_paid_ticket_bookings + \
open_unpaid_ticket_bookings:
Expand Down Expand Up @@ -645,7 +645,7 @@ def form_valid(self, form):
ctx = {
'ticketed_event': ticket_booking.ticketed_event,
'ticket_booking': ticket_booking,
'host': 'http://{}'.format(self.request.META.get('HTTP_HOST'))
'host': 'http://{}'.format(self.request.get_host())
}

send_mail(
Expand Down
2 changes: 1 addition & 1 deletion studioadmin/views/timetable.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def _format_override_option(value):
if visible_created_classes:
ctx = {
"new_classes": visible_created_classes,
"host": 'http://{}'.format(request.META.get('HTTP_HOST'))
"host": 'http://{}'.format(request.get_host())
}

send_mail(
Expand Down
4 changes: 2 additions & 2 deletions studioadmin/views/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ def process_user_booking_updates(form, request):
send_confirmation_msg = ""
if 'send_confirmation' in form.changed_data:
# send confirmation email
host = 'http://{}'.format(request.META.get('HTTP_HOST'))
host = 'http://{}'.format(request.get_host())
# send email to studio
ctx = {
'host': host,
Expand Down Expand Up @@ -674,7 +674,7 @@ def process_user_booking_updates(form, request):
[wluser.user for \
wluser in waiting_list_users],
host='http://{}'.format(
request.META.get('HTTP_HOST')
request.get_host()
)
)
ActivityLog.objects.create(
Expand Down

0 comments on commit 5596cfc

Please sign in to comment.