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
b25b3e1b
Commit
b25b3e1b
authored
Jan 28, 2014
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move doc_url function out of edxmako middleware
parent
bf1b75f5
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
20 deletions
+21
-20
cms/djangoapps/contentstore/context_processors.py
+20
-0
cms/envs/common.py
+1
-0
common/djangoapps/edxmako/middleware.py
+0
-20
No files found.
cms/djangoapps/contentstore/context_processors.py
0 → 100644
View file @
b25b3e1b
import
ConfigParser
from
django.conf
import
settings
def
doc_url
(
request
):
config_file
=
open
(
settings
.
REPO_ROOT
/
"docs"
/
"config.ini"
)
config
=
ConfigParser
.
ConfigParser
()
config
.
readfp
(
config_file
)
# in the future, we will detect the locale; for now, we will
# hardcode en_us, since we only have English documentation
locale
=
"en_us"
def
get_doc_url
(
token
):
try
:
return
config
.
get
(
locale
,
token
)
except
ConfigParser
.
NoOptionError
:
return
config
.
get
(
locale
,
"default"
)
return
{
"doc_url"
:
get_doc_url
}
cms/envs/common.py
View file @
b25b3e1b
...
...
@@ -117,6 +117,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth'
,
# this is required for admin
'django.core.context_processors.csrf'
,
'dealer.contrib.django.staff.context_processor'
,
# access git revision
'contentstore.context_processors.doc_url'
,
)
# use the ratelimit backend to prevent brute force attacks
...
...
common/djangoapps/edxmako/middleware.py
View file @
b25b3e1b
...
...
@@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import
ConfigParser
from
django.conf
import
settings
from
django.template
import
RequestContext
from
util.request
import
safe_get_host
requestcontext
=
None
...
...
@@ -26,21 +24,3 @@ class MakoMiddleware(object):
requestcontext
=
RequestContext
(
request
)
requestcontext
[
'is_secure'
]
=
request
.
is_secure
()
requestcontext
[
'site'
]
=
safe_get_host
(
request
)
requestcontext
[
'doc_url'
]
=
self
.
get_doc_url_func
(
request
)
def
get_doc_url_func
(
self
,
request
):
config_file
=
open
(
settings
.
REPO_ROOT
/
"docs"
/
"config.ini"
)
config
=
ConfigParser
.
ConfigParser
()
config
.
readfp
(
config_file
)
# in the future, we will detect the locale; for now, we will
# hardcode en_us, since we only have English documentation
locale
=
"en_us"
def
doc_url
(
token
):
try
:
return
config
.
get
(
locale
,
token
)
except
ConfigParser
.
NoOptionError
:
return
config
.
get
(
locale
,
"default"
)
return
doc_url
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