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
c2f27a5f
Commit
c2f27a5f
authored
12 years ago
by
Rocky Duan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
some starting refactor ideas
parent
f1dabe15
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
15 deletions
+20
-15
lms/djangoapps/django_comment_client/base/views.py
+0
-0
lms/djangoapps/django_comment_client/forum/views.py
+20
-15
No files found.
lms/djangoapps/django_comment_client/base/views.py
View file @
c2f27a5f
This diff is collapsed.
Click to expand it.
lms/djangoapps/django_comment_client/forum/views.py
View file @
c2f27a5f
...
...
@@ -15,7 +15,7 @@ import django_comment_client.utils as utils
from
urllib
import
urlencode
import
json
import
comment_client
import
comment_client
as
c
import
dateutil
from
django_comment_client.permissions
import
check_permissions_by_view
...
...
@@ -59,7 +59,7 @@ def render_discussion(request, course_id, threads, discussion_id=None, \
context
=
{
'threads'
:
threads
,
'discussion_id'
:
discussion_id
,
'user_info'
:
comment_client
.
get_user_info
(
request
.
user
.
id
,
raw
=
True
),
'user_info'
:
dict
(
c
.
User
.
from_django_user
(
request
.
user
)),
#
comment_client.get_user_info(request.user.id, raw=True),
'course_id'
:
course_id
,
'request'
:
request
,
'performed_search'
:
_should_perform_search
(
request
),
...
...
@@ -86,13 +86,17 @@ def get_threads(request, course_id, discussion_id):
'sort_order'
:
request
.
GET
.
get
(
'sort_order'
,
'desc'
),
'text'
:
request
.
GET
.
get
(
'text'
,
''
),
'tags'
:
request
.
GET
.
get
(
'tags'
,
''
),
'commentable_id'
:
discussion_id
,
'course_id'
:
course_id
,
}
if
_should_perform_search
(
request
):
query_params
[
'commentable_id'
]
=
discussion_id
threads
,
page
,
num_pages
=
comment_client
.
search_threads
(
course_id
,
recursive
=
False
,
query_params
=
utils
.
strip_none
(
query_params
))
else
:
threads
,
page
,
num_pages
=
comment_client
.
get_threads
(
discussion_id
,
recursive
=
False
,
query_params
=
utils
.
strip_none
(
query_params
))
threads
,
page
,
num_pages
=
c
.
Thread
.
search
(
query_params
)
#if _should_perform_search(request):
# query_params['commentable_id'] = discussion_id
# threads, page, num_pages = c.Thread.searchcomment_client.search_threads(course_id, recursive=False, query_params=utils.strip_none(query_params))
#else:
# threads, page, num_pages = comment_client.get_threads(discussion_id, recursive=False, query_params=utils.strip_none(query_params))
query_params
[
'page'
]
=
page
query_params
[
'num_pages'
]
=
num_pages
...
...
@@ -122,14 +126,14 @@ def forum_form_discussion(request, course_id, discussion_id):
content
=
render_forum_discussion
(
request
,
course_id
,
threads
,
discussion_id
=
discussion_id
,
\
query_params
=
query_params
)
recent_active_threads
=
c
omment_client
.
search_recent_active_threads
(
recent_active_threads
=
c
.
search_recent_active_threads
(
course_id
,
recursive
=
False
,
query_params
=
{
'follower_id'
:
request
.
user
.
id
,
'commentable_id'
:
discussion_id
},
)
trending_tags
=
c
omment_client
.
search_trending_tags
(
trending_tags
=
c
.
search_trending_tags
(
course_id
,
query_params
=
{
'commentable_id'
:
discussion_id
},
)
...
...
@@ -167,15 +171,16 @@ def get_annotated_content_infos(thread, user, is_thread=True):
def
render_single_thread
(
request
,
discussion_id
,
course_id
,
thread_id
):
thread
=
comment_client
.
get_thread
(
thread_id
,
recursive
=
True
)
thread
=
c
.
Thread
.
find
(
thread_id
)
.
retrieve_with_comments
()
#comment_client.get_thread(thread_id, recursive=True)
annotated_content_info
=
get_annotated_content_infos
(
thread
=
thread
,
\
annotated_content_info
=
get_annotated_content_infos
(
thread
=
dict
(
thread
)
,
\
user
=
request
.
user
,
is_thread
=
True
)
context
=
{
'discussion_id'
:
discussion_id
,
'thread'
:
thread
,
'user_info'
:
comment_client
.
get_user_info
(
request
.
user
.
id
,
raw
=
True
),
'user_info'
:
dict
(
c
.
User
.
from_django_user
(
request
.
user
)),
#
get_user_info(request.user.id, raw=True),
'annotated_content_info'
:
json
.
dumps
(
annotated_content_info
),
'course_id'
:
course_id
,
'request'
:
request
,
...
...
@@ -186,9 +191,9 @@ def single_thread(request, course_id, discussion_id, thread_id):
if
request
.
is_ajax
():
thread
=
comment_client
.
get_thread
(
thread_id
,
recursive
=
True
)
thread
=
c
.
Thread
.
find
(
thread_id
)
.
retrieve_with_comments
()
#c
omment_client.get_thread(thread_id, recursive=True)
annotated_content_info
=
get_annotated_content_infos
(
thread
,
request
.
user
)
context
=
{
'thread'
:
thread
}
context
=
{
'thread'
:
dict
(
thread
)
}
html
=
render_to_string
(
'discussion/_ajax_single_thread.html'
,
context
)
return
utils
.
JsonResponse
({
...
...
@@ -218,7 +223,7 @@ def search(request, course_id):
commentable_id
=
request
.
GET
.
get
(
'commentable_id'
,
None
)
tags
=
request
.
GET
.
get
(
'tags'
,
None
)
threads
=
c
omment_client
.
search_threads
({
threads
=
c
.
Threads
.
search
({
'text'
:
text
,
'commentable_id'
:
commentable_id
,
'tags'
:
tags
,
...
...
This diff is collapsed.
Click to expand it.
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