Skip to content

Commit

Permalink
refactor: remove COUPON_SHEETS (#3370)
Browse files Browse the repository at this point in the history
  • Loading branch information
asadali145 authored Jan 20, 2025
1 parent e872a1b commit ebfe955
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 35 deletions.
4 changes: 2 additions & 2 deletions .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
"filename": "sheets/dev-setup.md",
"hashed_secret": "1348b145fa1a555461c1b790a2f66614781091e9",
"is_verified": false,
"line_number": 179
"line_number": 178
}
],
"static/js/constants.js": [
Expand Down Expand Up @@ -261,5 +261,5 @@
}
]
},
"generated_at": "2024-09-26T09:26:28Z"
"generated_at": "2025-01-13T12:49:44Z"
}
45 changes: 23 additions & 22 deletions mitxpro/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -905,39 +905,40 @@
month_of_year="*",
),
},
}
if FEATURES.get("COUPON_SHEETS"):
CELERY_BEAT_SCHEDULE["renew_all_file_watches"] = {
"renew_all_file_watches": {
"task": "sheets.tasks.renew_all_file_watches",
"schedule": (
DRIVE_WEBHOOK_EXPIRATION_MINUTES - DRIVE_WEBHOOK_RENEWAL_PERIOD_MINUTES
)
* 60,
}
alt_sheets_processing = FEATURES.get("COUPON_SHEETS_ALT_PROCESSING")
if alt_sheets_processing:
CELERY_BEAT_SCHEDULE.update(
{
"handle-coupon-request-sheet": {
"task": "sheets.tasks.handle_unprocessed_coupon_requests",
"schedule": SHEETS_MONITORING_FREQUENCY,
}
}
)
},
}

alt_sheets_processing = FEATURES.get("COUPON_SHEETS_ALT_PROCESSING")
if alt_sheets_processing:
CELERY_BEAT_SCHEDULE.update(
{
"update-assignment-delivery-dates": {
"task": "sheets.tasks.update_incomplete_assignment_delivery_statuses",
"schedule": OffsettingSchedule(
run_every=timedelta(seconds=SHEETS_MONITORING_FREQUENCY),
offset=timedelta(
seconds=0 if not alt_sheets_processing else SHEETS_TASK_OFFSET
),
),
"handle-coupon-request-sheet": {
"task": "sheets.tasks.handle_unprocessed_coupon_requests",
"schedule": SHEETS_MONITORING_FREQUENCY,
}
}
)

CELERY_BEAT_SCHEDULE.update(
{
"update-assignment-delivery-dates": {
"task": "sheets.tasks.update_incomplete_assignment_delivery_statuses",
"schedule": OffsettingSchedule(
run_every=timedelta(seconds=SHEETS_MONITORING_FREQUENCY),
offset=timedelta(
seconds=0 if not alt_sheets_processing else SHEETS_TASK_OFFSET
),
),
}
}
)

# Hijack
HIJACK_INSERT_BEFORE = "</body>"

Expand Down
1 change: 0 additions & 1 deletion sheets/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
@pytest.fixture(autouse=True)
def sheets_settings(settings):
"""Default settings for sheets tests"""
settings.FEATURES["COUPON_SHEETS"] = True
settings.SHEETS_REQ_EMAIL_COL = 7
settings.SHEETS_REQ_PROCESSED_COL = 8
settings.SHEETS_REQ_ERROR_COL = 9
Expand Down
1 change: 0 additions & 1 deletion sheets/dev-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ First, gather a bunch of ID-type values from Drive:
_If it's not obvious, remove the angle brackets (`<>`) for the actual values._

```dotenv
FEATURE_COUPON_SHEETS=True
SHEETS_ADMIN_EMAILS=<Your email address>
DRIVE_CLIENT_ID=<Client ID from step 1>
DRIVE_CLIENT_SECRET=<Client secret from step 1>
Expand Down
10 changes: 1 addition & 9 deletions sheets/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required
from django.db import transaction
from django.http import Http404, HttpResponse
from django.http import HttpResponse
from django.shortcuts import redirect, render
from django.urls import reverse
from django.views.decorators.csrf import csrf_exempt
Expand All @@ -32,8 +32,6 @@
@staff_member_required(login_url="login")
def sheets_admin_view(request):
"""Admin view that renders a page that allows a user to begin Google OAuth auth"""
if not settings.FEATURES.get("COUPON_SHEETS"):
raise Http404
existing_api_auth = GoogleApiAuth.objects.first()
successful_action = request.GET.get("success")
return render(
Expand All @@ -49,8 +47,6 @@ def sheets_admin_view(request):
@staff_member_required(login_url="login")
def request_google_auth(request):
"""Admin view to begin Google OAuth auth"""
if not settings.FEATURES.get("COUPON_SHEETS"):
raise Http404
flow = Flow.from_client_config(
generate_google_client_config(), scopes=REQUIRED_GOOGLE_API_SCOPES
)
Expand All @@ -66,8 +62,6 @@ def request_google_auth(request):
@csrf_exempt
def complete_google_auth(request):
"""Admin view that handles the redirect from Google after completing Google auth"""
if not settings.FEATURES.get("COUPON_SHEETS"):
raise Http404
state = request.session.get("state")
if not state:
raise GoogleAuthError(
Expand Down Expand Up @@ -98,8 +92,6 @@ def handle_watched_sheet_update(request):
View that handles requests sent from Google's push notification service when changes are made to the
a sheet with a file watch applied.
"""
if not settings.FEATURES.get("COUPON_SHEETS"):
raise Http404
channel_id = request.META.get("HTTP_X_GOOG_CHANNEL_ID")
if not channel_id:
log.error(
Expand Down

0 comments on commit ebfe955

Please sign in to comment.