Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cypress/e2e/8.Login/login.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ describe('Log In Feature: Test Instructor Login', () => {
cy.get('.choose-course').should('contain', 'Sample Course');
cy.get('.choose-course').click();
cy.title().should('contain', 'Sample Course');
cy.visit('/accounts/logout/?next=/');
cy.get('.sign-out').click();
cy.title().should('contain', 'Splash');
});
});

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

describe('Log In Feature: Test Student Login', () => {
it('should test student login', () => {
it('should log in as student_one', () => {
cy.visit('/accounts/login/');
cy.title().should('contain', 'Login');
cy.get('#cu-privacy-notice-button').click();
Expand All @@ -45,13 +45,13 @@ describe('Log In Feature: Test Student Login', () => {
cy.login('student_one', 'test');
cy.visit('/');
cy.title().should('contain', 'Sample Course');
cy.visit('/accounts/logout/?next=/');
cy.get('.sign-out').click();
cy.title().should('contain', 'Splash');
});
});

describe('Log In Feature: Test Switch Course feature', () => {
it('should test student login', () => {
it('should log in as student_one and see courses', () => {
cy.visit('/accounts/login/');
cy.title().should('contain', 'Login');
cy.get('#cu-privacy-notice-button').click();
Expand Down
2 changes: 1 addition & 1 deletion mediathread/main/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class MethCourseManagerMiddleware(CourseManagerMiddleware):
def set_course(self, course, request):
request.session[SESSION_KEY] = course
request.session[SESSION_KEY] = course.pk
request.course = course
self.decorate_request(request, course)

Expand Down
24 changes: 21 additions & 3 deletions mediathread/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def dispatch(self, request, *args, **kwargs):
# Set the course in the session cookie. This is legacy
# functionality, but still used by the Mediathread collection
# browser extension.
request.session[SESSION_KEY] = course
request.session[SESSION_KEY] = course.pk

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

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

if SESSION_KEY in self.request.session:
initial['course'] = self.request.session[SESSION_KEY].title
course_pk = self.request.session[SESSION_KEY]
course = None

try:
course = Course.objects.get(pk=course_pk)
except Course.DoesNotExist:
pass

if course:
initial['course'] = course.title

return initial

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

course_name = ''
if SESSION_KEY in request.session:
course_name = request.session[SESSION_KEY].title
course_pk = self.request.session[SESSION_KEY]
course = None

try:
course = Course.objects.get(pk=course_pk)
except Course.DoesNotExist:
pass

if course:
course_name = course.title

d = {
'logged_in': logged_in,
Expand Down
2 changes: 0 additions & 2 deletions mediathread/settings_shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@

DEFAULT_COLLABORATION_POLICY = 'InstructorManaged'

SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'

ACCOUNT_ACTIVATION_DAYS = 7

CORS_ALLOW_ALL_ORIGINS = True
Expand Down
9 changes: 6 additions & 3 deletions mediathread/templates/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,13 @@

<li class="nav-item">
{% if request.user.is_authenticated %}
<a class="btn btn-outline-light btn-block sign-out" role="button"
href="/accounts/logout/?next=/" title="Sign Out">
<form action="/accounts/logout/?next=/" method="post">
{% csrf_token %}
<button type="submit" title="Sign Out"
class="btn btn-outline-light btn-block sign-out">
Sign Out
</a>
</button>
</form>
{% else %}
<a href="/accounts/register/" class="btn btn-outline-secondary" style="margin-right:.25em;">Sign Up</a>
<a href="/accounts/login/" class="btn btn-outline-light">Sign In</a>
Expand Down
12 changes: 6 additions & 6 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Django>=4.2.14,<5
Django>=5.2.4,<6
asgiref==3.11.0
psycopg[binary]==3.3.0
psycopg[binary]==3.3.1
statsd==4.0.1
pep8==1.7.1
pyflakes==3.4.0
Expand Down Expand Up @@ -58,7 +58,7 @@ django-reversion==6.0.0
requirements/src/djangohelpers-0.22-py2.py3-none-any.whl
django-contrib-comments==2.2.0
django-threadedcomments==2.0
django-courseaffils==2.4.0
django-courseaffils==2.5.1
django-statsd-mozilla==0.4.0
sentry-sdk[celery]==2.47.0
django-appconf==1.2.0
Expand All @@ -69,7 +69,7 @@ django-smoketest==1.2.1
django-markwhat==2025.5.31
text-unidecode==1.3 # for faker
Faker==38.2.0
factory_boy==3.3.0
factory_boy==3.3.3
django-impersonate==1.9.2
django-registration-redux==2.13
django-cors-headers==4.9.0
Expand Down Expand Up @@ -99,7 +99,7 @@ simplegeneric==0.8.1
scandir==1.10.0
pathlib2==2.3.6

freezegun==1.5.1
freezegun==1.5.5
django-smtp-ssl==1.0
djangorestframework==3.16.0

Expand All @@ -126,7 +126,7 @@ attrs==25.4.0 # zeep
zeep==4.3.2

stevedore==5.6.0
pyyaml==6.0.2
pyyaml==6.0.3
rich==14.2.0 # bandit
bandit==1.9.1
funcsigs==1.0.2
Expand Down
Loading