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
4070e019
Commit
4070e019
authored
May 06, 2013
by
Arthur Barrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified the html static book to only enable annotator.js when notes are enabled for the course
parent
45cca10f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
7 deletions
+35
-7
lms/djangoapps/notes/api.py
+7
-0
lms/djangoapps/notes/utils.py
+5
-0
lms/djangoapps/notes/views.py
+6
-1
lms/djangoapps/staticbook/views.py
+4
-1
lms/templates/static_htmlbook.html
+13
-5
No files found.
lms/djangoapps/notes/api.py
View file @
4070e019
...
...
@@ -2,6 +2,8 @@ from django.contrib.auth.decorators import login_required
from
django.http
import
HttpResponse
,
Http404
from
django.core.exceptions
import
ValidationError
from
notes.models
import
Note
from
notes.utils
import
notes_enabled_for_course
from
courseware.courses
import
get_course_with_access
import
json
import
logging
...
...
@@ -34,6 +36,11 @@ def api_request(request, course_id, **kwargs):
Raises a 404 if the resource type doesn't exist, or if there is no action
method associated with the HTTP method.
'''
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
if
not
notes_enabled_for_course
(
course
):
log
.
debug
(
'Notes not enabled for course'
)
raise
Http404
resource_map
=
api_resource_map
()
resource_name
=
kwargs
.
pop
(
'resource'
)
resource
=
resource_map
.
get
(
resource_name
)
...
...
lms/djangoapps/notes/utils.py
0 → 100644
View file @
4070e019
# TODO: make a separate policy setting to enable/disable notes.
def
notes_enabled_for_course
(
course
):
''' Returns True if notes are enabled for the course, False otherwise. '''
notes_tab_type
=
'notes'
return
next
((
True
for
tab
in
course
.
tabs
if
tab
[
'type'
]
==
notes_tab_type
),
False
)
lms/djangoapps/notes/views.py
View file @
4070e019
from
django.contrib.auth.decorators
import
login_required
from
django.http
import
Http404
from
mitxmako.shortcuts
import
render_to_response
from
courseware.courses
import
get_course_with_access
from
notes.models
import
Note
from
notes.utils
import
notes_enabled_for_course
import
json
@login_required
def
notes
(
request
,
course_id
):
''' Displays a student's notes in a course. '''
''' Displays the student's notes. '''
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
if
not
notes_enabled_for_course
(
course
):
raise
Http404
notes
=
Note
.
objects
.
filter
(
course_id
=
course_id
,
user
=
request
.
user
)
.
order_by
(
'-created'
,
'uri'
)
json_notes
=
json
.
dumps
([
n
.
as_dict
()
for
n
in
notes
])
...
...
lms/djangoapps/staticbook/views.py
View file @
4070e019
...
...
@@ -5,6 +5,7 @@ from mitxmako.shortcuts import render_to_response
from
courseware.access
import
has_access
from
courseware.courses
import
get_course_with_access
from
notes.utils
import
notes_enabled_for_course
from
static_replace
import
replace_static_urls
...
...
@@ -102,6 +103,7 @@ def html_index(request, course_id, book_index, chapter=None):
"""
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
staff_access
=
has_access
(
request
.
user
,
course
,
'staff'
)
notes_enabled
=
notes_enabled_for_course
(
course
)
book_index
=
int
(
book_index
)
if
book_index
<
0
or
book_index
>=
len
(
course
.
html_textbooks
):
...
...
@@ -130,4 +132,5 @@ def html_index(request, course_id, book_index, chapter=None):
'course'
:
course
,
'textbook'
:
textbook
,
'chapter'
:
chapter
,
'staff_access'
:
staff_access
})
'staff_access'
:
staff_access
,
'notes_enabled'
:
notes_enabled
})
lms/templates/static_htmlbook.html
View file @
4070e019
...
...
@@ -31,11 +31,14 @@
anchorToLoad
=
options
.
anchor_id
;
}
var
onComplete
=
function
(
url
)
{
return
function
()
{
$
(
'#viewerContainer'
).
trigger
(
'notes:init'
,
[
url
]);
}
};
var
onComplete
=
function
()
{};
if
(
options
.
notesEnabled
)
{
onComplete
=
function
(
url
)
{
return
function
()
{
$
(
'#viewerContainer'
).
trigger
(
'notes:init'
,
[
url
]);
}
};
}
loadUrl
=
function
htmlViewLoadUrl
(
url
,
anchorId
)
{
// clear out previous load, if any:
...
...
@@ -102,6 +105,11 @@
options
.
anchor_id
=
$
{
anchor_id
};
%
endif
options
.
notesEnabled
=
false
;
%
if
notes_enabled
is
not
UNDEFINED
and
notes_enabled
:
options
.
notesEnabled
=
true
;
%
endif
$
(
'#outerContainer'
).
myHTMLViewer
(
options
);
});
</script>
...
...
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