get closer to working again
This commit is contained in:
@@ -47,6 +47,7 @@ from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
from django.db.models.signals import post_save
|
||||
from django.dispatch import receiver
|
||||
from django.forms import ModelForm
|
||||
|
||||
import comment_client as cc
|
||||
from django_comment_client.models import Role
|
||||
@@ -194,7 +195,7 @@ class TestCenterUser(models.Model):
|
||||
|
||||
# Confirmation
|
||||
upload_status = models.CharField(max_length=20, blank=True) # 'Error' or 'Accepted'
|
||||
uploaded_at = models.DateTimeField(null=True, db_index=True)
|
||||
uploaded_at = models.DateTimeField(null=True, blank=True, db_index=True)
|
||||
upload_error_message = models.CharField(max_length=512, blank=True)
|
||||
|
||||
@staticmethod
|
||||
@@ -206,7 +207,56 @@ class TestCenterUser(models.Model):
|
||||
@property
|
||||
def email(self):
|
||||
return self.user.email
|
||||
|
||||
def needs_update(self, dict):
|
||||
# needs_updating = any([__getattribute__(fieldname) != dict[fieldname]
|
||||
# for fieldname in TestCenterUser.user_provided_fields()])
|
||||
for fieldname in TestCenterUser.user_provided_fields():
|
||||
if self.__getattribute__(fieldname) != dict[fieldname]:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def update(self, dict):
|
||||
# leave user and client_candidate_id as before
|
||||
self.user_updated_at = datetime.now()
|
||||
for fieldname in TestCenterUser.user_provided_fields():
|
||||
self.__setattr__(fieldname, dict[fieldname])
|
||||
|
||||
@staticmethod
|
||||
def create(user, dict):
|
||||
testcenter_user = TestCenterUser(user=user)
|
||||
testcenter_user.update(dict)
|
||||
# testcenter_user.candidate_id remains unset
|
||||
# TODO: assign an ID of our own:
|
||||
testcenter_user.client_candidate_id = 'edx' + '123456' # some unique value
|
||||
|
||||
|
||||
class TestCenterUserForm(ModelForm):
|
||||
class Meta:
|
||||
model = TestCenterUser
|
||||
fields = ( 'first_name', 'middle_name', 'last_name', 'suffix', 'salutation',
|
||||
'address_1', 'address_2', 'address_3', 'city', 'state', 'postal_code', 'country',
|
||||
'phone', 'extension', 'phone_country_code', 'fax', 'fax_country_code', 'company_name')
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ACCOMODATION_CODES = (
|
||||
('EQPMNT', 'Equipment'),
|
||||
('ET12ET', 'Extra Time - 1/2 Exam Time'),
|
||||
('ET30MN', 'Extra Time - 30 Minutes'),
|
||||
('ETDBTM', 'Extra Time - Double Time'),
|
||||
('SEPRMM', 'Separate Room'),
|
||||
('SRREAD', 'Separate Room & Reader'),
|
||||
('SRRERC', 'Separate Room & Reader/Recorder'),
|
||||
('SRRECR', 'Separate Room & Recorder'),
|
||||
('SRSEAN', 'Separate Room & Service Animal'),
|
||||
('SRSGNR', 'Separate Room & Sign Lang Interp'),
|
||||
)
|
||||
|
||||
class TestCenterRegistration(models.Model):
|
||||
"""
|
||||
This is our representation of a user's registration for in-person testing,
|
||||
@@ -242,7 +292,8 @@ class TestCenterRegistration(models.Model):
|
||||
exam_series_code = models.CharField(max_length=15, db_index=True)
|
||||
eligibility_appointment_date_first = models.DateField(db_index=True)
|
||||
eligibility_appointment_date_last = models.DateField(db_index=True)
|
||||
# TODO: this should be an enumeration:
|
||||
|
||||
# this is really a list of codes, using an '*' as a delimiter.
|
||||
accommodation_code = models.CharField(max_length=64, blank=True)
|
||||
|
||||
# store the original text of the accommodation request.
|
||||
@@ -250,7 +301,7 @@ class TestCenterRegistration(models.Model):
|
||||
|
||||
# Confirmation
|
||||
upload_status = models.CharField(max_length=20, blank=True) # 'Error' or 'Accepted'
|
||||
uploaded_at = models.DateTimeField(null=True, db_index=True)
|
||||
uploaded_at = models.DateTimeField(null=True, blank=True, db_index=True)
|
||||
upload_error_message = models.CharField(max_length=512, blank=True)
|
||||
|
||||
@property
|
||||
|
||||
@@ -29,7 +29,7 @@ from bs4 import BeautifulSoup
|
||||
from django.core.cache import cache
|
||||
|
||||
from django_future.csrf import ensure_csrf_cookie, csrf_exempt
|
||||
from student.models import (Registration, UserProfile, TestCenterUser, TestCenterRegistration,
|
||||
from student.models import (Registration, UserProfile, TestCenterUser, TestCenterUserForm, TestCenterRegistration,
|
||||
PendingNameChange, PendingEmailChange,
|
||||
CourseEnrollment, unique_id_for_user,
|
||||
get_testcenter_registrations_for_user_and_course)
|
||||
@@ -650,29 +650,41 @@ def _do_create_or_update_test_center_user(post_vars):
|
||||
try:
|
||||
testcenter_user = TestCenterUser.objects.get(user=user)
|
||||
# found a TestCenterUser, so check to see if it has changed
|
||||
needs_updating = any([testcenter_user.__getattribute__(fieldname) != post_vars[fieldname]
|
||||
for fieldname in TestCenterUser.user_provided_fields()])
|
||||
|
||||
# needs_updating = any([testcenter_user.__getattribute__(fieldname) != post_vars[fieldname]
|
||||
# for fieldname in TestCenterUser.user_provided_fields()])
|
||||
needs_updating = testcenter_user.needs_update(post_vars)
|
||||
if needs_updating:
|
||||
# leave user and client_candidate_id as before
|
||||
testcenter_user.user_updated_at = datetime.datetime.now()
|
||||
for fieldname in TestCenterUser.user_provided_fields():
|
||||
testcenter_user.__setattr__(fieldname, post_vars[fieldname])
|
||||
# # leave user and client_candidate_id as before
|
||||
# testcenter_user.user_updated_at = datetime.datetime.now()
|
||||
# for fieldname in TestCenterUser.user_provided_fields():
|
||||
# testcenter_user.__setattr__(fieldname, post_vars[fieldname])
|
||||
testcenter_user.update(post_vars)
|
||||
needs_saving = True
|
||||
|
||||
except TestCenterUser.DoesNotExist:
|
||||
# did not find the TestCenterUser, so create a new one
|
||||
testcenter_user = TestCenterUser(user=user)
|
||||
for fieldname in TestCenterUser.user_provided_fields():
|
||||
testcenter_user.__setattr__(fieldname, post_vars[fieldname])
|
||||
# testcenter_user.candidate_id remains unset
|
||||
testcenter_user.client_candidate_id = 'edx' + '123456' # some unique value
|
||||
testcenter_user.user_updated_at = datetime.datetime.now()
|
||||
testcenter_user = TestCenterUser.create(user, post_vars)
|
||||
# testcenter_user = TestCenterUser(user=user)
|
||||
# testcenter_user.update(post_vars)
|
||||
## for fieldname in TestCenterUser.user_provided_fields():
|
||||
## testcenter_user.__setattr__(fieldname, post_vars[fieldname])
|
||||
# # testcenter_user.candidate_id remains unset
|
||||
# testcenter_user.client_candidate_id = 'edx' + '123456' # some unique value
|
||||
## testcenter_user.user_updated_at = datetime.datetime.now()
|
||||
needs_saving = True
|
||||
|
||||
# additional validation occurs at save time, so handle exceptions
|
||||
if needs_saving:
|
||||
try:
|
||||
# first perform validation on the user information
|
||||
# using a Django Form.
|
||||
form = TestCenterUserForm(testcenter_user)
|
||||
if not form.is_valid():
|
||||
response_data = {'success': False}
|
||||
# return a list of errors...
|
||||
response_data['field_errors'] = form.errors
|
||||
response_data['non_field_errors'] = form.non_field_errors()
|
||||
return HttpResponse(json.dumps(response_data))
|
||||
|
||||
testcenter_user.save()
|
||||
except IntegrityError, ie:
|
||||
js = {'success': False}
|
||||
@@ -728,7 +740,7 @@ def _do_create_or_update_test_center_user(post_vars):
|
||||
def create_test_registration(request, post_override=None):
|
||||
'''
|
||||
JSON call to create test registration.
|
||||
Used by form in test_center_register_modal.html, which is included
|
||||
Used by form in test_center_register.html, which is called from
|
||||
into dashboard.html
|
||||
'''
|
||||
js = {'success': False}
|
||||
@@ -736,24 +748,24 @@ def create_test_registration(request, post_override=None):
|
||||
post_vars = post_override if post_override else request.POST
|
||||
|
||||
# Confirm we have a properly formed request
|
||||
for a in ['first_name', 'last_name', 'address_1', 'city', 'country']:
|
||||
if a not in post_vars:
|
||||
js['value'] = "Error (401 {field}). E-mail us.".format(field=a)
|
||||
js['field'] = a
|
||||
return HttpResponse(json.dumps(js))
|
||||
|
||||
# Confirm appropriate fields are filled in with something for now
|
||||
for a in ['first_name', 'last_name', 'address_1', 'city', 'country']:
|
||||
if len(post_vars[a]) < 2:
|
||||
error_str = {'first_name': 'First name must be minimum of two characters long.',
|
||||
'last_name': 'Last name must be minimum of two characters long.',
|
||||
'address_1': 'Address must be minimum of two characters long.',
|
||||
'city': 'City must be minimum of two characters long.',
|
||||
'country': 'Country must be minimum of two characters long.',
|
||||
}
|
||||
js['value'] = error_str[a]
|
||||
js['field'] = a
|
||||
return HttpResponse(json.dumps(js))
|
||||
# for a in ['first_name', 'last_name', 'address_1', 'city', 'country']:
|
||||
# if a not in post_vars:
|
||||
# js['value'] = "Error (401 {field}). E-mail us.".format(field=a)
|
||||
# js['field'] = a
|
||||
# return HttpResponse(json.dumps(js))
|
||||
#
|
||||
# # Confirm appropriate fields are filled in with something for now
|
||||
# for a in ['first_name', 'last_name', 'address_1', 'city', 'country']:
|
||||
# if len(post_vars[a]) < 2:
|
||||
# error_str = {'first_name': 'First name must be minimum of two characters long.',
|
||||
# 'last_name': 'Last name must be minimum of two characters long.',
|
||||
# 'address_1': 'Address must be minimum of two characters long.',
|
||||
# 'city': 'City must be minimum of two characters long.',
|
||||
# 'country': 'Country must be minimum of two characters long.',
|
||||
# }
|
||||
# js['value'] = error_str[a]
|
||||
# js['field'] = a
|
||||
# return HttpResponse(json.dumps(js))
|
||||
|
||||
# Once the test_center_user information has been validated, create the entries:
|
||||
ret = _do_create_or_update_test_center_user(post_vars)
|
||||
@@ -791,6 +803,7 @@ def create_test_registration(request, post_override=None):
|
||||
js = {'success': True}
|
||||
return HttpResponse(json.dumps(js), mimetype="application/json")
|
||||
|
||||
|
||||
def get_random_post_override():
|
||||
"""
|
||||
Return a dictionary suitable for passing to post_vars of _do_create_account or post_override
|
||||
|
||||
@@ -45,6 +45,13 @@ exam_info = course.testcenter_info
|
||||
If the user has already registered in the past for a test center, then also display
|
||||
their ID. -->
|
||||
|
||||
<!-- check to see if the user has already registering, or
|
||||
is registering for the first time -->
|
||||
<%
|
||||
registrations = get_testcenter_registrations_for_user_and_course(user, course.id)
|
||||
%>
|
||||
|
||||
|
||||
<section class="output-raw">
|
||||
<hgroup>
|
||||
<p class="date-block">
|
||||
@@ -67,12 +74,6 @@ exam_info = course.testcenter_info
|
||||
<p>Last Eligible Appointment Date: ${exam_info.get('Last_Eligible_Appointment_Date')}</p>
|
||||
% endif
|
||||
|
||||
<!-- check to see if the user has already registering, or
|
||||
is registering for the first time -->
|
||||
<%
|
||||
registrations = get_testcenter_registrations_for_user_and_course(user, course.id)
|
||||
%>
|
||||
|
||||
% if len(registrations) > 0:
|
||||
<%
|
||||
registration = registrations[0]
|
||||
@@ -161,14 +162,14 @@ exam_info = course.testcenter_info
|
||||
|
||||
% if len(registrations) > 0:
|
||||
<p class="instructions">
|
||||
Please complete the following form to update your demographic information used in your Pearson VUE Porctored Exam. Required fields are noted by <strong>bold text and an asterisk (*)</strong>.
|
||||
Please complete the following form to update your demographic information used in your Pearson VUE Proctored Exam. Required fields are noted by <strong>bold text and an asterisk (*)</strong>.
|
||||
</p>
|
||||
% else:
|
||||
<p class="instructions">
|
||||
Please provide the following demographic information to register for a Pearson VUE Porctored Exam. Required fields are noted by <strong>bold text and an asterisk (*)</strong>.
|
||||
Please provide the following demographic information to register for a Pearson VUE Proctored Exam. Required fields are noted by <strong>bold text and an asterisk (*)</strong>.
|
||||
</p>
|
||||
% endif
|
||||
|
||||
|
||||
<!-- include these as pass-throughs -->
|
||||
<input id="id_email" type="hidden" name="email" maxlength="75" value="${user.email}" />
|
||||
<input id="id_username" type="hidden" name="username" maxlength="75" value="${user.username}" />
|
||||
@@ -181,24 +182,24 @@ exam_info = course.testcenter_info
|
||||
<ol class="list-input">
|
||||
<li class="field">
|
||||
<label for="salutation">Salutation</label>
|
||||
<input class="short" id="salutation" type="text" value="${testcenteruser.salutation}" placeholder="e.g. Mr., Ms., Mrs., Dr." />
|
||||
<input class="short" id="salutation" type="text" name="salutation" value="${testcenteruser.salutation}" placeholder="e.g. Mr., Ms., Mrs., Dr." />
|
||||
</li>
|
||||
<!-- NOTE: BT - to inform a user of what field the error occured on, add a class of .error to the .field element -->
|
||||
<li class="field required">
|
||||
<label for="name-first">First Name </label>
|
||||
<input id="name-first" type="text" value="${testcenteruser.first_name}" placeholder="e.g. Albert" />
|
||||
<input id="name-first" type="text" name="first_name" value="${testcenteruser.first_name}" placeholder="e.g. Albert" />
|
||||
</li>
|
||||
<li class="field">
|
||||
<label for="name-middle">Middle Name</label>
|
||||
<input id="name-middle" type="text" value="${testcenteruser.middle_name}" placeholder="" />
|
||||
<input id="name-middle" type="text" name="middle_name" value="${testcenteruser.middle_name}" placeholder="" />
|
||||
</li>
|
||||
<li class="field required">
|
||||
<label for="name-last">Last Name</label>
|
||||
<input id="name-last" type="text" value="${testcenteruser.last_name}" placeholder="e.g. Einstein" />
|
||||
<input id="name-last" type="text" name="last_name" value="${testcenteruser.last_name}" placeholder="e.g. Einstein" />
|
||||
</li>
|
||||
<li class="field">
|
||||
<label for="name-suffix">Suffix</label>
|
||||
<input class="short" id="name-suffix" type="text" value="${testcenteruser.suffix}" placeholder="e.g. Jr., Sr. " />
|
||||
<input class="short" id="name-suffix" type="text" name="suffix" value="${testcenteruser.suffix}" placeholder="e.g. Jr., Sr. " />
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
@@ -209,30 +210,34 @@ exam_info = course.testcenter_info
|
||||
<ol class="list-input">
|
||||
<li class="field">
|
||||
<label class="long" for="address-1">Address Line #1</label>
|
||||
<input id="address-1" type="text" value="${testcenteruser.address_1}" placeholder="e.g. 112 Mercer Street" />
|
||||
<input id="address-1" type="text" name="address_1" value="${testcenteruser.address_1}" placeholder="e.g. 112 Mercer Street" />
|
||||
</li>
|
||||
<li class="field-group addresses">
|
||||
<div class="field">
|
||||
<label for="address-2">Address Line #2</label>
|
||||
<input id="address-2" class="long" type="text" value="${testcenteruser.address_2}" placeholder="e.g. Apartment 123" />
|
||||
<input id="address-2" class="long" type="text" name="address_2" value="${testcenteruser.address_2}" placeholder="e.g. Apartment 123" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="address-3">Address Line #3</label>
|
||||
<input id="address-3" class="long" type="text" value="${testcenteruser.address_3}" placeholder="e.g. Attention: Albert Einstein" />
|
||||
<input id="address-3" class="long" type="text" name="address_3" value="${testcenteruser.address_3}" placeholder="e.g. Attention: Albert Einstein" />
|
||||
</div>
|
||||
</li>
|
||||
<li class="field-group postal">
|
||||
<div class="field">
|
||||
<label for="city">City</label>
|
||||
<input id="city" class="short" type="text" name="city" value="${testcenteruser.city}" placeholder="e.g. Newark" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="state">State/Province</label>
|
||||
<input id="state" class="short" type="text" value="${testcenteruser.state}" placeholder="e.g. NJ" />
|
||||
<input id="state" class="short" type="text" name="state" value="${testcenteruser.state}" placeholder="e.g. NJ" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="postal-code">Postal Code</label>
|
||||
<input id="postal-code" class="short" type="text" value="${testcenteruser.postal_code}" placeholder="e.g. 08540" />
|
||||
<input id="postal-code" class="short" type="text" name="postal_code" value="${testcenteruser.postal_code}" placeholder="e.g. 08540" />
|
||||
</div>
|
||||
<div class="field required">
|
||||
<label class="short" for="country-code">Country Code</label>
|
||||
<input id="country-code" class="short" type="text" value="${testcenteruser.country}" placeholder="e.g. USA" />
|
||||
<input id="country-code" class="short" type="text" name="country" value="${testcenteruser.country}" placeholder="e.g. USA" />
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
@@ -245,30 +250,30 @@ exam_info = course.testcenter_info
|
||||
<li class="field-group phoneinfo">
|
||||
<div class="field required">
|
||||
<label for="phone">Phone Number</label>
|
||||
<input id="phone" type="text" value="${testcenteruser.phone}" placeholder="e.g. 1-55-555-5555" />
|
||||
<input id="phone" type="text" name="phone" value="${testcenteruser.phone}" placeholder="e.g. 1-55-555-5555" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="phone-extension">Extension</label>
|
||||
<input id="phone-extension" class="short" type="text" value="${testcenteruser.extension}" placeholder="e.g. 555" />
|
||||
<input id="phone-extension" class="short" type="text" name="extension" value="${testcenteruser.extension}" placeholder="e.g. 555" />
|
||||
</div>
|
||||
<div class="field required">
|
||||
<label for="phone-countrycode">Phone Country Code</label>
|
||||
<input id="phone-countrycode" class="short" type="text" value="${testcenteruser.phone_country_code}" placeholder="e.g. USA" />
|
||||
<input id="phone-countrycode" class="short" type="text" name="phone_country_code" value="${testcenteruser.phone_country_code}" placeholder="e.g. USA" />
|
||||
</div>
|
||||
</li>
|
||||
<li class="field-group faxinfo">
|
||||
<div class="field">
|
||||
<label for="fax">Fax Number</label>
|
||||
<input id="fax" type="text" class="short" value="${testcenteruser.fax}" placeholder="e.g. 1-55-555-5555" />
|
||||
<input id="fax" type="text" class="short" name="fax" value="${testcenteruser.fax}" placeholder="e.g. 1-55-555-5555" />
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="fax-countrycode">Fax Country Code</label>
|
||||
<input id="fax-countrycode" class="short" type="text" value="${testcenteruser.fax_country_code}" placeholder="e.g. USA" />
|
||||
<input id="fax-countrycode" class="short" type="text" name="fax_country_code" value="${testcenteruser.fax_country_code}" placeholder="e.g. USA" />
|
||||
</div>
|
||||
</li>
|
||||
<li class="field">
|
||||
<label for="company">Company</label>
|
||||
<input id="company" type="text" value="${testcenteruser.company_name}" placeholder="e.g. American Association of University Professors" />
|
||||
<input id="company" type="text" name="company_name" value="${testcenteruser.company_name}" placeholder="e.g. American Association of University Professors" />
|
||||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
@@ -312,38 +317,51 @@ exam_info = course.testcenter_info
|
||||
</section>
|
||||
|
||||
<aside>
|
||||
% if len(registrations) > 0:
|
||||
<h3 class="is-hidden">Registration Details</h3>
|
||||
|
||||
<%
|
||||
regstatus = "registration pending acknowledgement by Pearson"
|
||||
registration = registrations[0]
|
||||
|
||||
if registration.upload_status == 'Accepted':
|
||||
regstatus = "Registration approved by Pearson"
|
||||
elif registration.upload_status == 'Error':
|
||||
regstatus = "Registration rejected by Pearson: %s" % registration.upload_error_message
|
||||
elif len(registration.accommodation_request) > 0 and registration.accommodation_code == '':
|
||||
regstatus = "Pending approval of accommodation request"
|
||||
regstatus = "Registration pending approval of accommodation request"
|
||||
else:
|
||||
regstatus = "Registration pending acknowledgement by Pearson"
|
||||
%>
|
||||
|
||||
<!-- NOTE: BT - state for if registration is accepted -->
|
||||
% if registration.upload_status == 'Accepted':
|
||||
<% regstatus = "Registration approved by Pearson" %>
|
||||
<div class="message message-status registration-accepted is-shown">
|
||||
<p class="registration-status"><span class="label">Registration Status: </span><span class="value">${regstatus}</span></p>
|
||||
<p class="registration-number"><span class="label">Registration number: </span> <span class="value">edx00015879548</span></p>
|
||||
<p class="message-copy">Write this down! You’ll need it to schedule your exam.</p>
|
||||
<a href="https://www1.pearsonvue.com/testtaker/signin/SignInPage/EDX" class="button exam-button">Schedule Pearson exam</a>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
% if registration.upload_status == 'Error':
|
||||
<!-- NOTE: BT - state for if registration is rejected -->
|
||||
<% regstatus = "Registration rejected by Pearson: %s" % registration.upload_error_message %>
|
||||
<div class="message message-status registration-rejected is-shown">
|
||||
<p class="registration-status"><span class="label">Registration Status: </span><span class="value">${regstatus}</span></p>
|
||||
<p class="message-copy">Your registration for the Pearson exam has been rejected. Please contact Pearson VUE for further information regarding your registration.</p>
|
||||
</div>
|
||||
% endif
|
||||
|
||||
% if len(registration.accommodation_request) > 0 and registration.accommodation_code == '':
|
||||
<% regstatus = "Registration pending approval of accommodation request" %>
|
||||
<!-- NOTE: BT - state for if registration is pending -->
|
||||
<div class="message message-status registration-pending is-shown">
|
||||
<p class="registration-status"><span class="label">Registration Status: </span><span class="value">${regstatus}</span></p>
|
||||
<p class="message-copy">Your registration for the Pearson exam is pending. Within a few days, you should see a confirmation number here, which can be used to schedule your exam.</p>
|
||||
</div>
|
||||
% endif
|
||||
% endif
|
||||
|
||||
<div class="details details-course">
|
||||
<!-- NOTE: showing course details -->
|
||||
@@ -378,4 +396,4 @@ exam_info = course.testcenter_info
|
||||
% endif
|
||||
</div>
|
||||
</aside>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user