Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
b25b3e1b
Commit
b25b3e1b
authored
11 years ago
by
David Baumgold
Browse files
Options
Downloads
Patches
Plain Diff
Move doc_url function out of edxmako middleware
parent
bf1b75f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
cms/djangoapps/contentstore/context_processors.py
+20
-0
20 additions, 0 deletions
cms/djangoapps/contentstore/context_processors.py
cms/envs/common.py
+1
-0
1 addition, 0 deletions
cms/envs/common.py
common/djangoapps/edxmako/middleware.py
+0
-20
0 additions, 20 deletions
common/djangoapps/edxmako/middleware.py
with
21 additions
and
20 deletions
cms/djangoapps/contentstore/context_processors.py
0 → 100644
+
20
−
0
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
}
This diff is collapsed.
Click to expand it.
cms/envs/common.py
+
1
−
0
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
...
...
This diff is collapsed.
Click to expand it.
common/djangoapps/edxmako/middleware.py
+
0
−
20
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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment