@@ -181,6 +181,6 @@ if SEGMENT_IO_KEY:
|
||||
#####################################################################
|
||||
# Lastly, see if the developer has any local overrides.
|
||||
try:
|
||||
from .private import *
|
||||
from .private import * # pylint: disable=F0401
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -3,7 +3,7 @@ import json
|
||||
import logging
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
import string # pylint: disable=W0402
|
||||
import fnmatch
|
||||
|
||||
from textwrap import dedent
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from django.conf.urls import *
|
||||
from django.conf.urls import url, patterns
|
||||
|
||||
urlpatterns = patterns('', # nopep8
|
||||
url(r'^$', 'heartbeat.views.heartbeat', name='heartbeat'),
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
django admin pages for courseware model
|
||||
'''
|
||||
|
||||
from student.models import *
|
||||
from student.models import UserProfile, UserTestGroup, CourseEnrollmentAllowed
|
||||
from student.models import CourseEnrollment, Registration, PendingNameChange
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
admin.site.register(UserProfile)
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ rate -- messages per second
|
||||
self.log_file.write(datetime.datetime.utcnow().isoformat() + ' -- ' + text + '\n')
|
||||
|
||||
def handle(self, *args, **options):
|
||||
global log_file
|
||||
(user_file, message_base, logfilename, ratestr) = args
|
||||
|
||||
users = [u.strip() for u in open(user_file).readlines()]
|
||||
|
||||
@@ -4,7 +4,7 @@ import json
|
||||
import logging
|
||||
import random
|
||||
import re
|
||||
import string
|
||||
import string # pylint: disable=W0402
|
||||
import urllib
|
||||
import uuid
|
||||
import time
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
django admin pages for courseware model
|
||||
'''
|
||||
|
||||
from track.models import *
|
||||
from track.models import TrackingLog
|
||||
from django.contrib import admin
|
||||
|
||||
admin.site.register(TrackingLog)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
# Provides sympy representation.
|
||||
|
||||
import os
|
||||
import string
|
||||
import string # pylint: disable=W0402
|
||||
import re
|
||||
import logging
|
||||
import operator
|
||||
|
||||
@@ -18,8 +18,6 @@ def load_function(path):
|
||||
|
||||
|
||||
def contentstore(name='default'):
|
||||
global _CONTENTSTORE
|
||||
|
||||
if name not in _CONTENTSTORE:
|
||||
class_ = load_function(settings.CONTENTSTORE['ENGINE'])
|
||||
options = {}
|
||||
|
||||
@@ -26,8 +26,6 @@ def load_function(path):
|
||||
|
||||
|
||||
def modulestore(name='default'):
|
||||
global _MODULESTORES
|
||||
|
||||
if name not in _MODULESTORES:
|
||||
class_ = load_function(settings.MODULESTORE[name]['ENGINE'])
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
django admin pages for courseware model
|
||||
'''
|
||||
|
||||
from courseware.models import *
|
||||
from courseware.models import StudentModule, OfflineComputedGrade, OfflineComputedGradeLog
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ from django.conf import settings
|
||||
from .mustache_helpers import mustache_helpers
|
||||
from functools import partial
|
||||
|
||||
from .utils import *
|
||||
from .utils import extend_content, merge_dict, render_mustache
|
||||
import django_comment_client.settings as cc_settings
|
||||
|
||||
import pystache_custom as pystache
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import string
|
||||
import string # pylint: disable=W0402
|
||||
import random
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
@@ -73,21 +73,17 @@ def get_discussion_id_map(course):
|
||||
"""
|
||||
return a dict of the form {category: modules}
|
||||
"""
|
||||
global _DISCUSSIONINFO
|
||||
initialize_discussion_info(course)
|
||||
return _DISCUSSIONINFO[course.id]['id_map']
|
||||
|
||||
|
||||
def get_discussion_title(course, discussion_id):
|
||||
global _DISCUSSIONINFO
|
||||
initialize_discussion_info(course)
|
||||
title = _DISCUSSIONINFO[course.id]['id_map'].get(discussion_id, {}).get('title', '(no title)')
|
||||
return title
|
||||
|
||||
|
||||
def get_discussion_category_map(course):
|
||||
|
||||
global _DISCUSSIONINFO
|
||||
initialize_discussion_info(course)
|
||||
return filter_unstarted_categories(_DISCUSSIONINFO[course.id]['category_map'])
|
||||
|
||||
@@ -141,8 +137,6 @@ def sort_map_entries(category_map):
|
||||
|
||||
|
||||
def initialize_discussion_info(course):
|
||||
global _DISCUSSIONINFO
|
||||
|
||||
course_id = course.id
|
||||
|
||||
discussion_id_map = {}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
# django management command: dump grades to csv files
|
||||
# for use by batch processes
|
||||
|
||||
from instructor.offline_gradecalc import *
|
||||
from instructor.offline_gradecalc import offline_grade_calculation
|
||||
from courseware.courses import get_course_by_id
|
||||
from xmodule.modulestore.django import modulestore
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import string
|
||||
import string # pylint: disable=W0402
|
||||
import datetime
|
||||
from getpass import getpass
|
||||
import json
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
django admin pages for courseware model
|
||||
'''
|
||||
|
||||
from psychometrics.models import *
|
||||
from psychometrics.models import PsychometricData
|
||||
from django.contrib import admin
|
||||
|
||||
admin.site.register(PsychometricData)
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
import json
|
||||
|
||||
from courseware.models import *
|
||||
from track.models import *
|
||||
from psychometrics.models import *
|
||||
from courseware.models import StudentModule
|
||||
from track.models import TrackingLog
|
||||
from psychometrics.models import PsychometricData
|
||||
from xmodule.modulestore import Location
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
@@ -14,7 +14,8 @@ from scipy.optimize import curve_fit
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.models import Sum, Max
|
||||
from psychometrics.models import *
|
||||
from psychometrics.models import PsychometricData
|
||||
from courseware.models import StudentModule
|
||||
from pytz import UTC
|
||||
|
||||
log = logging.getLogger("mitx.psychometrics")
|
||||
@@ -303,7 +304,7 @@ def generate_plots_for_problem(problem):
|
||||
def make_psychometrics_data_update_handler(course_id, user, module_state_key):
|
||||
"""
|
||||
Construct and return a procedure which may be called to update
|
||||
the PsychometricsData instance for the given StudentModule instance.
|
||||
the PsychometricData instance for the given StudentModule instance.
|
||||
"""
|
||||
sm, status = StudentModule.objects.get_or_create(
|
||||
course_id=course_id,
|
||||
|
||||
@@ -258,6 +258,6 @@ if SEGMENT_IO_LMS_KEY:
|
||||
#####################################################################
|
||||
# Lastly, see if the developer has any local overrides.
|
||||
try:
|
||||
from .private import *
|
||||
from .private import * # pylint: disable=F0401
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from .utils import *
|
||||
from .utils import CommentClientError, perform_request
|
||||
|
||||
from .thread import Thread
|
||||
from .thread import Thread, _url_for_flag_abuse_thread, _url_for_unflag_abuse_thread
|
||||
import models
|
||||
import settings
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ from .thread import Thread
|
||||
from .user import User
|
||||
from .commentable import Commentable
|
||||
|
||||
from .utils import *
|
||||
from .utils import perform_request
|
||||
|
||||
import settings
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
from .utils import *
|
||||
|
||||
import models
|
||||
import settings
|
||||
|
||||
|
||||
@@ -1,226 +0,0 @@
|
||||
def delete_threads(commentable_id, *args, **kwargs):
|
||||
return _perform_request('delete', _url_for_commentable_threads(commentable_id), *args, **kwargs)
|
||||
|
||||
|
||||
def get_threads(commentable_id, recursive=False, query_params={}, *args, **kwargs):
|
||||
default_params = {'page': 1, 'per_page': 20, 'recursive': recursive}
|
||||
attributes = dict(default_params.items() + query_params.items())
|
||||
response = _perform_request('get', _url_for_threads(commentable_id), attributes, *args, **kwargs)
|
||||
return response.get('collection', []), response.get('page', 1), response.get('num_pages', 1)
|
||||
|
||||
|
||||
def search_threads(course_id, recursive=False, query_params={}, *args, **kwargs):
|
||||
default_params = {'page': 1, 'per_page': 20, 'course_id': course_id, 'recursive': recursive}
|
||||
attributes = dict(default_params.items() + query_params.items())
|
||||
response = _perform_request('get', _url_for_search_threads(), attributes, *args, **kwargs)
|
||||
return response.get('collection', []), response.get('page', 1), response.get('num_pages', 1)
|
||||
|
||||
|
||||
def search_similar_threads(course_id, recursive=False, query_params={}, *args, **kwargs):
|
||||
default_params = {'course_id': course_id, 'recursive': recursive}
|
||||
attributes = dict(default_params.items() + query_params.items())
|
||||
return _perform_request('get', _url_for_search_similar_threads(), attributes, *args, **kwargs)
|
||||
|
||||
|
||||
def search_recent_active_threads(course_id, recursive=False, query_params={}, *args, **kwargs):
|
||||
default_params = {'course_id': course_id, 'recursive': recursive}
|
||||
attributes = dict(default_params.items() + query_params.items())
|
||||
return _perform_request('get', _url_for_search_recent_active_threads(), attributes, *args, **kwargs)
|
||||
|
||||
|
||||
def search_trending_tags(course_id, query_params={}, *args, **kwargs):
|
||||
default_params = {'course_id': course_id}
|
||||
attributes = dict(default_params.items() + query_params.items())
|
||||
return _perform_request('get', _url_for_search_trending_tags(), attributes, *args, **kwargs)
|
||||
|
||||
|
||||
def create_user(attributes, *args, **kwargs):
|
||||
return _perform_request('post', _url_for_users(), attributes, *args, **kwargs)
|
||||
|
||||
|
||||
def update_user(user_id, attributes, *args, **kwargs):
|
||||
return _perform_request('put', _url_for_user(user_id), attributes, *args, **kwargs)
|
||||
|
||||
|
||||
def get_threads_tags(*args, **kwargs):
|
||||
return _perform_request('get', _url_for_threads_tags(), {}, *args, **kwargs)
|
||||
|
||||
|
||||
def tags_autocomplete(value, *args, **kwargs):
|
||||
return _perform_request('get', _url_for_threads_tags_autocomplete(), {'value': value}, *args, **kwargs)
|
||||
|
||||
|
||||
def create_thread(commentable_id, attributes, *args, **kwargs):
|
||||
return _perform_request('post', _url_for_threads(commentable_id), attributes, *args, **kwargs)
|
||||
|
||||
|
||||
def get_thread(thread_id, recursive=False, *args, **kwargs):
|
||||
return _perform_request('get', _url_for_thread(thread_id), {'recursive': recursive}, *args, **kwargs)
|
||||
|
||||
|
||||
def update_thread(thread_id, attributes, *args, **kwargs):
|
||||
return _perform_request('put', _url_for_thread(thread_id), attributes, *args, **kwargs)
|
||||
|
||||
|
||||
def create_comment(thread_id, attributes, *args, **kwargs):
|
||||
return _perform_request('post', _url_for_thread_comments(thread_id), attributes, *args, **kwargs)
|
||||
|
||||
|
||||
def delete_thread(thread_id, *args, **kwargs):
|
||||
return _perform_request('delete', _url_for_thread(thread_id), *args, **kwargs)
|
||||
|
||||
|
||||
def get_comment(comment_id, recursive=False, *args, **kwargs):
|
||||
return _perform_request('get', _url_for_comment(comment_id), {'recursive': recursive}, *args, **kwargs)
|
||||
|
||||
|
||||
def update_comment(comment_id, attributes, *args, **kwargs):
|
||||
return _perform_request('put', _url_for_comment(comment_id), attributes, *args, **kwargs)
|
||||
|
||||
|
||||
def create_sub_comment(comment_id, attributes, *args, **kwargs):
|
||||
return _perform_request('post', _url_for_comment(comment_id), attributes, *args, **kwargs)
|
||||
|
||||
|
||||
def delete_comment(comment_id, *args, **kwargs):
|
||||
return _perform_request('delete', _url_for_comment(comment_id), *args, **kwargs)
|
||||
|
||||
|
||||
def vote_for_comment(comment_id, user_id, value, *args, **kwargs):
|
||||
return _perform_request('put', _url_for_vote_comment(comment_id), {'user_id': user_id, 'value': value}, *args, **kwargs)
|
||||
|
||||
|
||||
def undo_vote_for_comment(comment_id, user_id, *args, **kwargs):
|
||||
return _perform_request('delete', _url_for_vote_comment(comment_id), {'user_id': user_id}, *args, **kwargs)
|
||||
|
||||
|
||||
def vote_for_thread(thread_id, user_id, value, *args, **kwargs):
|
||||
return _perform_request('put', _url_for_vote_thread(thread_id), {'user_id': user_id, 'value': value}, *args, **kwargs)
|
||||
|
||||
|
||||
def undo_vote_for_thread(thread_id, user_id, *args, **kwargs):
|
||||
return _perform_request('delete', _url_for_vote_thread(thread_id), {'user_id': user_id}, *args, **kwargs)
|
||||
|
||||
|
||||
def get_notifications(user_id, *args, **kwargs):
|
||||
return _perform_request('get', _url_for_notifications(user_id), *args, **kwargs)
|
||||
|
||||
|
||||
def get_user_info(user_id, complete=True, *args, **kwargs):
|
||||
return _perform_request('get', _url_for_user(user_id), {'complete': complete}, *args, **kwargs)
|
||||
|
||||
|
||||
def subscribe(user_id, subscription_detail, *args, **kwargs):
|
||||
return _perform_request('post', _url_for_subscription(user_id), subscription_detail, *args, **kwargs)
|
||||
|
||||
|
||||
def subscribe_user(user_id, followed_user_id, *args, **kwargs):
|
||||
return subscribe(user_id, {'source_type': 'user', 'source_id': followed_user_id})
|
||||
|
||||
follow = subscribe_user
|
||||
|
||||
|
||||
def subscribe_thread(user_id, thread_id, *args, **kwargs):
|
||||
return subscribe(user_id, {'source_type': 'thread', 'source_id': thread_id})
|
||||
|
||||
|
||||
def subscribe_commentable(user_id, commentable_id, *args, **kwargs):
|
||||
return subscribe(user_id, {'source_type': 'other', 'source_id': commentable_id})
|
||||
|
||||
|
||||
def unsubscribe(user_id, subscription_detail, *args, **kwargs):
|
||||
return _perform_request('delete', _url_for_subscription(user_id), subscription_detail, *args, **kwargs)
|
||||
|
||||
|
||||
def unsubscribe_user(user_id, followed_user_id, *args, **kwargs):
|
||||
return unsubscribe(user_id, {'source_type': 'user', 'source_id': followed_user_id})
|
||||
|
||||
unfollow = unsubscribe_user
|
||||
|
||||
|
||||
def unsubscribe_thread(user_id, thread_id, *args, **kwargs):
|
||||
return unsubscribe(user_id, {'source_type': 'thread', 'source_id': thread_id})
|
||||
|
||||
|
||||
def unsubscribe_commentable(user_id, commentable_id, *args, **kwargs):
|
||||
return unsubscribe(user_id, {'source_type': 'other', 'source_id': commentable_id})
|
||||
|
||||
|
||||
def _perform_request(method, url, data_or_params=None, *args, **kwargs):
|
||||
if method in ['post', 'put', 'patch']:
|
||||
response = requests.request(method, url, data=data_or_params)
|
||||
else:
|
||||
response = requests.request(method, url, params=data_or_params)
|
||||
if 200 < response.status_code < 500:
|
||||
raise CommentClientError(response.text)
|
||||
elif response.status_code == 500:
|
||||
raise CommentClientUnknownError(response.text)
|
||||
else:
|
||||
if kwargs.get("raw", False):
|
||||
return response.text
|
||||
else:
|
||||
return json.loads(response.text)
|
||||
|
||||
|
||||
def _url_for_threads(commentable_id):
|
||||
return "{prefix}/{commentable_id}/threads".format(prefix=PREFIX, commentable_id=commentable_id)
|
||||
|
||||
|
||||
def _url_for_thread(thread_id):
|
||||
return "{prefix}/threads/{thread_id}".format(prefix=PREFIX, thread_id=thread_id)
|
||||
|
||||
|
||||
def _url_for_thread_comments(thread_id):
|
||||
return "{prefix}/threads/{thread_id}/comments".format(prefix=PREFIX, thread_id=thread_id)
|
||||
|
||||
|
||||
def _url_for_comment(comment_id):
|
||||
return "{prefix}/comments/{comment_id}".format(prefix=PREFIX, comment_id=comment_id)
|
||||
|
||||
|
||||
def _url_for_vote_comment(comment_id):
|
||||
return "{prefix}/comments/{comment_id}/votes".format(prefix=PREFIX, comment_id=comment_id)
|
||||
|
||||
|
||||
def _url_for_vote_thread(thread_id):
|
||||
return "{prefix}/threads/{thread_id}/votes".format(prefix=PREFIX, thread_id=thread_id)
|
||||
|
||||
|
||||
def _url_for_notifications(user_id):
|
||||
return "{prefix}/users/{user_id}/notifications".format(prefix=PREFIX, user_id=user_id)
|
||||
|
||||
|
||||
def _url_for_subscription(user_id):
|
||||
return "{prefix}/users/{user_id}/subscriptions".format(prefix=PREFIX, user_id=user_id)
|
||||
|
||||
|
||||
def _url_for_user(user_id):
|
||||
return "{prefix}/users/{user_id}".format(prefix=PREFIX, user_id=user_id)
|
||||
|
||||
|
||||
def _url_for_search_threads():
|
||||
return "{prefix}/search/threads".format(prefix=PREFIX)
|
||||
|
||||
|
||||
def _url_for_search_similar_threads():
|
||||
return "{prefix}/search/threads/more_like_this".format(prefix=PREFIX)
|
||||
|
||||
|
||||
def _url_for_search_recent_active_threads():
|
||||
return "{prefix}/search/threads/recent_active".format(prefix=PREFIX)
|
||||
|
||||
|
||||
def _url_for_search_trending_tags():
|
||||
return "{prefix}/search/tags/trending".format(prefix=PREFIX)
|
||||
|
||||
|
||||
def _url_for_threads_tags():
|
||||
return "{prefix}/threads/tags".format(prefix=PREFIX)
|
||||
|
||||
|
||||
def _url_for_threads_tags_autocomplete():
|
||||
return "{prefix}/threads/tags/autocomplete".format(prefix=PREFIX)
|
||||
|
||||
|
||||
def _url_for_users():
|
||||
return "{prefix}/users".format(prefix=PREFIX)
|
||||
@@ -1,4 +1,5 @@
|
||||
from .utils import *
|
||||
from .utils import merge_dict, strip_blank, strip_none, extract, perform_request
|
||||
from .utils import CommentClientError
|
||||
import models
|
||||
import settings
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from .utils import *
|
||||
from .utils import merge_dict, perform_request, CommentClientError
|
||||
|
||||
import models
|
||||
import settings
|
||||
|
||||
4
pylintrc
4
pylintrc
@@ -41,6 +41,10 @@ disable=
|
||||
# W0142: Used * or ** magic
|
||||
I0011,C0301,W0141,W0142,
|
||||
|
||||
# Django makes classes that trigger these
|
||||
# W0232: Class has no __init__ method
|
||||
W0232,
|
||||
|
||||
# Might use these when the code is in better shape
|
||||
# C0302: Too many lines in module
|
||||
# R0201: Method could be a function
|
||||
|
||||
Reference in New Issue
Block a user