Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
eb7ae354
Commit
eb7ae354
authored
Jul 16, 2012
by
Bridger Maxwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a simple, specific cache for the static_template_pages.
parent
cd2eacc6
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
14 deletions
+22
-14
common/djangoapps/student/views.py
+1
-3
lms/djangoapps/static_template_view/views.py
+15
-6
lms/envs/common.py
+1
-0
lms/urls.py
+5
-5
No files found.
common/djangoapps/student/views.py
View file @
eb7ae354
...
...
@@ -45,10 +45,8 @@ def index(request):
if
settings
.
COURSEWARE_ENABLED
and
request
.
user
.
is_authenticated
():
return
redirect
(
reverse
(
'dashboard'
))
else
:
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
# TODO: Clean up how 'error' is done.
return
render_to_response
(
'index.html'
,
{
'courses'
:
modulestore
()
.
get_courses
(),
'csrf'
:
csrf_token
})
return
render_to_response
(
'index.html'
,
{
'courses'
:
modulestore
()
.
get_courses
()})
@login_required
...
...
lms/djangoapps/static_template_view/views.py
View file @
eb7ae354
...
...
@@ -5,8 +5,10 @@
from
mitxmako.shortcuts
import
render_to_response
,
render_to_string
from
django.shortcuts
import
redirect
from
django.core.context_processors
import
csrf
from
django.conf
import
settings
from
django_future.csrf
import
ensure_csrf_cookie
from
util.cache
import
cache
valid_templates
=
[]
...
...
@@ -21,23 +23,30 @@ if settings.STATIC_GRAB:
]
def
index
(
request
,
template
):
csrf_token
=
csrf
(
request
)[
'csrf_token'
]
if
template
in
valid_templates
:
return
render_to_response
(
'static_templates/'
+
template
,
{})
else
:
return
redirect
(
'/'
)
@ensure_csrf_cookie
def
render
(
request
,
template
):
"""
This view function renders the template sent without checking that it
exists. Do not expose template as a regex part of the url. The user should
not be able to ender any arbitray template name. The correct usage would be:
url(r'^jobs$', 'static_template_view.views.render', {'template': 'jobs'}, name="jobs")
url(r'^jobs$', 'static_template_view.views.render', {'template': 'jobs
.html
'}, name="jobs")
"""
template
=
template
+
'.html'
return
render_to_response
(
'static_templates/'
+
template
,
{})
cache_key
=
"static_template_view_render."
+
template
use_cache
=
not
request
.
user
.
is_authenticated
()
response
=
cache
.
get
(
cache_key
)
if
use_cache
else
None
if
not
response
:
response
=
render_to_response
(
'static_templates/'
+
template
,
{})
if
use_cache
:
cache
.
set
(
cache_key
,
response
,
60
*
3
)
return
response
valid_auth_templates
=
[
'help.html'
]
...
...
lms/envs/common.py
View file @
eb7ae354
...
...
@@ -219,6 +219,7 @@ ASKBOT_ALLOWED_UPLOAD_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.t
ASKBOT_MAX_UPLOAD_FILE_SIZE
=
1024
*
1024
# result in bytes
CACHE_MIDDLEWARE_ANONYMOUS_ONLY
=
True
CACHE_PREFIX
=
SITE_ID
ASKBOT_URL
=
'discussion/'
LOGIN_REDIRECT_URL
=
MITX_ROOT_URL
+
'/'
LOGIN_URL
=
MITX_ROOT_URL
+
'/'
...
...
lms/urls.py
View file @
eb7ae354
...
...
@@ -48,11 +48,11 @@ urlpatterns = ('',
#Semi-static views (these need to be rendered and have the login bar, but don't change)
url
(
r'^404$'
,
'static_template_view.views.render'
,
{
'template'
:
'404'
},
name
=
"404"
),
url
(
r'^about$'
,
'static_template_view.views.render'
,
{
'template'
:
'about'
},
name
=
"about_edx"
),
url
(
r'^university_profile$'
,
'static_template_view.views.render'
,
{
'template'
:
'university_profile'
},
name
=
"university_profile"
),
url
(
r'^jobs$'
,
'static_template_view.views.render'
,
{
'template'
:
'jobs'
},
name
=
"jobs"
),
url
(
r'^help$'
,
'static_template_view.views.render'
,
{
'template'
:
'help'
},
name
=
"help_edx"
),
url
(
r'^404$'
,
'static_template_view.views.render'
,
{
'template'
:
'404
.html
'
},
name
=
"404"
),
url
(
r'^about$'
,
'static_template_view.views.render'
,
{
'template'
:
'about
.html
'
},
name
=
"about_edx"
),
url
(
r'^university_profile$'
,
'static_template_view.views.render'
,
{
'template'
:
'university_profile
.html
'
},
name
=
"university_profile"
),
url
(
r'^jobs$'
,
'static_template_view.views.render'
,
{
'template'
:
'jobs
.html
'
},
name
=
"jobs"
),
url
(
r'^help$'
,
'static_template_view.views.render'
,
{
'template'
:
'help
.html
'
},
name
=
"help_edx"
),
#TODO: Convert these pages to the new edX layout
# 'tos.html',
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment