Commit 104e4c9f by Rocky Duan

Merge branch 'master' of github.com:MITx/mitx

parents fc4e21d4 6afe1709
...@@ -33,7 +33,7 @@ load-plugins= ...@@ -33,7 +33,7 @@ load-plugins=
# can either give multiple identifier separated by comma (,) or put this option # can either give multiple identifier separated by comma (,) or put this option
# multiple time (only on the command line, not in the configuration file where # multiple time (only on the command line, not in the configuration file where
# it should appear only once). # it should appear only once).
#disable= disable=E1102,W0142
[REPORTS] [REPORTS]
...@@ -82,7 +82,7 @@ zope=no ...@@ -82,7 +82,7 @@ zope=no
# List of members which are set dynamically and missed by pylint inference # List of members which are set dynamically and missed by pylint inference
# system, and so shouldn't trigger E0201 when accessed. Python regular # system, and so shouldn't trigger E0201 when accessed. Python regular
# expressions are accepted. # expressions are accepted.
generated-members=REQUEST,acl_users,aq_parent generated-members=REQUEST,acl_users,aq_parent,objects,DoesNotExist,can_read,can_write,get_url,size
[BASIC] [BASIC]
......
...@@ -264,14 +264,17 @@ def create_account(request, post_override=None): ...@@ -264,14 +264,17 @@ def create_account(request, post_override=None):
for a in ['username', 'email', 'password', 'name']: for a in ['username', 'email', 'password', 'name']:
if a not in post_vars: if a not in post_vars:
js['value'] = "Error (401 {field}). E-mail us.".format(field=a) js['value'] = "Error (401 {field}). E-mail us.".format(field=a)
js['field'] = a
return HttpResponse(json.dumps(js)) return HttpResponse(json.dumps(js))
if post_vars.get('honor_code', 'false') != u'true': if post_vars.get('honor_code', 'false') != u'true':
js['value'] = "To enroll, you must follow the honor code.".format(field=a) js['value'] = "To enroll, you must follow the honor code.".format(field=a)
js['field'] = 'honor_code'
return HttpResponse(json.dumps(js)) return HttpResponse(json.dumps(js))
if post_vars.get('terms_of_service', 'false') != u'true': if post_vars.get('terms_of_service', 'false') != u'true':
js['value'] = "You must accept the terms of service.".format(field=a) js['value'] = "You must accept the terms of service.".format(field=a)
js['field'] = 'terms_of_service'
return HttpResponse(json.dumps(js)) return HttpResponse(json.dumps(js))
# Confirm appropriate fields are there. # Confirm appropriate fields are there.
...@@ -288,18 +291,21 @@ def create_account(request, post_override=None): ...@@ -288,18 +291,21 @@ def create_account(request, post_override=None):
'terms_of_service': 'Accepting Terms of Service is required.', 'terms_of_service': 'Accepting Terms of Service is required.',
'honor_code': 'Agreeing to the Honor Code is required.'} 'honor_code': 'Agreeing to the Honor Code is required.'}
js['value'] = error_str[a] js['value'] = error_str[a]
js['field'] = a
return HttpResponse(json.dumps(js)) return HttpResponse(json.dumps(js))
try: try:
validate_email(post_vars['email']) validate_email(post_vars['email'])
except ValidationError: except ValidationError:
js['value'] = "Valid e-mail is required.".format(field=a) js['value'] = "Valid e-mail is required.".format(field=a)
js['field'] = 'email'
return HttpResponse(json.dumps(js)) return HttpResponse(json.dumps(js))
try: try:
validate_slug(post_vars['username']) validate_slug(post_vars['username'])
except ValidationError: except ValidationError:
js['value'] = "Username should only consist of A-Z and 0-9.".format(field=a) js['value'] = "Username should only consist of A-Z and 0-9.".format(field=a)
js['field'] = 'username'
return HttpResponse(json.dumps(js)) return HttpResponse(json.dumps(js))
u = User(username=post_vars['username'], u = User(username=post_vars['username'],
...@@ -315,10 +321,12 @@ def create_account(request, post_override=None): ...@@ -315,10 +321,12 @@ def create_account(request, post_override=None):
# Figure out the cause of the integrity error # Figure out the cause of the integrity error
if len(User.objects.filter(username=post_vars['username'])) > 0: if len(User.objects.filter(username=post_vars['username'])) > 0:
js['value'] = "An account with this username already exists." js['value'] = "An account with this username already exists."
js['field'] = 'username'
return HttpResponse(json.dumps(js)) return HttpResponse(json.dumps(js))
if len(User.objects.filter(email=post_vars['email'])) > 0: if len(User.objects.filter(email=post_vars['email'])) > 0:
js['value'] = "An account with this e-mail already exists." js['value'] = "An account with this e-mail already exists."
js['field'] = 'email'
return HttpResponse(json.dumps(js)) return HttpResponse(json.dumps(js))
raise raise
......
...@@ -53,8 +53,9 @@ class XMLModuleStore(ModuleStore): ...@@ -53,8 +53,9 @@ class XMLModuleStore(ModuleStore):
class_ = getattr(import_module(module_path), class_name) class_ = getattr(import_module(module_path), class_name)
self.default_class = class_ self.default_class = class_
log.debug('XMLModuleStore: eager=%s, data_dir = %s' % (eager, self.data_dir)) # TODO (cpennington): We need a better way of selecting specific sets of debug messages to enable. These were drowning out important messages
log.debug('default_class = %s' % self.default_class) #log.debug('XMLModuleStore: eager=%s, data_dir = %s' % (eager, self.data_dir))
#log.debug('default_class = %s' % self.default_class)
for course_dir in os.listdir(self.data_dir): for course_dir in os.listdir(self.data_dir):
if course_dirs is not None and course_dir not in course_dirs: if course_dirs is not None and course_dir not in course_dirs:
......
...@@ -430,6 +430,24 @@ PIPELINE_JS = { ...@@ -430,6 +430,24 @@ PIPELINE_JS = {
} }
} }
# Compile all coffee files in course data directories if they are out of date.
# TODO: Remove this once we move data into Mongo. This is only temporary while
# course data directories are still in use.
if os.path.isdir(DATA_DIR):
for course_dir in os.listdir(DATA_DIR):
js_dir = DATA_DIR / course_dir / "js"
if not os.path.isdir(js_dir):
continue
for filename in os.listdir(js_dir):
if filename.endswith('coffee'):
new_filename = os.path.splitext(filename)[0] + ".js"
if os.path.exists(js_dir / new_filename):
coffee_timestamp = os.stat(js_dir / filename).st_mtime
js_timestamp = os.stat(js_dir / new_filename).st_mtime
if coffee_timestamp <= js_timestamp:
continue
os.system("coffee -c %s" % (js_dir / filename))
PIPELINE_COMPILERS = [ PIPELINE_COMPILERS = [
'pipeline.compilers.sass.SASSCompiler', 'pipeline.compilers.sass.SASSCompiler',
'pipeline.compilers.coffee.CoffeeScriptCompiler', 'pipeline.compilers.coffee.CoffeeScriptCompiler',
......
...@@ -3,19 +3,19 @@ import os.path ...@@ -3,19 +3,19 @@ import os.path
import platform import platform
import sys import sys
def get_logger_config(log_dir, def get_logger_config(log_dir,
logging_env="no_env", logging_env="no_env",
tracking_filename=None, tracking_filename=None,
syslog_addr=None, syslog_addr=None,
debug=False): debug=False):
"""Return the appropriate logging config dictionary. You should assign the """Return the appropriate logging config dictionary. You should assign the
result of this to the LOGGING var in your settings. The reason it's done result of this to the LOGGING var in your settings. The reason it's done
this way instead of registering directly is because I didn't want to worry this way instead of registering directly is because I didn't want to worry
about resetting the logging state if this is called multiple times when about resetting the logging state if this is called multiple times when
settings are extended.""" settings are extended."""
# If we're given an explicit place to put tracking logs, we do that (say for # If we're given an explicit place to put tracking logs, we do that (say for
# debugging). However, logging is not safe for multiple processes hitting # debugging). However, logging is not safe for multiple processes hitting
# the same file. So if it's left blank, we dynamically create the filename # the same file. So if it's left blank, we dynamically create the filename
# based on the PID of this worker process. # based on the PID of this worker process.
if tracking_filename: if tracking_filename:
...@@ -33,7 +33,7 @@ def get_logger_config(log_dir, ...@@ -33,7 +33,7 @@ def get_logger_config(log_dir,
return { return {
'version': 1, 'version': 1,
'disable_existing_loggers': True, 'disable_existing_loggers': False,
'formatters' : { 'formatters' : {
'standard' : { 'standard' : {
'format' : '%(asctime)s %(levelname)s %(process)d [%(name)s] %(filename)s:%(lineno)d - %(message)s', 'format' : '%(asctime)s %(levelname)s %(process)d [%(name)s] %(filename)s:%(lineno)d - %(message)s',
......
...@@ -19,19 +19,19 @@ ...@@ -19,19 +19,19 @@
<div id="register_error" name="register_error"></div> <div id="register_error" name="register_error"></div>
<div class="input-group"> <div class="input-group">
<label>E-mail*</label> <label data-field="email">E-mail*</label>
<input name="email" type="email" placeholder="E-mail*"> <input name="email" type="email" placeholder="E-mail*">
<label>Password*</label> <label data-field="password">Password*</label>
<input name="password" type="password" placeholder="Password*"> <input name="password" type="password" placeholder="Password*">
<label>Public Username*</label> <label data-field="username">Public Username*</label>
<input name="username" type="text" placeholder="Public Username*"> <input name="username" type="text" placeholder="Public Username*">
<label>Full Name</label> <label data-field="name">Full Name</label>
<input name="name" type="text" placeholder="Full Name*"> <input name="name" type="text" placeholder="Full Name*">
</div> </div>
<div class="input-group"> <div class="input-group">
<section class="citizenship"> <section class="citizenship">
<label>Ed. completed</label> <label data-field="level_of_education">Ed. completed</label>
<div class="input-wrapper"> <div class="input-wrapper">
<select name="level_of_education"> <select name="level_of_education">
<option value="">--</option> <option value="">--</option>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
</section> </section>
<section class="gender"> <section class="gender">
<label>Gender</label> <label data-field="gender">Gender</label>
<div class="input-wrapper"> <div class="input-wrapper">
<select name="gender"> <select name="gender">
<option value="">--</option> <option value="">--</option>
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
</section> </section>
<section class="date-of-birth"> <section class="date-of-birth">
<label>Year of birth</label> <label data-field="date-of-birth">Year of birth</label>
<div class="input-wrapper"> <div class="input-wrapper">
<select name="year_of_birth"> <select name="year_of_birth">
<option value="">--</option> <option value="">--</option>
...@@ -67,21 +67,21 @@ ...@@ -67,21 +67,21 @@
</div> </div>
</section> </section>
<label>Mailing address</label> <label data-field="mailing_address">Mailing address</label>
<textarea name="mailing_address" placeholder="Mailing address"></textarea> <textarea name="mailing_address" placeholder="Mailing address"></textarea>
<label>Goals in signing up for edX</label> <label data-field="goals">Goals in signing up for edX</label>
<textarea name="goals" placeholder="Goals in signing up for edX"></textarea> <textarea name="goals" placeholder="Goals in signing up for edX"></textarea>
</div> </div>
<div class="input-group"> <div class="input-group">
<label class="terms-of-service"> <label data-field="terms_of_service" class="terms-of-service">
<input name="terms_of_service" type="checkbox" value="true"> <input name="terms_of_service" type="checkbox" value="true">
I agree to the I agree to the
<a href="${reverse('tos')}" target="_blank">Terms of Service</a>* <a href="${reverse('tos')}" target="_blank">Terms of Service</a>*
</label> </label>
<label class="honor-code"> <label data-field="honor_code" class="honor-code">
<input name="honor_code" type="checkbox" value="true"> <input name="honor_code" type="checkbox" value="true">
I agree to the I agree to the
<a href="${reverse('honor')}" target="_blank">Honor Code</a>* <a href="${reverse('honor')}" target="_blank">Honor Code</a>*
...@@ -115,7 +115,9 @@ ...@@ -115,7 +115,9 @@
if(json.success) { if(json.success) {
location.href="${reverse('dashboard')}"; location.href="${reverse('dashboard')}";
} else { } else {
$(".field-error").removeClass('field-error');
$('#register_error').html(json.value).stop().css("display", "block"); $('#register_error').html(json.value).stop().css("display", "block");
$("[data-field='"+json.field+"']").addClass('field-error')
} }
}); });
})(this) })(this)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment