Skip to content

Commit 060e12e

Browse files
authored
Merge pull request #1121 from thecourseforum/cleanup
Django Session Cleanup (save 5 gb)
2 parents dab578f + 70c8fc2 commit 060e12e

File tree

8 files changed

+3
-277
lines changed

8 files changed

+3
-277
lines changed

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ psycopg2~=2.9.9
2323
pylint-django~=2.5.5
2424
pylint~=3.0.3
2525
requests~=2.31.0
26-
social-auth-app-django~=5.4.0
2726
tqdm~=4.66.1
2827
types-tqdm~=4.66.0
2928
uWSGI~=2.0.28

scripts/container-startup.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ echo 'collectstatic ran'
1111

1212
python manage.py invalidate_cachalot tcf_website
1313

14+
python manage.py clearsessions
15+
1416
# Add custom commands here
1517

1618
echo 'Starting Django Server...'

tcf_core/auth_pipeline.py

Lines changed: 0 additions & 181 deletions
This file was deleted.

tcf_core/settings/base.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,6 @@
130130
"django.template.context_processors.request",
131131
"django.contrib.auth.context_processors.auth",
132132
"django.contrib.messages.context_processors.messages",
133-
"social_django.context_processors.backends",
134-
"social_django.context_processors.login_redirect",
135133
"tcf_core.context_processors.base",
136134
"tcf_core.context_processors.history_cookies",
137135
"tcf_core.context_processors.searchbar_context",

tcf_core/urls.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,5 @@
1919

2020
urlpatterns = [
2121
path("", include("tcf_website.urls")),
22-
path("oauth/", include("social_django.urls")),
2322
path("admin/", admin.site.urls),
2423
]

tcf_website/templates/login/extra_info_form.html

Lines changed: 0 additions & 26 deletions
This file was deleted.

tcf_website/views/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# https://docs.djangoproject.com/en/3.0/topics/db/models/#organizing-models-in-a-package
55

66
from .ads import ads
7-
from .auth import collect_extra_info, login, login_error, logout, password_error
7+
from .auth import login, logout
88
from .browse import (
99
browse,
1010
course_instructor,

tcf_website/views/auth.py

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@
22

33
import logging
44
from base64 import b64encode
5-
from datetime import datetime
65
import json
76

87
import requests
9-
from django import forms
108
from django.conf import settings
119
from django.contrib import messages
1210
from django.contrib.auth import authenticate, login as auth_login, logout as auth_logout
1311
from django.contrib.auth.decorators import login_required
1412
from django.http import HttpResponseRedirect
1513
from django.shortcuts import redirect, render
16-
from django.urls import reverse
1714

18-
from .browse import browse
1915

2016
logger = logging.getLogger(__name__)
2117

@@ -101,67 +97,6 @@ def cognito_callback(request):
10197
return redirect("index")
10298

10399

104-
def login_error(request):
105-
"""Login error view."""
106-
messages.error(
107-
request,
108-
"There was an error logging you in. Please make \
109-
sure you're using an @virginia.edu email address.",
110-
)
111-
return browse(request)
112-
113-
114-
def password_error(request):
115-
"""Incorrect password error view."""
116-
messages.error(
117-
request,
118-
"There was an error logging you in. Please check \
119-
your email and password",
120-
)
121-
return browse(request)
122-
123-
124-
class ExtraUserInfoForm(forms.Form):
125-
"""Form to collect extra user info on sign up."""
126-
127-
current_yr = datetime.now().year
128-
max_yr = current_yr + 6
129-
grad_year = forms.IntegerField(
130-
widget=forms.NumberInput(
131-
attrs={
132-
"class": "form-control",
133-
"min": "1900",
134-
"max": max_yr,
135-
"value": current_yr,
136-
}
137-
)
138-
)
139-
140-
141-
def collect_extra_info(request, method):
142-
"""Extra sign up info collection view."""
143-
if request.method == "POST":
144-
form = ExtraUserInfoForm(request.POST)
145-
if form.is_valid():
146-
# because of FIELDS_STORED_IN_SESSION, this will get copied
147-
# to the request dictionary when the pipeline is resumed
148-
request.session["grad_year"] = form.cleaned_data["grad_year"]
149-
150-
# once we have the grad_year stashed in the session, we can
151-
# tell the pipeline to resume by using the "complete" endpoint
152-
return redirect(
153-
reverse("social:complete", args=[method])
154-
+ "?verification_code="
155-
+ request.GET["verification_code"]
156-
+ "&partial_token="
157-
+ request.GET["partial_token"]
158-
)
159-
else:
160-
form = ExtraUserInfoForm()
161-
162-
return render(request, "login/extra_info_form.html", {"form": form})
163-
164-
165100
def unauthenticated_index(request):
166101
"""Index shown to non-logged in users."""
167102
return render(request, "landing/landing.html")

0 commit comments

Comments
 (0)