Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-notes-api
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-notes-api
Commits
5fd3ff8c
Commit
5fd3ff8c
authored
Dec 26, 2014
by
Tim Babych
Committed by
Oleg Marshev
Jan 05, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixing tests
parent
b61f0652
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
11 deletions
+11
-11
notesapi/v1/models.py
+4
-2
notesapi/v1/tests/test_views.py
+0
-0
notesapi/v1/views.py
+2
-1
notesserver/settings/common.py
+2
-2
notesserver/settings/dev.py
+0
-4
notesserver/settings/test.py
+3
-2
No files found.
notesapi/v1/models.py
View file @
5fd3ff8c
...
@@ -37,7 +37,8 @@ class Note(models.Model):
...
@@ -37,7 +37,8 @@ class Note(models.Model):
try
:
try
:
self
.
course_id
=
note
[
'course_id'
]
self
.
course_id
=
note
[
'course_id'
]
self
.
usage_id
=
note
[
'usage_id'
]
self
.
usage_id
=
note
[
'usage_id'
]
self
.
user_id
=
note
[
'user'
]
if
not
self
.
user_id
:
self
.
user_id
=
note
[
'user'
]
except
KeyError
as
error
:
except
KeyError
as
error
:
raise
ValidationError
(
'Note must have a course_id and usage_id and user_id.'
)
raise
ValidationError
(
'Note must have a course_id and usage_id and user_id.'
)
...
@@ -97,6 +98,7 @@ class NoteMappingType(MappingType, Indexable):
...
@@ -97,6 +98,7 @@ class NoteMappingType(MappingType, Indexable):
return
{
return
{
'properties'
:
{
'properties'
:
{
'id'
:
charfield
,
'id'
:
charfield
,
'user'
:
charfield
,
'course_id'
:
charfield
,
'course_id'
:
charfield
,
'usage_id'
:
charfield
,
'usage_id'
:
charfield
,
'text'
:
{
'type'
:
'string'
,
'index'
:
'snowball'
,
'store'
:
True
},
'text'
:
{
'type'
:
'string'
,
'index'
:
'snowball'
,
'store'
:
True
},
...
@@ -119,7 +121,7 @@ class NoteMappingType(MappingType, Indexable):
...
@@ -119,7 +121,7 @@ class NoteMappingType(MappingType, Indexable):
for
i
,
item
in
enumerate
(
data
):
for
i
,
item
in
enumerate
(
data
):
if
isinstance
(
item
,
dict
):
if
isinstance
(
item
,
dict
):
for
k
,
v
in
item
.
items
():
for
k
,
v
in
item
.
items
():
if
isinstance
(
v
,
list
)
and
len
(
v
)
>
0
:
if
k
!=
'ranges'
and
isinstance
(
v
,
list
)
and
len
(
v
)
>
0
:
data
[
i
][
k
]
=
v
[
0
]
data
[
i
][
k
]
=
v
[
0
]
return
data
return
data
...
...
notesapi/v1/tests/test_views.py
View file @
5fd3ff8c
This diff is collapsed.
Click to expand it.
notesapi/v1/views.py
View file @
5fd3ff8c
...
@@ -110,7 +110,8 @@ class AnnotationDetailView(APIView):
...
@@ -110,7 +110,8 @@ class AnnotationDetailView(APIView):
except
Note
.
DoesNotExist
:
except
Note
.
DoesNotExist
:
return
Response
(
'Annotation not found! No update performed.'
,
status
=
status
.
HTTP_404_NOT_FOUND
)
return
Response
(
'Annotation not found! No update performed.'
,
status
=
status
.
HTTP_404_NOT_FOUND
)
if
note
.
user_id
!=
es_note
[
'user_id'
]:
# changing user_id is not permitted
if
note
.
user_id
!=
self
.
request
.
DATA
[
'user'
]:
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
)
return
Response
(
status
=
status
.
HTTP_400_BAD_REQUEST
)
filtered_payload
=
_filter_input
(
self
.
request
.
DATA
,
UPDATE_FILTER_FIELDS
)
filtered_payload
=
_filter_input
(
self
.
request
.
DATA
,
UPDATE_FILTER_FIELDS
)
...
...
notesserver/settings/common.py
View file @
5fd3ff8c
...
@@ -4,7 +4,7 @@ import sys
...
@@ -4,7 +4,7 @@ import sys
DEBUG
=
False
DEBUG
=
False
TEMPLATE_DEBUG
=
False
TEMPLATE_DEBUG
=
False
DISABLE_TOKEN_CHECK
=
Tru
e
DISABLE_TOKEN_CHECK
=
Fals
e
USE_TZ
=
True
USE_TZ
=
True
TIME_ZONE
=
'UTC'
TIME_ZONE
=
'UTC'
...
@@ -20,7 +20,7 @@ ELASTICSEARCH_URL = 'http://127.0.0.1:9200'
...
@@ -20,7 +20,7 @@ ELASTICSEARCH_URL = 'http://127.0.0.1:9200'
ELASTICSEARCH_INDEX
=
'edx-notes'
ELASTICSEARCH_INDEX
=
'edx-notes'
ES_URLS
=
[
'http://localhost:9200'
]
ES_URLS
=
[
'http://localhost:9200'
]
ES_INDEXES
=
{
'default'
:
'
main
_index'
}
ES_INDEXES
=
{
'default'
:
'
notes
_index'
}
ES_DISABLED
=
False
ES_DISABLED
=
False
# Number of rows to return by default in result.
# Number of rows to return by default in result.
...
...
notesserver/settings/dev.py
View file @
5fd3ff8c
...
@@ -19,8 +19,4 @@ DATABASES = {
...
@@ -19,8 +19,4 @@ DATABASES = {
es
.
host
=
ELASTICSEARCH_URL
es
.
host
=
ELASTICSEARCH_URL
es
.
index
=
ELASTICSEARCH_INDEX
es
.
index
=
ELASTICSEARCH_INDEX
annotator
.
elasticsearch
.
RESULTS_MAX_SIZE
=
RESULTS_MAX_SIZE
annotator
.
elasticsearch
.
RESULTS_MAX_SIZE
=
RESULTS_MAX_SIZE
ES_URLS
=
[
'http://localhost:9200'
]
ES_INDEXES
=
{
'default'
:
'main_index'
}
ES_DISABLED
=
False
###############################################################################
###############################################################################
notesserver/settings/test.py
View file @
5fd3ff8c
...
@@ -9,10 +9,9 @@ DATABASES = {
...
@@ -9,10 +9,9 @@ DATABASES = {
}
}
TEST_RUNNER
=
'django_nose.NoseTestSuiteRunner'
TEST_RUNNER
=
'django_nose.NoseTestSuiteRunner'
DISABLE_TOKEN_CHECK
=
False
INSTALLED_APPS
+=
(
'django_nose'
,)
INSTALLED_APPS
+=
(
'django_nose'
,)
ELASTICSEARCH_INDEX
=
'edx-notes-test'
###############################################################################
###############################################################################
# Override default annotator-store elasticsearch settings.
# Override default annotator-store elasticsearch settings.
...
@@ -22,6 +21,8 @@ es.index = ELASTICSEARCH_INDEX
...
@@ -22,6 +21,8 @@ es.index = ELASTICSEARCH_INDEX
annotator
.
elasticsearch
.
RESULTS_MAX_SIZE
=
RESULTS_MAX_SIZE
annotator
.
elasticsearch
.
RESULTS_MAX_SIZE
=
RESULTS_MAX_SIZE
###############################################################################
###############################################################################
ES_INDEXES
=
{
'default'
:
'notes_index_test'
}
LOGGING
=
{
LOGGING
=
{
'version'
:
1
,
'version'
:
1
,
...
...
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