Skip to content

Commit d72ae85

Browse files
committed
⬆️ Django 5.2
1 parent a479369 commit d72ae85

File tree

6 files changed

+39
-20
lines changed

6 files changed

+39
-20
lines changed

cypress/e2e/8.Login/login.cy.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ describe('Log In Feature: Test Instructor Login', () => {
1818
cy.get('.choose-course').should('contain', 'Sample Course');
1919
cy.get('.choose-course').click();
2020
cy.title().should('contain', 'Sample Course');
21-
cy.visit('/accounts/logout/?next=/');
21+
cy.get('.sign-out').click();
2222
cy.title().should('contain', 'Splash');
2323
});
2424
});
2525

2626
describe('Log In Feature: Test Invalid login', () => {
27-
it('should not log in', () => {
27+
it('should not log in with invalid credentials', () => {
2828
cy.visit('/accounts/login/');
2929
cy.title().should('contain', 'Login');
3030
cy.get('#cu-privacy-notice-button').click();
@@ -36,7 +36,7 @@ describe('Log In Feature: Test Invalid login', () => {
3636
});
3737

3838
describe('Log In Feature: Test Student Login', () => {
39-
it('should test student login', () => {
39+
it('should log in as student_one', () => {
4040
cy.visit('/accounts/login/');
4141
cy.title().should('contain', 'Login');
4242
cy.get('#cu-privacy-notice-button').click();
@@ -45,13 +45,13 @@ describe('Log In Feature: Test Student Login', () => {
4545
cy.login('student_one', 'test');
4646
cy.visit('/');
4747
cy.title().should('contain', 'Sample Course');
48-
cy.visit('/accounts/logout/?next=/');
48+
cy.get('.sign-out').click();
4949
cy.title().should('contain', 'Splash');
5050
});
5151
});
5252

5353
describe('Log In Feature: Test Switch Course feature', () => {
54-
it('should test student login', () => {
54+
it('should log in as student_one and see courses', () => {
5555
cy.visit('/accounts/login/');
5656
cy.title().should('contain', 'Login');
5757
cy.get('#cu-privacy-notice-button').click();

mediathread/main/middleware.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class MethCourseManagerMiddleware(CourseManagerMiddleware):
1010
def set_course(self, course, request):
11-
request.session[SESSION_KEY] = course
11+
request.session[SESSION_KEY] = course.pk
1212
request.course = course
1313
self.decorate_request(request, course)
1414

mediathread/main/views.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def dispatch(self, request, *args, **kwargs):
129129
# Set the course in the session cookie. This is legacy
130130
# functionality, but still used by the Mediathread collection
131131
# browser extension.
132-
request.session[SESSION_KEY] = course
132+
request.session[SESSION_KEY] = course.pk
133133

134134
return super(CourseDetailView, self).dispatch(request, *args, **kwargs)
135135

@@ -393,7 +393,16 @@ def get_initial(self):
393393
initial['issue_date'] = timezone.now()
394394

395395
if SESSION_KEY in self.request.session:
396-
initial['course'] = self.request.session[SESSION_KEY].title
396+
course_pk = self.request.session[SESSION_KEY]
397+
course = None
398+
399+
try:
400+
course = Course.objects.get(pk=course_pk)
401+
except Course.DoesNotExist:
402+
pass
403+
404+
if course:
405+
initial['course'] = course.title
397406

398407
return initial
399408

@@ -467,7 +476,16 @@ def get(self, request, *args, **kwargs):
467476

468477
course_name = ''
469478
if SESSION_KEY in request.session:
470-
course_name = request.session[SESSION_KEY].title
479+
course_pk = self.request.session[SESSION_KEY]
480+
course = None
481+
482+
try:
483+
course = Course.objects.get(pk=course_pk)
484+
except Course.DoesNotExist:
485+
pass
486+
487+
if course:
488+
course_name = course.title
471489

472490
d = {
473491
'logged_in': logged_in,

mediathread/settings_shared.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@
180180

181181
DEFAULT_COLLABORATION_POLICY = 'InstructorManaged'
182182

183-
SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
184-
185183
ACCOUNT_ACTIVATION_DAYS = 7
186184

187185
CORS_ALLOW_ALL_ORIGINS = True

mediathread/templates/navbar.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,13 @@
111111

112112
<li class="nav-item">
113113
{% if request.user.is_authenticated %}
114-
<a class="btn btn-outline-light btn-block sign-out" role="button"
115-
href="/accounts/logout/?next=/" title="Sign Out">
114+
<form action="/accounts/logout/?next=/" method="post">
115+
{% csrf_token %}
116+
<button type="submit" title="Sign Out"
117+
class="btn btn-outline-light btn-block sign-out">
116118
Sign Out
117-
</a>
119+
</button>
120+
</form>
118121
{% else %}
119122
<a href="/accounts/register/" class="btn btn-outline-secondary" style="margin-right:.25em;">Sign Up</a>
120123
<a href="/accounts/login/" class="btn btn-outline-light">Sign In</a>

requirements.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
Django>=4.2.14,<5
1+
Django>=5.2.4,<6
22
asgiref==3.11.0
3-
psycopg[binary]==3.3.0
3+
psycopg[binary]==3.3.1
44
statsd==4.0.1
55
pep8==1.7.1
66
pyflakes==3.4.0
@@ -58,7 +58,7 @@ django-reversion==6.0.0
5858
requirements/src/djangohelpers-0.22-py2.py3-none-any.whl
5959
django-contrib-comments==2.2.0
6060
django-threadedcomments==2.0
61-
django-courseaffils==2.4.0
61+
django-courseaffils==2.5.1
6262
django-statsd-mozilla==0.4.0
6363
sentry-sdk[celery]==2.47.0
6464
django-appconf==1.2.0
@@ -69,7 +69,7 @@ django-smoketest==1.2.1
6969
django-markwhat==2025.5.31
7070
text-unidecode==1.3 # for faker
7171
Faker==38.2.0
72-
factory_boy==3.3.0
72+
factory_boy==3.3.3
7373
django-impersonate==1.9.2
7474
django-registration-redux==2.13
7575
django-cors-headers==4.9.0
@@ -99,7 +99,7 @@ simplegeneric==0.8.1
9999
scandir==1.10.0
100100
pathlib2==2.3.6
101101

102-
freezegun==1.5.1
102+
freezegun==1.5.5
103103
django-smtp-ssl==1.0
104104
djangorestframework==3.16.0
105105

@@ -126,7 +126,7 @@ attrs==25.4.0 # zeep
126126
zeep==4.3.2
127127

128128
stevedore==5.6.0
129-
pyyaml==6.0.2
129+
pyyaml==6.0.3
130130
rich==14.2.0 # bandit
131131
bandit==1.9.1
132132
funcsigs==1.0.2

0 commit comments

Comments
 (0)