Skip to content

Commit

Permalink
emergency: Disable booking confirmation emails (#717)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoff authored Feb 16, 2024
1 parent 8dc1906 commit b0a5439
Show file tree
Hide file tree
Showing 109 changed files with 36 additions and 247 deletions.
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,9 @@ setup:
make collect-static
python -m venv .venv
source .venv/bin/activate
make setup-precommit
make up

setup-precommit:
pip install pre-commit
pre-commit install

setup-devcontainer:
make setup-precommit
make migrate
pip install -r requirements/local.txt

Expand Down Expand Up @@ -154,12 +148,12 @@ mypy: ## Type checking - mypy
schema: ## Dumps graphql schema in schema.json
$(COMMAND_PREFIX) ./manage.py graphql_schema --schema uobtheatre.schema.schema --out schema.graphql

pr: ## Runs everything required (that is not included in precommit) for a pr
pr: ## Runs everything required for a pr
make schema
make lint
make test

build:
python precommit_config_generator.py
docker-compose build api celery

django-shell: ## Open django shell
Expand Down
17 changes: 2 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ This will:
- Pull all the docker images
- Build the api image
- Collect the static files
- Setup a venv and precommit
- Setup a venv
- Start the api and db

(If you are on windows you will need to copy the commands into git bash from the makefile or use wsl)
Expand All @@ -27,19 +27,6 @@ This will:
- [docker](https://docs.docker.com/get-docker/)
- [docker-compose](https://docs.docker.com/compose/install/)

## Pre-commit

Pre-commit is required to format code and do lots of nice checks.

It should be installed by `make setup`.

Otherwise, it can be installed manually with:
```
pip install pre-commit
pre-commit install
```

If this case every commit should trigger the precommit hook. You will always need to be commit from within the venv for this to work.

## Visual Studio Dev Container

Expand Down Expand Up @@ -134,7 +121,7 @@ make build
```

This does the following:
- Set the requirements for mypy precommit
- Set the requirements for mypy
- Rebuild the api

If mypy gives an error about not being able to find the new package, add it to the list of "additional_dependencies" in `.pre-commit-config.yaml`.
75 changes: 0 additions & 75 deletions precommit_config_generator.py

This file was deleted.

8 changes: 4 additions & 4 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ django-configurations==2.4
django-environ==0.10.0 # https://github.com/joke2k/django-environ

# Spreadsheet generation
xlsxwriter==3.0.8
xlsxwriter==3.0.9

# Text formatting
html2text==2020.1.16
Expand Down Expand Up @@ -63,11 +63,11 @@ squareup>=9.0.0.20210226

#=== Logging ===#

sentry-sdk==1.16.0
sentry-sdk==1.19.1
whitenoise==6.4.0 # https://github.com/evansd/whitenoise

#=== Email ===#
django-anymail[amazon_ses]==9.0 # https://github.com/anymail/django-anymail
django-anymail[amazon_ses]==9.1 # https://github.com/anymail/django-anymail
django-inlinecss==0.3.0

#=== Timezones ===#
Expand All @@ -76,4 +76,4 @@ pytz==2022.7.1

#=== Task Queue ===#
django-celery-results==2.2.0
redis==4.5.1
redis==4.5.4
1 change: 0 additions & 1 deletion uobtheatre/addresses/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = []
Expand Down
1 change: 0 additions & 1 deletion uobtheatre/addresses/migrations/0002_auto_20210805_1525.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("addresses", "0001_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion uobtheatre/addresses/test/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class AddressFactory(factory.django.DjangoModelFactory):

street = factory.Faker("street_name")
building_name = factory.Faker("sentence", nb_words=2)
building_number = factory.Faker("bothify", text="##")
Expand Down
1 change: 0 additions & 1 deletion uobtheatre/bookings/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
1 change: 0 additions & 1 deletion uobtheatre/bookings/migrations/0002_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = [
Expand Down
1 change: 0 additions & 1 deletion uobtheatre/bookings/migrations/0003_auto_20210923_2223.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [
("bookings", "0002_initial"),
]
Expand Down
1 change: 0 additions & 1 deletion uobtheatre/bookings/migrations/0004_auto_20211128_2108.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [
("bookings", "0003_auto_20210923_2223"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("bookings", "0004_auto_20211128_2108"),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def ticket_check_in_to_datetime(apps, _):


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
("bookings", "0005_alter_booking_status"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("bookings", "0006_alter_ticket_checkin_to_datetime"),
]
Expand Down
10 changes: 5 additions & 5 deletions uobtheatre/bookings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.utils.functional import cached_property
from graphql_relay.node.node import to_global_id

import uobtheatre.bookings.emails as booking_emails
#import uobtheatre.bookings.emails as booking_emails
from uobtheatre.discounts.models import ConcessionType, DiscountCombination
from uobtheatre.payments.exceptions import (
CantBePaidForException,
Expand Down Expand Up @@ -206,6 +206,7 @@ def generate_expires_at():

BookingManager = models.Manager.from_queryset(BookingQuerySet)


# pylint: disable=too-many-public-methods
class Booking(TimeStampedMixin, Payable):
"""A booking for a performance
Expand Down Expand Up @@ -519,7 +520,6 @@ def get_ticket_diff(

# find tickets to delete
for ticket in self.tickets.all():

if existing_tickets.get(ticket.id):
# if a given booking ticket is in the requested tickets - you keep it -
existing_tickets.pop(ticket.id, None)
Expand Down Expand Up @@ -548,9 +548,9 @@ def complete(self, payment: Transaction = None):
"""
super().complete()

booking_emails.send_booking_confirmation_email(self, payment)
if self.accessibility_info:
booking_emails.send_booking_accessibility_info_email(self)
# booking_emails.send_booking_confirmation_email(self, payment)
# if self.accessibility_info:
# booking_emails.send_booking_accessibility_info_email(self)

def clone(self):
clone = super().clone()
Expand Down
1 change: 0 additions & 1 deletion uobtheatre/bookings/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ def resolve_mutation( # pylint: disable=too-many-arguments, too-many-branches
verify_token=None,
**kwargs,
):

# Get the performance and if it doesn't exist throw an error
booking = Booking.objects.get(id=kwargs["id"])

Expand Down
1 change: 0 additions & 1 deletion uobtheatre/bookings/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def resolve_tickets_discounted_price(self, _):
return self.subtotal

def resolve_tickets(self, _):

# Group the ticket together, this returns a list of tuples.
# The first element of the tuple is itself a tuple which contains the
# seat_group and concession_type, the second element of the typle
Expand Down
3 changes: 0 additions & 3 deletions uobtheatre/bookings/test/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class Meta:


class BookingFactory(factory.django.DjangoModelFactory):

user = factory.SubFactory(UserFactory)
creator = factory.SubFactory(UserFactory)
performance = factory.SubFactory(PerformanceFactory)
Expand All @@ -41,7 +40,6 @@ class Meta:


class PerformanceSeatingFactory(factory.django.DjangoModelFactory):

price = factory.Faker("pyint")
performance = factory.SubFactory(PerformanceFactory)
capacity = factory.Faker("pyint")
Expand All @@ -52,7 +50,6 @@ class Meta:


class TicketFactory(factory.django.DjangoModelFactory):

seat_group = factory.SubFactory(SeatGroupFactory)
booking = factory.SubFactory(BookingFactory)
concession_type = factory.SubFactory(
Expand Down
31 changes: 15 additions & 16 deletions uobtheatre/bookings/test/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,6 @@ def test_booking_can_be_refunded(is_refunded, status, production_status, expecte
"uobtheatre.bookings.models.Booking.is_refunded",
new_callable=PropertyMock(return_value=is_refunded),
):

booking = BookingFactory(
performance=PerformanceFactory(production=production), status=status
)
Expand All @@ -1069,21 +1068,21 @@ def test_complete(with_payment, with_accessibility):
status=Payable.Status.IN_PROGRESS,
accessibility_info=("Something" if with_accessibility else None),
)
with patch(
"uobtheatre.bookings.emails.send_booking_confirmation_email"
) as mock_send_email, patch(
"uobtheatre.bookings.emails.send_booking_accessibility_info_email"
) as mock_send_accessibility_email:
kwargs = {}
if with_payment:
kwargs["payment"] = TransactionFactory()
booking.complete(**kwargs)
mock_send_email.assert_called_once()

if with_accessibility:
mock_send_accessibility_email.assert_called_once()
else:
mock_send_accessibility_email.assert_not_called()
# with patch(
# "uobtheatre.bookings.emails.send_booking_confirmation_email"
# ) as mock_send_email, patch(
# "uobtheatre.bookings.emails.send_booking_accessibility_info_email"
# ) as mock_send_accessibility_email:
kwargs = {}
if with_payment:
kwargs["payment"] = TransactionFactory()
booking.complete(**kwargs)
# mock_send_email.assert_called_once()

# if with_accessibility:
# mock_send_accessibility_email.assert_called_once()
# else:
# mock_send_accessibility_email.assert_not_called()

booking.refresh_from_db()
assert booking.status == Payable.Status.PAID
Expand Down
Loading

0 comments on commit b0a5439

Please sign in to comment.