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
117c0b69
Commit
117c0b69
authored
Sep 20, 2012
by
Arjun Singh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark threads as read once they are fetched; change viewed to read
parent
c83a27ec
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
36 deletions
+16
-36
lms/djangoapps/django_comment_client/forum/views.py
+8
-21
lms/djangoapps/django_comment_client/utils.py
+1
-1
lms/lib/comment_client/models.py
+2
-2
lms/lib/comment_client/thread.py
+5
-2
lms/lib/comment_client/user.py
+0
-10
No files found.
lms/djangoapps/django_comment_client/forum/views.py
View file @
117c0b69
...
...
@@ -84,6 +84,7 @@ def inline_discussion(request, course_id, discussion_id):
# TODO (vshnayder): since none of this code seems to be aware of the fact that
# sometimes things go wrong, I suspect that the js client is also not
# checking for errors on request. Check and fix as needed.
log
.
error
(
"Error loading inline discussion threads."
)
raise
Http404
def
infogetter
(
thread
):
...
...
@@ -117,6 +118,7 @@ def forum_form_discussion(request, course_id):
unsafethreads
,
query_params
=
get_threads
(
request
,
course_id
)
# This might process a search query
threads
=
[
utils
.
safe_content
(
thread
)
for
thread
in
unsafethreads
]
except
(
cc
.
utils
.
CommentClientError
,
cc
.
utils
.
CommentClientUnknownError
)
as
err
:
log
.
error
(
"Error loading forum discussion threads:
%
s"
%
str
(
err
))
raise
Http404
user_info
=
cc
.
User
.
from_django_user
(
request
.
user
)
.
to_dict
()
...
...
@@ -167,21 +169,16 @@ def forum_form_discussion(request, course_id):
@login_required
def
single_thread
(
request
,
course_id
,
discussion_id
,
thread_id
):
if
request
.
is_ajax
():
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
cc_user
=
cc
.
User
.
from_django_user
(
request
.
user
)
user_info
=
cc_user
.
to_dict
()
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
cc_user
=
cc
.
User
.
from_django_user
(
request
.
user
)
user_info
=
cc_user
.
to_dict
()
try
:
last_read_time
=
datetime
.
datetime
.
utcnow
()
.
replace
(
tzinfo
=
utc
)
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S
%
z'
)
cc_user
.
update_read_states
(
course_id
,
thread_id
,
last_read_time
)
except
(
cc
.
utils
.
CommentClientError
,
cc
.
utils
.
CommentClientUnknownError
)
as
err
:
# TODO log error
pass
if
request
.
is_ajax
():
try
:
thread
=
cc
.
Thread
.
find
(
thread_id
)
.
retrieve
(
recursive
=
True
,
user_id
=
request
.
user
.
id
)
except
(
cc
.
utils
.
CommentClientError
,
cc
.
utils
.
CommentClientUnknownError
)
as
err
:
log
.
error
(
"Error loading single thread."
)
raise
Http404
courseware_context
=
get_courseware_context
(
thread
,
course
)
...
...
@@ -200,24 +197,14 @@ def single_thread(request, course_id, discussion_id, thread_id):
})
else
:
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
category_map
=
utils
.
get_discussion_category_map
(
course
)
cc_user
=
cc
.
User
.
from_django_user
(
request
.
user
)
user_info
=
cc_user
.
to_dict
()
try
:
last_read_time
=
datetime
.
datetime
.
utcnow
()
.
replace
(
tzinfo
=
utc
)
.
strftime
(
'
%
Y-
%
m-
%
dT
%
H:
%
M:
%
S
%
z'
)
cc_user
.
update_read_states
(
course_id
,
thread_id
,
last_read_time
)
except
(
cc
.
utils
.
CommentClientError
,
cc
.
utils
.
CommentClientUnknownError
)
as
err
:
# TODO log error
pass
try
:
threads
,
query_params
=
get_threads
(
request
,
course_id
)
thread
=
cc
.
Thread
.
find
(
thread_id
)
.
retrieve
(
recursive
=
True
,
user_id
=
request
.
user
.
id
)
threads
.
append
(
thread
.
to_dict
())
except
(
cc
.
utils
.
CommentClientError
,
cc
.
utils
.
CommentClientUnknownError
)
as
err
:
log
.
error
(
"Error loading single thread."
)
raise
Http404
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
...
...
lms/djangoapps/django_comment_client/utils.py
View file @
117c0b69
...
...
@@ -337,7 +337,7 @@ def safe_content(content):
'updated_at'
,
'depth'
,
'type'
,
'commentable_id'
,
'comments_count'
,
'at_position_list'
,
'children'
,
'highlighted_title'
,
'highlighted_body'
,
'courseware_title'
,
'courseware_url'
,
'tags'
,
'unread_comments_count'
,
'
viewe
d'
,
'
rea
d'
,
]
if
(
content
.
get
(
'anonymous'
)
is
False
)
and
(
content
.
get
(
'anonymous_to_peers'
)
is
False
):
...
...
lms/lib/comment_client/models.py
View file @
117c0b69
...
...
@@ -72,8 +72,8 @@ class Model(object):
for
k
,
v
in
kwargs
.
items
():
if
k
in
self
.
accessible_fields
:
self
.
__setattr__
(
k
,
v
)
#
else:
#
raise AttributeError("Field {0} does not exist".format(k))
else
:
raise
AttributeError
(
"Field {0} does not exist"
.
format
(
k
))
def
updatable_attributes
(
self
):
return
extract
(
self
.
attributes
,
self
.
updatable_fields
)
...
...
lms/lib/comment_client/thread.py
View file @
117c0b69
...
...
@@ -10,7 +10,7 @@ class Thread(models.Model):
'closed'
,
'tags'
,
'votes'
,
'commentable_id'
,
'username'
,
'user_id'
,
'created_at'
,
'updated_at'
,
'comments_count'
,
'unread_comments_count'
,
'at_position_list'
,
'children'
,
'type'
,
'highlighted_title'
,
'highlighted_body'
,
'endorsed'
,
'
un
read'
'highlighted_body'
,
'endorsed'
,
'read'
]
updatable_fields
=
[
...
...
@@ -60,7 +60,10 @@ class Thread(models.Model):
else
:
return
super
(
Thread
,
cls
)
.
url
(
action
,
params
)
# TODO: This is currently overriding Model._retrieve only to add parameters
# for the request. Model._retrieve should be modified to handle this such
# that subclasses don't need to override for this.
def
_retrieve
(
self
,
*
args
,
**
kwargs
):
url
=
self
.
url
(
action
=
'get'
,
params
=
self
.
attributes
)
response
=
perform_request
(
'get'
,
url
,
{
'recursive'
:
kwargs
.
get
(
'recursive'
),
'user_id'
:
kwargs
.
get
(
'user_id'
)})
response
=
perform_request
(
'get'
,
url
,
{
'recursive'
:
kwargs
.
get
(
'recursive'
),
'user_id'
:
kwargs
.
get
(
'user_id'
)
,
'mark_as_read'
:
kwargs
.
get
(
'mark_as_read'
,
True
)
})
self
.
update_attributes
(
**
response
)
lms/lib/comment_client/user.py
View file @
117c0b69
...
...
@@ -74,13 +74,6 @@ class User(models.Model):
response
=
perform_request
(
'get'
,
url
,
retrieve_params
)
self
.
update_attributes
(
**
response
)
def
update_read_states
(
self
,
course_id
,
thread_id
,
last_read_time
):
url
=
_url_for_read_states
(
self
.
id
)
response
=
perform_request
(
'put'
,
url
,
{
"course_id"
:
course_id
,
"thread_id"
:
thread_id
,
"last_read_time"
:
last_read_time
,
})
def
_url_for_vote_comment
(
comment_id
):
return
"{prefix}/comments/{comment_id}/votes"
.
format
(
prefix
=
settings
.
PREFIX
,
comment_id
=
comment_id
)
...
...
@@ -90,8 +83,5 @@ def _url_for_vote_thread(thread_id):
def
_url_for_subscription
(
user_id
):
return
"{prefix}/users/{user_id}/subscriptions"
.
format
(
prefix
=
settings
.
PREFIX
,
user_id
=
user_id
)
def
_url_for_read_states
(
user_id
):
return
"{prefix}/users/{user_id}/read_states"
.
format
(
prefix
=
settings
.
PREFIX
,
user_id
=
user_id
)
def
_url_for_user_active_threads
(
user_id
):
return
"{prefix}/users/{user_id}/active_threads"
.
format
(
prefix
=
settings
.
PREFIX
,
user_id
=
user_id
)
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