hook up panel to new stats service

This commit is contained in:
Kevin Chugh
2013-07-25 03:23:04 -04:00
parent 5d106ee048
commit d95693ebb7
7 changed files with 51 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ from django.conf.urls.defaults import url, patterns
urlpatterns = patterns('django_comment_client.base.views', # nopep8
url(r'upload$', 'upload', name='upload'),
url(r'users/(?P<user_id>\w+)/update_moderator_status$', 'update_moderator_status', name='update_moderator_status'),
url(r'panel/stats', 'user_stats', name='user_stats'),
url(r'threads/tags/autocomplete$', 'tags_autocomplete', name='tags_autocomplete'),
url(r'threads/(?P<thread_id>[\w\-]+)/update$', 'update_thread', name='update_thread'),
url(r'threads/(?P<thread_id>[\w\-]+)/reply$', 'create_comment', name='create_comment'),
@@ -17,7 +18,6 @@ urlpatterns = patterns('django_comment_client.base.views', # nopep8
url(r'threads/(?P<thread_id>[\w\-]+)/follow$', 'follow_thread', name='follow_thread'),
url(r'threads/(?P<thread_id>[\w\-]+)/unfollow$', 'unfollow_thread', name='unfollow_thread'),
url(r'threads/(?P<thread_id>[\w\-]+)/close$', 'openclose_thread', name='openclose_thread'),
url(r'comments/(?P<comment_id>[\w\-]+)/update$', 'update_comment', name='update_comment'),
url(r'comments/(?P<comment_id>[\w\-]+)/endorse$', 'endorse_comment', name='endorse_comment'),
url(r'comments/(?P<comment_id>[\w\-]+)/reply$', 'create_sub_comment', name='create_sub_comment'),

View File

@@ -649,3 +649,20 @@ def upload(request, course_id): # ajax upload file to a question or answer
'file_url': file_url,
}
})
@login_required
def user_stats(request, course_id):
try:
profiled_user = cc.User(id=request.user.id, course_id=course_id)
print "\n\n\n*******************\n\n\n"
print profiled_user.course_id
query_params = {}
user_stats_results = profiled_user.stats(query_params)
return utils.JsonResponse({
'stats': user_stats_results
})
except (cc.utils.CommentClientError, cc.utils.CommentClientUnknownError, User.DoesNotExist):
raise Http404