From b118b731434f845489e2ab1a5261df8c2979d467 Mon Sep 17 00:00:00 2001 From: Sef Kloninger Date: Wed, 10 Apr 2013 01:19:20 -0400 Subject: [PATCH 1/5] press releases: standardize template names (move 1) --- .../{bostonx_announcement.html => foo-bostonx_announcement.html} | 0 ...book_content.html => foo-cengage_to_provide_book_content.html} | 0 ...testing.html => foo-edx_announces_proctored_exam_testing.html} | 0 ..._internationally.html => foo-edx_expands_internationally.html} | 0 ...ates_with_edX.html => foo-elsevier_collaborates_with_edx.html} | 0 ...er_secret_of_life.html => foo-eric_lander_secret_of_life.html} | 0 ...n_announcement.html => foo-gates_foundation_announcement.html} | 0 .../{Georgetown_joins_edX.html => foo-georgetown_joins_edx.html} | 0 ...ourse_announcement.html => foo-lewin_course_announcement.html} | 0 ...rd_announce_edX.html => foo-mit_and_harvard_announce_edx.html} | 0 ...ing_2013_course_announcements.html => foo-spring_courses.html} | 0 ...nford_announcement.html => foo-stanford_to_work_with_edx.html} | 0 .../press_releases/{template.html => foo-template.html} | 0 ...{UC_Berkeley_joins_edX.html => foo-uc_berkeley_joins_edx.html} | 0 .../press_releases/{UT_joins_edX.html => foo-ut_joins_edx.html} | 0 ...ollege_joins_edX.html => foo-wellesley_college_joins_edx.html} | 0 .../{xblock_announcement.html => foo-xblock_announcement.html} | 0 17 files changed, 0 insertions(+), 0 deletions(-) rename lms/templates/static_templates/press_releases/{bostonx_announcement.html => foo-bostonx_announcement.html} (100%) rename lms/templates/static_templates/press_releases/{Cengage_to_provide_book_content.html => foo-cengage_to_provide_book_content.html} (100%) rename lms/templates/static_templates/press_releases/{edX_announces_proctored_exam_testing.html => foo-edx_announces_proctored_exam_testing.html} (100%) rename lms/templates/static_templates/press_releases/{edx_expands_internationally.html => foo-edx_expands_internationally.html} (100%) rename lms/templates/static_templates/press_releases/{Elsevier_collaborates_with_edX.html => foo-elsevier_collaborates_with_edx.html} (100%) rename lms/templates/static_templates/press_releases/{eric_lander_secret_of_life.html => foo-eric_lander_secret_of_life.html} (100%) rename lms/templates/static_templates/press_releases/{Gates_Foundation_announcement.html => foo-gates_foundation_announcement.html} (100%) rename lms/templates/static_templates/press_releases/{Georgetown_joins_edX.html => foo-georgetown_joins_edx.html} (100%) rename lms/templates/static_templates/press_releases/{Lewin_course_announcement.html => foo-lewin_course_announcement.html} (100%) rename lms/templates/static_templates/press_releases/{MIT_and_Harvard_announce_edX.html => foo-mit_and_harvard_announce_edx.html} (100%) rename lms/templates/static_templates/press_releases/{Spring_2013_course_announcements.html => foo-spring_courses.html} (100%) rename lms/templates/static_templates/press_releases/{stanford_announcement.html => foo-stanford_to_work_with_edx.html} (100%) rename lms/templates/static_templates/press_releases/{template.html => foo-template.html} (100%) rename lms/templates/static_templates/press_releases/{UC_Berkeley_joins_edX.html => foo-uc_berkeley_joins_edx.html} (100%) rename lms/templates/static_templates/press_releases/{UT_joins_edX.html => foo-ut_joins_edx.html} (100%) rename lms/templates/static_templates/press_releases/{Wellesley_College_joins_edX.html => foo-wellesley_college_joins_edx.html} (100%) rename lms/templates/static_templates/press_releases/{xblock_announcement.html => foo-xblock_announcement.html} (100%) diff --git a/lms/templates/static_templates/press_releases/bostonx_announcement.html b/lms/templates/static_templates/press_releases/foo-bostonx_announcement.html similarity index 100% rename from lms/templates/static_templates/press_releases/bostonx_announcement.html rename to lms/templates/static_templates/press_releases/foo-bostonx_announcement.html diff --git a/lms/templates/static_templates/press_releases/Cengage_to_provide_book_content.html b/lms/templates/static_templates/press_releases/foo-cengage_to_provide_book_content.html similarity index 100% rename from lms/templates/static_templates/press_releases/Cengage_to_provide_book_content.html rename to lms/templates/static_templates/press_releases/foo-cengage_to_provide_book_content.html diff --git a/lms/templates/static_templates/press_releases/edX_announces_proctored_exam_testing.html b/lms/templates/static_templates/press_releases/foo-edx_announces_proctored_exam_testing.html similarity index 100% rename from lms/templates/static_templates/press_releases/edX_announces_proctored_exam_testing.html rename to lms/templates/static_templates/press_releases/foo-edx_announces_proctored_exam_testing.html diff --git a/lms/templates/static_templates/press_releases/edx_expands_internationally.html b/lms/templates/static_templates/press_releases/foo-edx_expands_internationally.html similarity index 100% rename from lms/templates/static_templates/press_releases/edx_expands_internationally.html rename to lms/templates/static_templates/press_releases/foo-edx_expands_internationally.html diff --git a/lms/templates/static_templates/press_releases/Elsevier_collaborates_with_edX.html b/lms/templates/static_templates/press_releases/foo-elsevier_collaborates_with_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/Elsevier_collaborates_with_edX.html rename to lms/templates/static_templates/press_releases/foo-elsevier_collaborates_with_edx.html diff --git a/lms/templates/static_templates/press_releases/eric_lander_secret_of_life.html b/lms/templates/static_templates/press_releases/foo-eric_lander_secret_of_life.html similarity index 100% rename from lms/templates/static_templates/press_releases/eric_lander_secret_of_life.html rename to lms/templates/static_templates/press_releases/foo-eric_lander_secret_of_life.html diff --git a/lms/templates/static_templates/press_releases/Gates_Foundation_announcement.html b/lms/templates/static_templates/press_releases/foo-gates_foundation_announcement.html similarity index 100% rename from lms/templates/static_templates/press_releases/Gates_Foundation_announcement.html rename to lms/templates/static_templates/press_releases/foo-gates_foundation_announcement.html diff --git a/lms/templates/static_templates/press_releases/Georgetown_joins_edX.html b/lms/templates/static_templates/press_releases/foo-georgetown_joins_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/Georgetown_joins_edX.html rename to lms/templates/static_templates/press_releases/foo-georgetown_joins_edx.html diff --git a/lms/templates/static_templates/press_releases/Lewin_course_announcement.html b/lms/templates/static_templates/press_releases/foo-lewin_course_announcement.html similarity index 100% rename from lms/templates/static_templates/press_releases/Lewin_course_announcement.html rename to lms/templates/static_templates/press_releases/foo-lewin_course_announcement.html diff --git a/lms/templates/static_templates/press_releases/MIT_and_Harvard_announce_edX.html b/lms/templates/static_templates/press_releases/foo-mit_and_harvard_announce_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/MIT_and_Harvard_announce_edX.html rename to lms/templates/static_templates/press_releases/foo-mit_and_harvard_announce_edx.html diff --git a/lms/templates/static_templates/press_releases/Spring_2013_course_announcements.html b/lms/templates/static_templates/press_releases/foo-spring_courses.html similarity index 100% rename from lms/templates/static_templates/press_releases/Spring_2013_course_announcements.html rename to lms/templates/static_templates/press_releases/foo-spring_courses.html diff --git a/lms/templates/static_templates/press_releases/stanford_announcement.html b/lms/templates/static_templates/press_releases/foo-stanford_to_work_with_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/stanford_announcement.html rename to lms/templates/static_templates/press_releases/foo-stanford_to_work_with_edx.html diff --git a/lms/templates/static_templates/press_releases/template.html b/lms/templates/static_templates/press_releases/foo-template.html similarity index 100% rename from lms/templates/static_templates/press_releases/template.html rename to lms/templates/static_templates/press_releases/foo-template.html diff --git a/lms/templates/static_templates/press_releases/UC_Berkeley_joins_edX.html b/lms/templates/static_templates/press_releases/foo-uc_berkeley_joins_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/UC_Berkeley_joins_edX.html rename to lms/templates/static_templates/press_releases/foo-uc_berkeley_joins_edx.html diff --git a/lms/templates/static_templates/press_releases/UT_joins_edX.html b/lms/templates/static_templates/press_releases/foo-ut_joins_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/UT_joins_edX.html rename to lms/templates/static_templates/press_releases/foo-ut_joins_edx.html diff --git a/lms/templates/static_templates/press_releases/Wellesley_College_joins_edX.html b/lms/templates/static_templates/press_releases/foo-wellesley_college_joins_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/Wellesley_College_joins_edX.html rename to lms/templates/static_templates/press_releases/foo-wellesley_college_joins_edx.html diff --git a/lms/templates/static_templates/press_releases/xblock_announcement.html b/lms/templates/static_templates/press_releases/foo-xblock_announcement.html similarity index 100% rename from lms/templates/static_templates/press_releases/xblock_announcement.html rename to lms/templates/static_templates/press_releases/foo-xblock_announcement.html From f57028b8e8118c56a161fd380f1478d14d461e58 Mon Sep 17 00:00:00 2001 From: Sef Kloninger Date: Wed, 10 Apr 2013 01:23:32 -0400 Subject: [PATCH 2/5] press releases: standardize template names (move 2) --- .../{foo-bostonx_announcement.html => bostonx_announcement.html} | 0 ...ide_book_content.html => cengage_to_provide_book_content.html} | 0 ...xam_testing.html => edx_announces_proctored_exam_testing.html} | 0 ...ands_internationally.html => edx_expands_internationally.html} | 0 ...aborates_with_edx.html => elsevier_collaborates_with_edx.html} | 0 ...lander_secret_of_life.html => eric_lander_secret_of_life.html} | 0 ...ation_announcement.html => gates_foundation_announcement.html} | 0 .../{foo-georgetown_joins_edx.html => georgetown_joins_edx.html} | 0 ...in_course_announcement.html => lewin_course_announcement.html} | 0 ...arvard_announce_edx.html => mit_and_harvard_announce_edx.html} | 0 .../{foo-spring_courses.html => spring_courses.html} | 0 ...nford_to_work_with_edx.html => stanford_to_work_with_edx.html} | 0 .../press_releases/{foo-template.html => template.html} | 0 ...{foo-uc_berkeley_joins_edx.html => uc_berkeley_joins_edx.html} | 0 .../press_releases/{foo-ut_joins_edx.html => ut_joins_edx.html} | 0 ...ey_college_joins_edx.html => wellesley_college_joins_edx.html} | 0 .../{foo-xblock_announcement.html => xblock_announcement.html} | 0 17 files changed, 0 insertions(+), 0 deletions(-) rename lms/templates/static_templates/press_releases/{foo-bostonx_announcement.html => bostonx_announcement.html} (100%) rename lms/templates/static_templates/press_releases/{foo-cengage_to_provide_book_content.html => cengage_to_provide_book_content.html} (100%) rename lms/templates/static_templates/press_releases/{foo-edx_announces_proctored_exam_testing.html => edx_announces_proctored_exam_testing.html} (100%) rename lms/templates/static_templates/press_releases/{foo-edx_expands_internationally.html => edx_expands_internationally.html} (100%) rename lms/templates/static_templates/press_releases/{foo-elsevier_collaborates_with_edx.html => elsevier_collaborates_with_edx.html} (100%) rename lms/templates/static_templates/press_releases/{foo-eric_lander_secret_of_life.html => eric_lander_secret_of_life.html} (100%) rename lms/templates/static_templates/press_releases/{foo-gates_foundation_announcement.html => gates_foundation_announcement.html} (100%) rename lms/templates/static_templates/press_releases/{foo-georgetown_joins_edx.html => georgetown_joins_edx.html} (100%) rename lms/templates/static_templates/press_releases/{foo-lewin_course_announcement.html => lewin_course_announcement.html} (100%) rename lms/templates/static_templates/press_releases/{foo-mit_and_harvard_announce_edx.html => mit_and_harvard_announce_edx.html} (100%) rename lms/templates/static_templates/press_releases/{foo-spring_courses.html => spring_courses.html} (100%) rename lms/templates/static_templates/press_releases/{foo-stanford_to_work_with_edx.html => stanford_to_work_with_edx.html} (100%) rename lms/templates/static_templates/press_releases/{foo-template.html => template.html} (100%) rename lms/templates/static_templates/press_releases/{foo-uc_berkeley_joins_edx.html => uc_berkeley_joins_edx.html} (100%) rename lms/templates/static_templates/press_releases/{foo-ut_joins_edx.html => ut_joins_edx.html} (100%) rename lms/templates/static_templates/press_releases/{foo-wellesley_college_joins_edx.html => wellesley_college_joins_edx.html} (100%) rename lms/templates/static_templates/press_releases/{foo-xblock_announcement.html => xblock_announcement.html} (100%) diff --git a/lms/templates/static_templates/press_releases/foo-bostonx_announcement.html b/lms/templates/static_templates/press_releases/bostonx_announcement.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-bostonx_announcement.html rename to lms/templates/static_templates/press_releases/bostonx_announcement.html diff --git a/lms/templates/static_templates/press_releases/foo-cengage_to_provide_book_content.html b/lms/templates/static_templates/press_releases/cengage_to_provide_book_content.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-cengage_to_provide_book_content.html rename to lms/templates/static_templates/press_releases/cengage_to_provide_book_content.html diff --git a/lms/templates/static_templates/press_releases/foo-edx_announces_proctored_exam_testing.html b/lms/templates/static_templates/press_releases/edx_announces_proctored_exam_testing.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-edx_announces_proctored_exam_testing.html rename to lms/templates/static_templates/press_releases/edx_announces_proctored_exam_testing.html diff --git a/lms/templates/static_templates/press_releases/foo-edx_expands_internationally.html b/lms/templates/static_templates/press_releases/edx_expands_internationally.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-edx_expands_internationally.html rename to lms/templates/static_templates/press_releases/edx_expands_internationally.html diff --git a/lms/templates/static_templates/press_releases/foo-elsevier_collaborates_with_edx.html b/lms/templates/static_templates/press_releases/elsevier_collaborates_with_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-elsevier_collaborates_with_edx.html rename to lms/templates/static_templates/press_releases/elsevier_collaborates_with_edx.html diff --git a/lms/templates/static_templates/press_releases/foo-eric_lander_secret_of_life.html b/lms/templates/static_templates/press_releases/eric_lander_secret_of_life.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-eric_lander_secret_of_life.html rename to lms/templates/static_templates/press_releases/eric_lander_secret_of_life.html diff --git a/lms/templates/static_templates/press_releases/foo-gates_foundation_announcement.html b/lms/templates/static_templates/press_releases/gates_foundation_announcement.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-gates_foundation_announcement.html rename to lms/templates/static_templates/press_releases/gates_foundation_announcement.html diff --git a/lms/templates/static_templates/press_releases/foo-georgetown_joins_edx.html b/lms/templates/static_templates/press_releases/georgetown_joins_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-georgetown_joins_edx.html rename to lms/templates/static_templates/press_releases/georgetown_joins_edx.html diff --git a/lms/templates/static_templates/press_releases/foo-lewin_course_announcement.html b/lms/templates/static_templates/press_releases/lewin_course_announcement.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-lewin_course_announcement.html rename to lms/templates/static_templates/press_releases/lewin_course_announcement.html diff --git a/lms/templates/static_templates/press_releases/foo-mit_and_harvard_announce_edx.html b/lms/templates/static_templates/press_releases/mit_and_harvard_announce_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-mit_and_harvard_announce_edx.html rename to lms/templates/static_templates/press_releases/mit_and_harvard_announce_edx.html diff --git a/lms/templates/static_templates/press_releases/foo-spring_courses.html b/lms/templates/static_templates/press_releases/spring_courses.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-spring_courses.html rename to lms/templates/static_templates/press_releases/spring_courses.html diff --git a/lms/templates/static_templates/press_releases/foo-stanford_to_work_with_edx.html b/lms/templates/static_templates/press_releases/stanford_to_work_with_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-stanford_to_work_with_edx.html rename to lms/templates/static_templates/press_releases/stanford_to_work_with_edx.html diff --git a/lms/templates/static_templates/press_releases/foo-template.html b/lms/templates/static_templates/press_releases/template.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-template.html rename to lms/templates/static_templates/press_releases/template.html diff --git a/lms/templates/static_templates/press_releases/foo-uc_berkeley_joins_edx.html b/lms/templates/static_templates/press_releases/uc_berkeley_joins_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-uc_berkeley_joins_edx.html rename to lms/templates/static_templates/press_releases/uc_berkeley_joins_edx.html diff --git a/lms/templates/static_templates/press_releases/foo-ut_joins_edx.html b/lms/templates/static_templates/press_releases/ut_joins_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-ut_joins_edx.html rename to lms/templates/static_templates/press_releases/ut_joins_edx.html diff --git a/lms/templates/static_templates/press_releases/foo-wellesley_college_joins_edx.html b/lms/templates/static_templates/press_releases/wellesley_college_joins_edx.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-wellesley_college_joins_edx.html rename to lms/templates/static_templates/press_releases/wellesley_college_joins_edx.html diff --git a/lms/templates/static_templates/press_releases/foo-xblock_announcement.html b/lms/templates/static_templates/press_releases/xblock_announcement.html similarity index 100% rename from lms/templates/static_templates/press_releases/foo-xblock_announcement.html rename to lms/templates/static_templates/press_releases/xblock_announcement.html From 4b68e0282f4936a03f0d7705f9b16c31ce2d2cab Mon Sep 17 00:00:00 2001 From: Sef Kloninger Date: Wed, 10 Apr 2013 02:16:35 -0400 Subject: [PATCH 3/5] press releases: use generic matching rule This way instead of having to explicitly add releases to the urls.py file, we just add the relase to the static_templates/press_releases directory and the right thing happens. Getting rid of the current "feature" where /pressrelease redirects to the current press release. It was broken, looks like it's unused. Limitation: release file name must match slug, but with underscores and all lower case. Why bother? I wanted to do something small to learn the edX toolchain. --- lms/djangoapps/static_template_view/tests.py | 57 ++++++++++++++++---- lms/djangoapps/static_template_view/views.py | 22 +++++++- lms/templates/feed.rss | 28 +++++----- lms/urls.py | 46 +--------------- 4 files changed, 84 insertions(+), 69 deletions(-) diff --git a/lms/djangoapps/static_template_view/tests.py b/lms/djangoapps/static_template_view/tests.py index 501deb776c..806242c6d2 100644 --- a/lms/djangoapps/static_template_view/tests.py +++ b/lms/djangoapps/static_template_view/tests.py @@ -1,16 +1,53 @@ -""" -This file demonstrates writing tests using the unittest module. These will pass -when you run "manage.py test". - -Replace this with more appropriate tests for your application. -""" - from django.test import TestCase +from django.test.client import Client class SimpleTest(TestCase): - def test_basic_addition(self): + + def setUp(self): + self.client = Client() + + def test_render(self): """ - Tests that 1 + 1 always equals 2. + Render a normal page, like jobs """ - self.assertEqual(1 + 1, 2) + response = self.client.get("/jobs") + self.assertEquals(response.status_code, 200) + + + def test_render_press_release(self): + """ + Render press releases from generic URL match + """ + # since I had to remap files, pedantically test all press releases + # published to date. Decent positive test while we're at it. + all_releases = ["/press/mit-and-harvard-announce-edx", + "/press/uc-berkeley-joins-edx", + "/press/edX-announces-proctored-exam-testing", + "/press/elsevier-collaborates-with-edx", + "/press/ut-joins-edx", + "/press/cengage-to-provide-book-content", + "/press/gates-foundation-announcement", + "/press/wellesley-college-joins-edx", + "/press/georgetown-joins-edx", + "/press/spring-courses", + "/press/lewin-course-announcement", + "/press/bostonx-announcement", + "/press/eric-lander-secret-of-life", + "/press/edx-expands-internationally", + "/press/xblock_announcement", + "/press/stanford-to-work-with-edx", + ] + + for rel in all_releases: + response = self.client.get(rel) + self.assertNotContains(response, "PAGE NOT FOUND", status_code=200) + + # should work with caps + response = self.client.get("/press/STANFORD-to-work-with-edx") + self.assertContains(response, "Stanford", status_code=200) + + # negative test + response = self.client.get("/press/this-shouldnt-work") + self.assertEqual(response.status_code, 404) + diff --git a/lms/djangoapps/static_template_view/views.py b/lms/djangoapps/static_template_view/views.py index 022f12b148..56a7f32780 100644 --- a/lms/djangoapps/static_template_view/views.py +++ b/lms/djangoapps/static_template_view/views.py @@ -4,9 +4,10 @@ # security reasons. from mitxmako.shortcuts import render_to_response, render_to_string +from mako.exceptions import TopLevelLookupException from django.shortcuts import redirect from django.conf import settings -from django.http import HttpResponseNotFound, HttpResponseServerError +from django.http import HttpResponseNotFound, HttpResponseServerError, Http404 from django_future.csrf import ensure_csrf_cookie from util.cache import cache_if_anonymous @@ -40,6 +41,25 @@ def render(request, template): return render_to_response('static_templates/' + template, {}) +@ensure_csrf_cookie +@cache_if_anonymous +def render_press_release(request, slug): + """ + Render a press release given a slug. Similar to the "render" function above, + but takes a slug and does a basic conversion to convert it to a template file. + a) all lower case, + b) convert dashes to underscores, and + c) appending ".html" + """ + template = slug.lower().replace('-', '_') + ".html" + try: + resp = render_to_response('static_templates/press_releases/' + template, {}) + except TopLevelLookupException: + raise Http404 + else: + return resp + + def render_404(request): return HttpResponseNotFound(render_to_string('static_templates/404.html', {})) diff --git a/lms/templates/feed.rss b/lms/templates/feed.rss index bd97113e33..3878f0d09f 100644 --- a/lms/templates/feed.rss +++ b/lms/templates/feed.rss @@ -11,7 +11,7 @@ tag:www.edx.org,2012:Post/17 2012-12-19T14:00:00-07:00 2012-12-19T14:00:00-07:00 - + Stanford University to Collaborate with edX on Development of Non-Profit Open Source edX Platform <img src="${static.url('images/press/releases/stanford-university_204x114.png')}" /> <p></p> @@ -20,7 +20,7 @@ tag:www.edx.org,2013:Post/16 2013-03-15T10:00:00-07:00 2013-03-15T10:00:00-07:00 - + edX releases XBlock SDK, first step toward open source vision <img src="${static.url('images/press/releases/edx-logo_240x180.png')}" /> <p></p> @@ -38,7 +38,7 @@ - + @@ -47,7 +47,7 @@ tag:www.edx.org,2013:Post/14 2013-01-30T10:00:00-07:00 2013-01-30T10:00:00-07:00 - + New biology course from human genome pioneer Eric Lander <img src="${static.url('images/press/releases/eric-lander_240x180.jpg')}" /> <p></p> @@ -56,7 +56,7 @@ tag:www.edx.org,2013:Post/12 2013-01-22T10:00:00-07:00 2013-01-22T10:00:00-07:00 - + New course from legendary MIT physics professor Walter Lewin <img src="${static.url('images/press/releases/dr-lewin-316_240x180.jpg')}" /> <p></p> @@ -65,7 +65,7 @@ tag:www.edx.org,2013:Post/11 2013-01-29T10:00:00-07:00 2013-01-29T10:00:00-07:00 - + City of Boston and edX partner to establish BostonX to improve educational access for residents <img src="${static.url('images/press/releases/edx-logo_240x180.png')}" /> <p></p> @@ -74,7 +74,7 @@ - + @@ -83,7 +83,7 @@ tag:www.edx.org,2012:Post/9 2012-12-10T14:00:00-07:00 2012-12-10T14:00:00-07:00 - + Georgetown University joins edX <img src="${static.url('images/press/releases/georgetown-seal_240x180.png')}" /> <p>Sixth institution to join global movement in year one</p> @@ -92,7 +92,7 @@ tag:www.edx.org,2012:Post/8 2012-12-04T14:00:00-07:00 2012-12-04T14:00:00-07:00 - + Wellesley College joins edX <img src="${static.url('images/press/releases/wellesley-seal_240x180.png')}" /> <p>First liberal arts college to join edX</p> @@ -101,7 +101,7 @@ tag:www.edx.org,2012:Post/7 2012-11-12T14:00:00-07:00 2012-11-12T14:00:00-07:00 - + edX and Massachusetts Community Colleges join in Gates-Funded educational initiative <img src="${static.url('images/press/releases/mass-seal_240x180.png')}" /> <p></p> @@ -110,7 +110,7 @@ tag:www.edx.org,2012:Post/6 2012-10-15T14:00:00-07:00 2012-10-14T14:00:00-07:00 - + The University of Texas System joins edX <img src="${static.url('images/press/releases/utsys-seal_240x180.png')}" /> <p>Nine universities and six health institutions</p> @@ -119,7 +119,7 @@ - + @@ -128,7 +128,7 @@ tag:www.edx.org,2012:Post/4 2012-09-06T14:00:00-07:00 2012-09-06T14:00:00-07:00 - + edX to offer learners option of taking proctored final exam <img src="${static.url('images/press/releases/diploma_240x180.jpg')}" /> @@ -136,7 +136,7 @@ tag:www.edx.org,2012:Post/3 2012-07-16T14:08:12-07:00 2012-07-16T14:08:12-07:00 - + UC Berkeley joins edX <img src="${static.url('images/press/releases/edx-logo_240x180.png')}" /> <p>edX broadens course offerings</p> diff --git a/lms/urls.py b/lms/urls.py index 4a0608720a..5251330cd8 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -117,51 +117,9 @@ urlpatterns = ('', {'template': 'honor.html'}, name="honor"), #Press releases - url(r'^press/mit-and-harvard-announce-edx$', 'static_template_view.views.render', - {'template': 'press_releases/MIT_and_Harvard_announce_edX.html'}, name="press/mit-and-harvard-announce-edx"), - url(r'^press/uc-berkeley-joins-edx$', 'static_template_view.views.render', - {'template': 'press_releases/UC_Berkeley_joins_edX.html'}, name="press/uc-berkeley-joins-edx"), - url(r'^press/edX-announces-proctored-exam-testing$', 'static_template_view.views.render', - {'template': 'press_releases/edX_announces_proctored_exam_testing.html'}, name="press/edX-announces-proctored-exam-testing"), - url(r'^press/elsevier-collaborates-with-edx$', 'static_template_view.views.render', - {'template': 'press_releases/Elsevier_collaborates_with_edX.html'}, name="press/elsevier-collaborates-with-edx"), - url(r'^press/ut-joins-edx$', 'static_template_view.views.render', - {'template': 'press_releases/UT_joins_edX.html'}, name="press/ut-joins-edx"), - url(r'^press/cengage-to-provide-book-content$', 'static_template_view.views.render', - {'template': 'press_releases/Cengage_to_provide_book_content.html'}, name="press/cengage-to-provide-book-content"), - url(r'^press/gates-foundation-announcement$', 'static_template_view.views.render', - {'template': 'press_releases/Gates_Foundation_announcement.html'}, name="press/gates-foundation-announcement"), - url(r'^press/wellesley-college-joins-edx$', 'static_template_view.views.render', - {'template': 'press_releases/Wellesley_College_joins_edX.html'}, name="press/wellesley-college-joins-edx"), - url(r'^press/georgetown-joins-edx$', 'static_template_view.views.render', - {'template': 'press_releases/Georgetown_joins_edX.html'}, name="press/georgetown-joins-edx"), - url(r'^press/spring-courses$', 'static_template_view.views.render', - {'template': 'press_releases/Spring_2013_course_announcements.html'}, - name="press/spring-courses"), - url(r'^press/lewin-course-announcement$', 'static_template_view.views.render', - {'template': 'press_releases/Lewin_course_announcement.html'}, - name="press/lewin-course-announcement"), - url(r'^press/bostonx-announcement$', 'static_template_view.views.render', - {'template': 'press_releases/bostonx_announcement.html'}, - name="press/bostonx-announcement"), - url(r'^press/eric-lander-secret-of-life$', 'static_template_view.views.render', - {'template': 'press_releases/eric_lander_secret_of_life.html'}, - name="press/eric-lander-secret-of-life"), - url(r'^press/edx-expands-internationally$', 'static_template_view.views.render', - {'template': 'press_releases/edx_expands_internationally.html'}, - name="press/edx-expands-internationally"), - url(r'^press/xblock_announcement$', 'static_template_view.views.render', - {'template': 'press_releases/xblock_announcement.html'}, - name="press/xblock-announcement"), - url(r'^press/stanford-to-work-with-edx$', 'static_template_view.views.render', - {'template': 'press_releases/stanford_announcement.html'}, - name="press/stanford-to-work-with-edx"), - - # Should this always update to point to the latest press release? - (r'^pressrelease$', 'django.views.generic.simple.redirect_to', - {'url': '/press/xblock-announcement'}), - + url(r'^press/([^/]+)$', 'static_template_view.views.render_press_release', name='press_release'), + # Favicon (r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/static/images/favicon.ico'}), # TODO: These urls no longer work. They need to be updated before they are re-enabled From bcdc6db4a9a1480d7ffb66d3449bbe3e129544cf Mon Sep 17 00:00:00 2001 From: Sef Kloninger Date: Wed, 10 Apr 2013 02:26:43 -0400 Subject: [PATCH 4/5] press releases: fix stanford announcement in rss feed --- lms/templates/feed.rss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lms/templates/feed.rss b/lms/templates/feed.rss index 3878f0d09f..5eaa29a574 100644 --- a/lms/templates/feed.rss +++ b/lms/templates/feed.rss @@ -11,7 +11,7 @@ tag:www.edx.org,2012:Post/17 2012-12-19T14:00:00-07:00 2012-12-19T14:00:00-07:00 - + Stanford University to Collaborate with edX on Development of Non-Profit Open Source edX Platform <img src="${static.url('images/press/releases/stanford-university_204x114.png')}" /> <p></p> From bd2330a8f0a1fb2ac06aa95c360efdc579bbac53 Mon Sep 17 00:00:00 2001 From: Sef Kloninger Date: Wed, 10 Apr 2013 08:20:30 -0400 Subject: [PATCH 5/5] press releases: more explicitly match on slug (safety) --- lms/djangoapps/static_template_view/tests.py | 8 ++++++++ lms/urls.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lms/djangoapps/static_template_view/tests.py b/lms/djangoapps/static_template_view/tests.py index 806242c6d2..9cd5502d5d 100644 --- a/lms/djangoapps/static_template_view/tests.py +++ b/lms/djangoapps/static_template_view/tests.py @@ -51,3 +51,11 @@ class SimpleTest(TestCase): response = self.client.get("/press/this-shouldnt-work") self.assertEqual(response.status_code, 404) + # can someone do something fishy? no. + response = self.client.get("/press/../homework.html") + self.assertEqual(response.status_code, 404) + + # "." in is ascii 2E + response = self.client.get("/press/%2E%2E/homework.html") + self.assertEqual(response.status_code, 404) + diff --git a/lms/urls.py b/lms/urls.py index 5251330cd8..d72112593a 100644 --- a/lms/urls.py +++ b/lms/urls.py @@ -117,7 +117,7 @@ urlpatterns = ('', {'template': 'honor.html'}, name="honor"), #Press releases - url(r'^press/([^/]+)$', 'static_template_view.views.render_press_release', name='press_release'), + url(r'^press/([_a-zA-Z0-9-]+)$', 'static_template_view.views.render_press_release', name='press_release'), # Favicon (r'^favicon\.ico$', 'django.views.generic.simple.redirect_to', {'url': '/static/images/favicon.ico'}),