From d8c27a18fa56b72f5e9e3f82e6c9e3ac1f7cf10c Mon Sep 17 00:00:00 2001 From: David Adams Date: Wed, 30 Oct 2013 14:48:05 -0700 Subject: [PATCH] Changes to CME registration form These changes bring the form to Nov 12 specs. --- ...how_stanford_affiliated__del_field_cmeu.py | 301 +++++++++++++ common/djangoapps/cme_registration/models.py | 226 +++++----- .../tests/registration_tests.py | 395 +++++++++--------- common/djangoapps/cme_registration/views.py | 342 +++++++++++---- lms/templates/cme_register.html | 351 ++++++++++------ 5 files changed, 1120 insertions(+), 495 deletions(-) create mode 100644 common/djangoapps/cme_registration/migrations/0002_auto__del_field_cmeuserprofile_how_stanford_affiliated__del_field_cmeu.py diff --git a/common/djangoapps/cme_registration/migrations/0002_auto__del_field_cmeuserprofile_how_stanford_affiliated__del_field_cmeu.py b/common/djangoapps/cme_registration/migrations/0002_auto__del_field_cmeuserprofile_how_stanford_affiliated__del_field_cmeu.py new file mode 100644 index 000000000000..e79ea96ae963 --- /dev/null +++ b/common/djangoapps/cme_registration/migrations/0002_auto__del_field_cmeuserprofile_how_stanford_affiliated__del_field_cmeu.py @@ -0,0 +1,301 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Deleting field 'CmeUserProfile.how_stanford_affiliated' + db.delete_column('cme_registration', 'how_stanford_affiliated') + + # Deleting field 'CmeUserProfile.profession' + db.delete_column('cme_registration', 'profession') + + # Deleting field 'CmeUserProfile.stanford_affiliated' + db.delete_column('cme_registration', 'stanford_affiliated') + + # Deleting field 'CmeUserProfile.phone_number' + db.delete_column('cme_registration', 'phone_number') + + # Deleting field 'CmeUserProfile.fax' + db.delete_column('cme_registration', 'fax') + + # Deleting field 'CmeUserProfile.hear_about_us' + db.delete_column('cme_registration', 'hear_about_us') + + # Deleting field 'CmeUserProfile.mailing_list' + db.delete_column('cme_registration', 'mailing_list') + + # Deleting field 'CmeUserProfile.state_province' + db.delete_column('cme_registration', 'state_province') + + # Deleting field 'CmeUserProfile.extension' + db.delete_column('cme_registration', 'extension') + + # Deleting field 'CmeUserProfile.organization' + db.delete_column('cme_registration', 'organization') + + # Adding field 'CmeUserProfile.first_name' + db.add_column('cme_registration', 'first_name', + self.gf('django.db.models.fields.CharField')(max_length=50, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.last_name' + db.add_column('cme_registration', 'last_name', + self.gf('django.db.models.fields.CharField')(max_length=50, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.middle_initial' + db.add_column('cme_registration', 'middle_initial', + self.gf('django.db.models.fields.CharField')(max_length=1, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.birth_date' + db.add_column('cme_registration', 'birth_date', + self.gf('django.db.models.fields.CharField')(max_length=5, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.license_country' + db.add_column('cme_registration', 'license_country', + self.gf('django.db.models.fields.CharField')(max_length=50, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.license_state' + db.add_column('cme_registration', 'license_state', + self.gf('django.db.models.fields.CharField')(max_length=50, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.physician_status' + db.add_column('cme_registration', 'physician_status', + self.gf('django.db.models.fields.CharField')(max_length=8, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.affiliation' + db.add_column('cme_registration', 'affiliation', + self.gf('django.db.models.fields.CharField')(max_length=46, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.other_affiliation' + db.add_column('cme_registration', 'other_affiliation', + self.gf('django.db.models.fields.CharField')(max_length=46, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.sub_affiliation' + db.add_column('cme_registration', 'sub_affiliation', + self.gf('django.db.models.fields.CharField')(max_length=46, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.stanford_department' + db.add_column('cme_registration', 'stanford_department', + self.gf('django.db.models.fields.CharField')(max_length=46, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.sunet_id' + db.add_column('cme_registration', 'sunet_id', + self.gf('django.db.models.fields.CharField')(max_length=33, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.state' + db.add_column('cme_registration', 'state', + self.gf('django.db.models.fields.CharField')(max_length=50, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.county_province' + db.add_column('cme_registration', 'county_province', + self.gf('django.db.models.fields.CharField')(max_length=50, null=True, blank=True), + keep_default=False) + + + # Changing field 'CmeUserProfile.license_number' + db.alter_column('cme_registration', 'license_number', self.gf('django.db.models.fields.CharField')(max_length=20, null=True)) + + # Changing field 'CmeUserProfile.professional_designation' + db.alter_column('cme_registration', 'professional_designation', self.gf('django.db.models.fields.CharField')(max_length=25, null=True)) + + def backwards(self, orm): + # Adding field 'CmeUserProfile.how_stanford_affiliated' + db.add_column('cme_registration', 'how_stanford_affiliated', + self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.profession' + db.add_column('cme_registration', 'profession', + self.gf('django.db.models.fields.CharField')(max_length=30, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.stanford_affiliated' + db.add_column('cme_registration', 'stanford_affiliated', + self.gf('django.db.models.fields.BooleanField')(default=False), + keep_default=False) + + # Adding field 'CmeUserProfile.phone_number' + db.add_column('cme_registration', 'phone_number', + self.gf('django.db.models.fields.CharField')(max_length=30, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.fax' + db.add_column('cme_registration', 'fax', + self.gf('django.db.models.fields.CharField')(max_length=30, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.hear_about_us' + db.add_column('cme_registration', 'hear_about_us', + self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.mailing_list' + db.add_column('cme_registration', 'mailing_list', + self.gf('django.db.models.fields.BooleanField')(default=False), + keep_default=False) + + # Adding field 'CmeUserProfile.state_province' + db.add_column('cme_registration', 'state_province', + self.gf('django.db.models.fields.CharField')(max_length=50, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.extension' + db.add_column('cme_registration', 'extension', + self.gf('django.db.models.fields.CharField')(max_length=10, null=True, blank=True), + keep_default=False) + + # Adding field 'CmeUserProfile.organization' + db.add_column('cme_registration', 'organization', + self.gf('django.db.models.fields.CharField')(max_length=255, null=True, blank=True), + keep_default=False) + + # Deleting field 'CmeUserProfile.first_name' + db.delete_column('cme_registration', 'first_name') + + # Deleting field 'CmeUserProfile.last_name' + db.delete_column('cme_registration', 'last_name') + + # Deleting field 'CmeUserProfile.middle_initial' + db.delete_column('cme_registration', 'middle_initial') + + # Deleting field 'CmeUserProfile.birth_date' + db.delete_column('cme_registration', 'birth_date') + + # Deleting field 'CmeUserProfile.license_country' + db.delete_column('cme_registration', 'license_country') + + # Deleting field 'CmeUserProfile.license_state' + db.delete_column('cme_registration', 'license_state') + + # Deleting field 'CmeUserProfile.physician_status' + db.delete_column('cme_registration', 'physician_status') + + # Deleting field 'CmeUserProfile.affiliation' + db.delete_column('cme_registration', 'affiliation') + + # Deleting field 'CmeUserProfile.other_affiliation' + db.delete_column('cme_registration', 'other_affiliation') + + # Deleting field 'CmeUserProfile.sub_affiliation' + db.delete_column('cme_registration', 'sub_affiliation') + + # Deleting field 'CmeUserProfile.stanford_department' + db.delete_column('cme_registration', 'stanford_department') + + # Deleting field 'CmeUserProfile.sunet_id' + db.delete_column('cme_registration', 'sunet_id') + + # Deleting field 'CmeUserProfile.state' + db.delete_column('cme_registration', 'state') + + # Deleting field 'CmeUserProfile.county_province' + db.delete_column('cme_registration', 'county_province') + + + # Changing field 'CmeUserProfile.license_number' + db.alter_column('cme_registration', 'license_number', self.gf('django.db.models.fields.CharField')(max_length=255, null=True)) + + # Changing field 'CmeUserProfile.professional_designation' + db.alter_column('cme_registration', 'professional_designation', self.gf('django.db.models.fields.CharField')(max_length=3, null=True)) + + models = { + 'auth.group': { + 'Meta': {'object_name': 'Group'}, + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}), + 'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}) + }, + 'auth.permission': { + 'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'}, + 'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}) + }, + 'auth.user': { + 'Meta': {'object_name': 'User'}, + 'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}), + 'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}), + 'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}), + 'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'}) + }, + 'cme_registration.cmeuserprofile': { + 'Meta': {'object_name': 'CmeUserProfile', 'db_table': "'cme_registration'", '_ormbases': ['student.UserProfile']}, + 'address_1': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'address_2': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'affiliation': ('django.db.models.fields.CharField', [], {'max_length': '46', 'null': 'True', 'blank': 'True'}), + 'birth_date': ('django.db.models.fields.CharField', [], {'max_length': '5', 'null': 'True', 'blank': 'True'}), + 'city': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'country': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'county_province': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'first_name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'last_name': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'license_country': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'license_number': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}), + 'license_state': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'middle_initial': ('django.db.models.fields.CharField', [], {'max_length': '1', 'null': 'True', 'blank': 'True'}), + 'other_affiliation': ('django.db.models.fields.CharField', [], {'max_length': '46', 'null': 'True', 'blank': 'True'}), + 'patient_population': ('django.db.models.fields.CharField', [], {'max_length': '25', 'null': 'True', 'blank': 'True'}), + 'physician_status': ('django.db.models.fields.CharField', [], {'max_length': '8', 'null': 'True', 'blank': 'True'}), + 'postal_code': ('django.db.models.fields.CharField', [], {'max_length': '20', 'null': 'True', 'blank': 'True'}), + 'professional_designation': ('django.db.models.fields.CharField', [], {'max_length': '25', 'null': 'True', 'blank': 'True'}), + 'specialty': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'stanford_department': ('django.db.models.fields.CharField', [], {'max_length': '46', 'null': 'True', 'blank': 'True'}), + 'state': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), + 'sub_affiliation': ('django.db.models.fields.CharField', [], {'max_length': '46', 'null': 'True', 'blank': 'True'}), + 'sub_specialty': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'sunet_id': ('django.db.models.fields.CharField', [], {'max_length': '33', 'null': 'True', 'blank': 'True'}), + 'userprofile_ptr': ('django.db.models.fields.related.OneToOneField', [], {'to': "orm['student.UserProfile']", 'unique': 'True', 'primary_key': 'True'}) + }, + 'contenttypes.contenttype': { + 'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"}, + 'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}) + }, + 'student.userprofile': { + 'Meta': {'object_name': 'UserProfile', 'db_table': "'auth_userprofile'"}, + 'allow_certificate': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), + 'courseware': ('django.db.models.fields.CharField', [], {'default': "'course.xml'", 'max_length': '255', 'blank': 'True'}), + 'gender': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '6', 'null': 'True', 'blank': 'True'}), + 'goals': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), + 'level_of_education': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '6', 'null': 'True', 'blank': 'True'}), + 'location': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), + 'mailing_address': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + 'meta': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'db_index': 'True', 'max_length': '255', 'blank': 'True'}), + 'user': ('django.db.models.fields.related.OneToOneField', [], {'related_name': "'profile'", 'unique': 'True', 'to': "orm['auth.User']"}), + 'year_of_birth': ('django.db.models.fields.IntegerField', [], {'db_index': 'True', 'null': 'True', 'blank': 'True'}) + } + } + + complete_apps = ['cme_registration'] \ No newline at end of file diff --git a/common/djangoapps/cme_registration/models.py b/common/djangoapps/cme_registration/models.py index 14ea65721b8c..5cec88056f38 100644 --- a/common/djangoapps/cme_registration/models.py +++ b/common/djangoapps/cme_registration/models.py @@ -18,103 +18,149 @@ class CmeUserProfile(UserProfile): class Meta: db_table = "cme_registration" - PROFESSION_CHOICES = (('Allied Health Professional', 'Allied Health Professional'), - ('Fellow', 'Fellow'), - ('Nurse', 'Nurse'), - ('Nurse Practioner', 'Nurse Practioner'), - ('Physician', 'Physician'), - ('Physician Assistant', 'Physician Assistant'), - ('Resident', 'Resident'), - ('Student', 'Student')) - profession = models.CharField(blank=True, null=True, max_length=30, choices=PROFESSION_CHOICES) + first_name = models.CharField(max_length=50, blank=True, null=True) + last_name = models.CharField(max_length=50, blank=True, null=True) + middle_initial = models.CharField(max_length=1, blank=True, null=True) + birth_date = models.CharField(max_length=5, blank=True, null=True) - PROFESSIONAL_DESIGNATION_CHOICES = (('MD', 'MD'), - ('DO', 'DO'), - ('PA', 'PA'), + PROFESSIONAL_DESIGNATION_CHOICES = (('DO', 'DO'), + ('MD', 'MD'), + ('MD, PhD', 'MD, PhD'), + ('MBBS', 'MBBS'), ('NP', 'NP'), - ('RN', 'RN')) - professional_designation = models.CharField(blank=True, null=True, max_length=3, choices=PROFESSIONAL_DESIGNATION_CHOICES) - license_number = models.CharField(blank=True, null=True, max_length=255) - organization = models.CharField(blank=True, null=True, max_length=255) - stanford_affiliated = models.BooleanField(default=0) + ('PA', 'PA'), + ('RN', 'RN'), + ('Other', 'Other'), + ('None', 'None')) + professional_designation = models.CharField(blank=True, null=True, max_length=25, choices=PROFESSIONAL_DESIGNATION_CHOICES) + license_number = models.CharField(max_length=20, blank=True, null=True, ) + license_country = models.CharField(max_length=50, blank=True, null=True) + license_state = models.CharField(max_length=50, blank=True, null=True) - HOW_STANFORD_AFFILIATED_CHOICES = (('Lucile Packard Children\'s Hospital at Stanford', 'Lucile Packard Children\'s Hospital at Stanford'), - ('Packard Children\'s Health Alliance (PCHA)', 'Packard Children\'s Health Alliance (PCHA)'), - ('Stanford Hospital & Clinics', 'Stanford Hospital & Clinics'), - ('Stanford University', 'Stanford University'), - ('University Healthcare Alliance (UHA)', 'University Healthcare Alliance (UHA)'), - ('Other', 'Other, please enter:')) - how_stanford_affiliated = models.CharField(blank=True, null=True, max_length=255, choices=HOW_STANFORD_AFFILIATED_CHOICES) + PHYSICIAN_STATUS_CHOICES = (('Active', 'Active'), + ('Resident', 'Resident'), + ('Fellow', 'Fellow'), + ('Retired', 'Retired')) + physician_status = models.CharField(blank=True, null=True, max_length=8) PATIENT_POPULATION_CHOICES = (('Adult', 'Adult'), ('Pediatric', 'Pediatric'), - ('Both (Adult/Pediatric)', 'Both (Adult/Pediatric)')) + ('Both', 'Both'), + ('None', 'None')) patient_population = models.CharField(blank=True, null=True, max_length=25, choices=PATIENT_POPULATION_CHOICES) specialty = models.CharField(blank=True, null=True, max_length=255) sub_specialty = models.CharField(blank=True, null=True, max_length=255) + + AFFILIATION_CHOICES = (('Lucile Packard Children\'s Hospital', 'Lucile Packard Children\'s Hospital'), + ('Packard Children\'s Health Alliance', 'Packard Children\'s Health Alliance'), + ('Stanford Hospital and Clinics', 'Stanford Hospital and Clinics'), + ('Stanford University', 'Stanford University'), + ('University Healthcare Alliance', 'University Healthcare Alliance'), + ('Other', 'Other')) + affiliation = models.CharField(blank=True, null=True, max_length=46, choices=AFFILIATION_CHOICES) + other_affiliation = models.CharField(blank=True, null=True, max_length=46) + sub_affiliation = models.CharField(blank=True, null=True, max_length=46) + + DEPARTMENT_CHOICES = (('Anesthesiology,Perioperative,Pain Medicine', 'Anesthesiology,Perioperative,Pain Medicine'), + ('Biochemistry', 'Biochemistry'), + ('Cardiothoracic Surgery', 'Cardiothoracic Surgery'), + ('Centers - School of Medicine', 'Centers - School of Medicine'), + ('Chemical and Systems Biology', 'Chemical and Systems Biology'), + ('Comparative Medicine', 'Comparative Medicine'), + ('Dermatology', 'Dermatology'), + ('Developmental Biology', 'Developmental Biology'), + ('Genetics Operations', 'Genetics Operations'), + ('Health Research and Policy', 'Health Research and Policy'), + ('Medicine', 'Medicine'), + ('Microbiology and Immunology', 'Microbiology and Immunology'), + ('Molecular and Cellular Physiology', 'Molecular and Cellular Physiology'), + ('Neurobiology', 'Neurobiology'), + ('Neurology', 'Neurology'), + ('Neurosurgery', 'Neurosurgery'), + ('Obstetrics & Gynecology', 'Obstetrics & Gynecology'), + ('Ophthalmology', 'Ophthalmology'), + ('Orthopaedic Surgery', 'Orthopaedic Surgery'), + ('Otolaryngology/Head & Neck Surgery', 'Otolaryngology/Head & Neck Surgery'), + ('Pathology', 'Pathology'), + ('Pediatrics', 'Pediatrics'), + ('Psychiatry and Behavioral Sciences', 'Psychiatry and Behavioral Sciences'), + ('Radiation Oncology', 'Radiation Oncology'), + ('Radiology', 'Radiology'), + ('School of Medicine', 'School of Medicine'), + ('SoM - Basic Science Pool', 'SoM - Basic Science Pool'), + ('SoM - Bio-X/Clark', 'SoM - Bio-X/Clark'), + ('SoM - Bioengineering', 'SoM - Bioengineering'), + ('SoM - Clinical Science Pool', 'SoM - Clinical Science Pool'), + ('SoM - Other Departments', 'SoM - Other Departments'), + ('SoM Dean\'s Office Administrative Units', 'SoM Dean\'s Office Administrative Units'), + ('SoM Non Cap Projects', 'SoM Non Cap Projects'), + ('Stanford Cancer/Stem Cell Biology', 'Stanford Cancer/Stem Cell Biology'), + ('Stanford Institutes of Medicine', 'Stanford Institutes of Medicine'), + ('Structural Biology Department', 'Structural Biology Department'), + ('Surgery', 'Surgery'), + ('Urology', 'Urology'), + ('Urology - Administration', 'Urology - Administration'), + ('Urology - Divisions', 'Urology - Divisions')) + stanford_department = models.CharField(blank=True, null=True, max_length=46, choices=DEPARTMENT_CHOICES) + sunet_id = models.CharField(blank=True, null=True, max_length=33) + address_1 = models.TextField(blank=True, null=True) address_2 = models.TextField(blank=True, null=True) city = models.TextField(blank=True, null=True) - STATE_CHOICES = (('Alabama', 'Alabama'), - ('Alaska', 'Alaska'), - ('Arizona', 'Arizona'), - ('Arkansas', 'Arkansas'), - ('California', 'California'), - ('Colorado', 'Colorado'), - ('Connecticut', 'Connecticut'), - ('Delaware', 'Deleware'), - ('District of Columbia', 'District of Columbia'), - ('Florida', 'Florida'), - ('Georgia', 'Georgia'), - ('Hawaii', 'Hawaii'), - ('Idaho', 'Idaho'), - ('Illinois', 'Indiana'), - ('Iowa', 'Iowa'), - ('Kansas', 'Kansas'), - ('Kentucky', 'Kentucky'), - ('Louisiana', 'Louisiana'), - ('Maine', 'Maine'), - ('Maryland', 'Maryland'), - ('Massachusetts', 'Massachusetts'), - ('Michigan', 'Michigan'), - ('Minnesota', 'Minnesota'), - ('Mississippi', 'Mississippi'), - ('Missouri', 'Missouri'), - ('Montana', 'Montana'), - ('Nebraska', 'Nebraska'), - ('Nevada', 'Nevada'), - ('Vermont', 'Vermont'), - ('Virginia', 'Virginia'), - ('Washington', 'Washington'), - ('West Virginia', 'West Virginia'), - ('Wisconsin', 'Wisconsin'), - ('Wyoming', 'Wyoming'), - ('American Samoa', 'American Samoa'), - ('Armed Forces America', 'Armed Forces America'), - ('Armed Forces Europe', 'Armed Forces Europe'), - ('Armed Forces Pacific', 'Armed Forces Pacific'), - ('Guam', 'Guam'), - ('Northern Mariana Islands', 'Northern, Mariana Islands'), - ('Palau', 'Palau'), - ('Puerto Rico', 'Puerto Rico'), - ('Utah', 'Utah'), - ('Virgin Island', 'Virgin Island'), - ('Alberta', 'Alberta'), - ('British Columbia', 'British Columbia'), - ('Manitoba', 'Manitoba'), - ('Nanavut', 'Nanavut'), - ('New Brunswick', 'New Brunswick'), - ('Newfoundland and Labrador', 'Newfoundland and Labrador'), - ('Northwest Territories', 'Northwest Territories'), - ('Nova Scotia', 'Nova Scotia'), - ('Ontario', 'Ontario'), - ('Prince Edward Island', 'Prince Edward Island'), - ('Quebec', 'Quebec'), - ('Saskatchewan', 'Saskatchewan'), - ('Yukon Territory', 'Yukon Territory'), - ('Other', 'Other')) + STATE_CHOICES = (('AL', 'Alabama'), + ('AK', 'Alaska'), + ('AZ', 'Arizona'), + ('AR', 'Arkansas'), + ('CA', 'California'), + ('CO', 'Colorado'), + ('CT', 'Connecticut'), + ('DE', 'Deleware'), + ('DC', 'District of Columbia'), + ('FL', 'Florida'), + ('GA', 'Georgia'), + ('HI', 'Hawaii'), + ('ID', 'Idaho'), + ('IL', 'Illinois'), + ('IN', 'Indiana'), + ('IA', 'Iowa'), + ('KS', 'Kansas'), + ('KY', 'Kentucky'), + ('LA', 'Louisiana'), + ('ME', 'Maine'), + ('MD', 'Maryland'), + ('MA', 'Massachusetts'), + ('MI', 'Michigan'), + ('MN', 'Minnesota'), + ('MS', 'Mississippi'), + ('MO', 'Missouri'), + ('MT', 'Montana'), + ('NE', 'Nebraska'), + ('NV', 'Nevada'), + ('NH', 'New Hampshire'), + ('NJ', 'New Jersey'), + ('NM', 'New Mexico'), + ('NY', 'New York'), + ('NC', 'North Carolina'), + ('ND', 'North Dakota'), + ('OH', 'Ohio'), + ('OK', 'Oklahoma'), + ('OR', 'Oregon'), + ('PA', 'Pennsylvania'), + ('RI', 'Rhode Island'), + ('SC', 'South Carolina'), + ('SD', 'South Dakota'), + ('TN', 'Tennessee'), + ('TX', 'Texas'), + ('UT', 'Utah'), + ('VT', 'Vermont'), + ('VA', 'Virginia'), + ('WA', 'Washington'), + ('WV', 'West Virginia'), + ('WI', 'Wisconsin'), + ('WY', 'Wyoming')) - state_province = models.CharField(blank=True, null=True, max_length=50, choices=STATE_CHOICES) + state = models.CharField(blank=True, null=True, max_length=50, choices=STATE_CHOICES) + county_province = models.CharField(blank=True, null=True, max_length=50) postal_code = models.CharField(blank=True, null=True, max_length=20) COUNTRY_CHOICES = (('United States', 'United States'), ('Afghanistan', 'Afghanistan'), @@ -364,13 +410,5 @@ class Meta: ('Other', 'Other')) country = models.CharField(blank=True, null=True, max_length=50, choices=COUNTRY_CHOICES) - phone_number = models.CharField(blank=True, null=True, max_length=30) - extension = models.CharField(blank=True, null=True, max_length=10) - fax = models.CharField(blank=True, null=True, max_length=30) - HEAR_ABOUT_US_CHOICES = (('Direct Mail Brochure', 'Direct Mail Brochure'), - ('Email Announcement', 'Email Announcement'), - ('SCCME Web site', 'SCCME Web site'), - ('Friend/Colleague', 'Friend/Colleague'), - ('Other', 'Other, please enter:')) - hear_about_us = models.CharField(blank=True, null=True, max_length=255) - mailing_list = models.BooleanField(default=0) + GENDER_CHOICES = (('M', 'Male'), + ('F', 'Female')) diff --git a/common/djangoapps/cme_registration/tests/registration_tests.py b/common/djangoapps/cme_registration/tests/registration_tests.py index a2f0edd0c7aa..d15bea2e045b 100644 --- a/common/djangoapps/cme_registration/tests/registration_tests.py +++ b/common/djangoapps/cme_registration/tests/registration_tests.py @@ -18,7 +18,7 @@ from student.models import Registration, UserProfile from cme_registration.models import CmeUserProfile from student.tests.factories import UserFactory -from cme_registration.views import DENIED_COUNTRIES, validate_export_controls +from cme_registration.views import DENIED_COUNTRIES, validate_export_controls, setup_sub_affiliation_field TEST_MITX_FEATURES = settings.MITX_FEATURES.copy() TEST_MITX_FEATURES['USE_CME_REGISTRATION'] = True @@ -35,35 +35,37 @@ def setUp(self): 'email': 'test@email.com', 'password': '1234', 'name': 'Chester Tester', - 'stanford_affiliated': '1', - 'how_stanford_affiliated': 'j\'st affiliat\'d', + 'first_name': 'Chester', + 'last_name': 'Tester', + 'middle_initial': 'A', + 'birth_date': '09/24', 'honor_code': 'true', 'terms_of_service': 'true', - 'profession': 'profession', 'professional_designation': 'professional_designation', 'license_number': 'license_number', - 'organization': 'organization', + 'license_country': 'license_country', + 'license_state': 'license_state', + 'physician_status': 'physician_status', 'patient_population': 'patient_population', 'specialty': 'specialty', 'sub_specialty': 'sub_specialty', + 'affiliation': 'affiliation', + 'other_affiliation': 'other_affiliation', + 'sub_affiliation': 'sub_affiliation', + 'sunet_id': 'sunet_id', + 'stanford_department': 'stanford_department', 'address_1': 'address_1', 'address_2': 'address_2', 'city': 'city', - 'state_province': 'state_province', + 'state': 'state', 'postal_code': 'postal_code', 'country': 'country', - 'phone_number': 'phone_number', - 'extension': 'extension', - 'fax': 'fax', - 'hear_about_us': 'hear_about_us', - 'mailing_list': 'false'} + 'county_province': 'county_province', + } @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_badly_formed_message(self): - """ - Post itself is badly formed - """ url = reverse('create_account') response = self.client.post(url, {}) @@ -71,274 +73,298 @@ def test_badly_formed_message(self): @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_profession_required(self): - """ - Profession required field - """ + def test_last_name_required(self): - self.post_vars['profession'] = '' + self.post_vars['last_name'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "profession", "value": "Choose your profession.", "success": false}') + self.assertContains(response, '{"field": "last_name", "value": "Enter your last name", "success": false}') + + @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), + dedent("""Skipping Test because the url is not in CMS""")) + def test_first_name_required(self): + + self.post_vars['first_name'] = '' + url = reverse('create_account') + response = self.client.post(url, self.post_vars) + + self.assertContains(response, '{"field": "first_name", "value": "Enter your first name", "success": false}') + + @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), + dedent("""Skipping Test because the url is not in CMS""")) + def test_middle_initial_length(self): + + self.post_vars['middle_initial'] = 'ABC' + url = reverse('create_account') + response = self.client.post(url, self.post_vars) + + self.assertContains(response, '{"field": "middle_initial", "value": "Enter your middle initial as a single character", "success": false}') + + @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), + dedent("""Skipping Test because the url is not in CMS""")) + def test_birth_date_required(self): + + self.post_vars['birth_date'] = '' + url = reverse('create_account') + response = self.client.post(url, self.post_vars) + + self.assertContains(response, '{"field": "birth_date", "value": "Enter your birth date", "success": false}') + + @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), + dedent("""Skipping Test because the url is not in CMS""")) + def test_birth_date_format1(self): + + self.post_vars['birth_date'] = '0102' + url = reverse('create_account') + response = self.client.post(url, self.post_vars) + + self.assertContains(response, '{"field": "birth_date", "value": "Enter your birth date as MM/DD", "success": false}') + + @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), + dedent("""Skipping Test because the url is not in CMS""")) + def test_birth_date_format2(self): + + self.post_vars['birth_date'] = '14/02' + url = reverse('create_account') + response = self.client.post(url, self.post_vars) + + self.assertContains(response, '{"field": "birth_date", "value": "month must be in 1..12", "success": false}') + + @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), + dedent("""Skipping Test because the url is not in CMS""")) + def test_professional_designation_required(self): + + self.post_vars['professional_designation'] = '' + url = reverse('create_account') + response = self.client.post(url, self.post_vars) + + self.assertContains(response, '{"field": "professional_designation", "value": "Choose your professional designation", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_license_number_required(self): - """ - License number required field - """ + self.post_vars['professional_designation'] = 'DO' self.post_vars['license_number'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "license_number", "value": "Enter your license number.", "success": false}') + self.assertContains(response, '{"field": "license_number", "value": "Enter your license number", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_patient_population_required(self): - """ - Patient population required field - """ + def test_license_country_required(self): - self.post_vars['patient_population'] = '' + self.post_vars['professional_designation'] = 'DO' + self.post_vars['license_country'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "patient_population", "value": "Choose your patient population", "success": false}') + self.assertContains(response, '{"field": "license_country", "value": "Choose your license country", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_specialty_required(self): - """ - Specialty required field - """ + def test_license_state_required(self): - self.post_vars['specialty'] = '' + self.post_vars['license_country'] = 'United States' + self.post_vars['license_state'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "specialty", "value": "Choose your specialty", "success": false}') + self.assertContains(response, '{"field": "license_state", "value": "Choose your license state", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_sub_specialty_not_required(self): - """ - Sub specialty not required - """ + def test_physician_status_required(self): - self.post_vars['sub_specialty'] = '' + self.post_vars['professional_designation'] = 'DO' + self.post_vars['physician_status'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '"success": true') + self.assertContains(response, '{"field": "physician_status", "value": "Enter your physician status", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_address_1_required(self): - """ - Address 1 required field - """ + def test_patient_population_required(self): - self.post_vars['address_1'] = '' + self.post_vars['professional_designation'] = 'DO' + self.post_vars['patient_population'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "address_1", "value": "Enter your Address 01", "success": false}') + self.assertContains(response, '{"field": "patient_population", "value": "Choose your patient population", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_city_required(self): - """ - City required field - """ + def test_specialty_required(self): - self.post_vars['city'] = '' + self.post_vars['professional_designation'] = 'DO' + self.post_vars['specialty'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "city", "value": "Enter your city", "success": false}') + self.assertContains(response, '{"field": "specialty", "value": "Choose your specialty", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_state_province_required(self): - """ - State Province required field - """ + def test_sub_specialty_not_required(self): - self.post_vars['state_province'] = '' + self.post_vars['sub_specialty'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "state_province", "value": "Choose your state/Province", "success": false}') + self.assertContains(response, '"success": true') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_postal_code_required(self): - """ - Postal Code required field - """ + def test_sub_affiliation_field(self): - self.post_vars['postal_code'] = '' + self.post_vars['affiliation'] = 'Packard Children\'s Health Alliance' + self.post_vars['PCHA_affiliation'] = 'Dummy_Value1' + + return_vars = setup_sub_affiliation_field(self.post_vars) + self.assertEquals(return_vars['sub_affiliation'], 'Dummy_Value1') + + self.post_vars['affiliation'] = 'University Healthcare Alliance' + self.post_vars['UHA_affiliation'] = 'Dummy_Value2' + + return_vars = setup_sub_affiliation_field(self.post_vars) + self.assertEquals(return_vars['sub_affiliation'], 'Dummy_Value2') + + self.post_vars['affiliation'] = 'Lucile Packard Children\'s Hospital' + self.post_vars['PCHA_affiliation'] = 'Dummy_Value1' + self.post_vars['UHA_affiliation'] = 'Dummy_Value2' + + return_vars = setup_sub_affiliation_field(self.post_vars) + self.assertEquals(return_vars['sub_affiliation'], '') + + self.post_vars['affiliation'] = 'Packard Children\'s Health Alliance' + self.post_vars['PCHA_affiliation'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "postal_code", "value": "Enter your postal code", "success": false}') + self.assertContains(response, '{"field": "sub_affiliation", "value": "Enter your Packard Children\'s Health Alliance affiliation", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_country_required(self): - """ - Country required field - """ + def test_sunet_id_required(self): - self.post_vars['country'] = '' + self.post_vars['affiliation'] = 'Stanford University' + self.post_vars['sunet_id'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "country", "value": "Choose your country", "success": false}') + self.assertContains(response, '{"field": "sunet_id", "value": "Enter your SUNet ID", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_phone_number_required(self): - """ - Phone number required field - """ + def test_stanford_department_required(self): - self.post_vars['phone_number'] = '' + self.post_vars['affiliation'] = 'Stanford University' + self.post_vars['stanford_department'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "phone_number", "value": "Enter your phone number", "success": false}') + self.assertContains(response, '{"field": "stanford_department", "value": "Choose your Stanford department", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_hear_about_us_required(self): - """ - Hear about us required field - """ + def test_address_1_required(self): - self.post_vars['hear_about_us'] = '' + self.post_vars['address_1'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "hear_about_us", "value": "Choose how you heard about us", "success": false}') + self.assertContains(response, '{"field": "address_1", "value": "Enter your Address 1", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_specialty_other(self): - """ - Specialty "other" required field - """ + def test_city_required(self): - self.post_vars['specialty'] = 'Other' - self.post_vars['specialty_free'] = '' + self.post_vars['city'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "specialty", "value": "Enter your specialty.", "success": false}') + self.assertContains(response, '{"field": "city", "value": "Enter your city", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_sub_specialty_other(self): - """ - Sub specialty "other" required field - """ + def test_country_required(self): - self.post_vars['sub_specialty'] = 'Other' - self.post_vars['sub_specialty_free'] = '' + self.post_vars['country'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "sub_specialty", "value": "Enter your sub-specialty.", "success": false}') + self.assertContains(response, '{"field": "country", "value": "Choose your country", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_hear_about_us_other(self): - """ - Hear about us "other" required field - """ + def test_state_required(self): - self.post_vars['hear_about_us'] = 'Other' - self.post_vars['hear_about_us_free'] = '' + self.post_vars['country'] = 'United States' + self.post_vars['state'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "hear_about_us", "value": "Enter how you heard about us.", "success": false}') + self.assertContains(response, '{"field": "state", "value": "Choose your state", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_stanford_affiliated_required(self): - """ - Stanford affiliated required field - """ + def test_postal_code_required(self): - del self.post_vars['stanford_affiliated'] + self.post_vars['postal_code'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "stanford_affiliated", "value": "Select whether, or not, you are affiliated with Stanford.", "success": false}') + self.assertContains(response, '{"field": "postal_code", "value": "Enter your postal code", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_honor_code_required(self): - """ - Honor code required field - """ + def test_specialty_other(self): - del self.post_vars['honor_code'] + self.post_vars['specialty'] = 'Other' + self.post_vars['specialty_free'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "honor_code", "value": "To enroll, you must follow the honor code.", "success": false}') + self.assertContains(response, '{"field": "specialty", "value": "Enter your specialty.", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_tos_required(self): - """ - TOS required field - """ + def test_sub_specialty_other(self): - del self.post_vars['terms_of_service'] + self.post_vars['sub_specialty'] = 'Other' + self.post_vars['sub_specialty_free'] = '' url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "terms_of_service", "value": "You must accept the terms of service.", "success": false}') + self.assertContains(response, '{"field": "sub_specialty", "value": "Enter your sub-specialty.", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_stanford_affiliated_choose(self): - """ - How Stanford affiliated required if stanford affiliated - """ + def test_honor_code_required(self): - self.post_vars['how_stanford_affiliated'] = '' + del self.post_vars['honor_code'] url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "stanford_affiliated", "value": "Choose how you are affiliated with Stanford.", "success": false}') + self.assertContains(response, '{"field": "honor_code", "value": "To enroll, you must follow the honor code.", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) - def test_stanford_affiliated_other(self): - """ - Stanford affiliated "other" required field - """ + def test_tos_required(self): - self.post_vars['how_stanford_affiliated'] = 'Other' - self.post_vars['how_stanford_affiliated_free'] = '' + del self.post_vars['terms_of_service'] url = reverse('create_account') response = self.client.post(url, self.post_vars) - self.assertContains(response, '{"field": "how_stanford_affiliated", "value": "Enter how you are affiliated with Stanford.", "success": false}') + self.assertContains(response, '{"field": "terms_of_service", "value": "You must accept the terms of service.", "success": false}') @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_db_records_created(self): - """ - Everything gets created correctly when all input data good - """ url = reverse('create_account') response = self.client.post(url, self.post_vars) @@ -357,26 +383,31 @@ def test_db_records_created(self): #Check cme_user_profile was created cme_user_profile = CmeUserProfile.objects.filter(user=user[0], name='Chester Tester', - stanford_affiliated=True, - how_stanford_affiliated='j\'st affiliat\'d', - profession='profession', + first_name='Chester', + last_name='Tester', + middle_initial='A', + birth_date='09/24', professional_designation='professional_designation', license_number='license_number', - organization='organization', + license_country='license_country', + license_state='license_state', + physician_status='physician_status', patient_population='patient_population', specialty='specialty', sub_specialty='sub_specialty', + affiliation='affiliation', + sub_affiliation='', + sunet_id='sunet_id', + stanford_department='stanford_department', address_1='address_1', address_2='address_2', city='city', - state_province='state_province', + state='state', postal_code='postal_code', country='country', - phone_number='phone_number', - extension='extension', - fax='fax', - hear_about_us='hear_about_us', - mailing_list=False) + county_province='county_province' + ) + self.assertEqual(1, len(cme_user_profile)) #Check user_profile was created @@ -386,18 +417,15 @@ def test_db_records_created(self): @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_db_records_with_others_created(self): - """ - Everything gets created correctly when all input data good with "others" - """ - self.post_vars['how_stanford_affiliated'] = 'Other' - self.post_vars['how_stanford_affiliated_free'] = 'Wife of the provost' self.post_vars['specialty'] = 'Other' self.post_vars['specialty_free'] = 'Patient care' self.post_vars['sub_specialty'] = 'Other' self.post_vars['sub_specialty_free'] = 'Legs and feet' - self.post_vars['hear_about_us'] = 'Other' - self.post_vars['hear_about_us_free'] = 'Through the grapevine' + self.post_vars['affiliation'] = 'Other' + self.post_vars['other_affiliation'] = 'other_affiliation' + self.post_vars['sub_affiliation'] = '' + url = reverse('create_account') response = self.client.post(url, self.post_vars) @@ -415,20 +443,31 @@ def test_db_records_with_others_created(self): #Check cme_user_profile was created cme_user_profile = CmeUserProfile.objects.filter(user=user[0], name='Chester Tester', - stanford_affiliated=True, - how_stanford_affiliated='Wife of the provost', - profession='profession', + first_name='Chester', + last_name='Tester', + middle_initial='A', + birth_date='09/24', + professional_designation='professional_designation', license_number='license_number', + license_country='license_country', + license_state='license_state', + physician_status='physician_status', patient_population='patient_population', - specialty='Patient care', - sub_specialty='Legs and feet', + affiliation='Other', + other_affiliation='other_affiliation', + sub_affiliation='', + sunet_id='sunet_id', + stanford_department='stanford_department', address_1='address_1', + address_2='address_2', city='city', - state_province='state_province', + state='state', postal_code='postal_code', country='country', - phone_number='phone_number', - hear_about_us='Through the grapevine') + county_province='county_province', + specialty='Patient care', + sub_specialty='Legs and feet', + ) self.assertEqual(1, len(cme_user_profile)) #Check user_profile was created @@ -438,9 +477,6 @@ def test_db_records_with_others_created(self): @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_valid_email(self): - """ - Email address conforms - """ self.post_vars['email'] = 'garbage_email_string' url = reverse('create_account') @@ -451,9 +487,6 @@ def test_valid_email(self): @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_valid_username(self): - """ - Username conforms - """ self.post_vars['username'] = ' $%$%$# ' url = reverse('create_account') @@ -464,9 +497,6 @@ def test_valid_username(self): @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_dupe_username(self): - """ - Username not already existing - """ UserFactory.create(username="student001", email="student001@test.com") @@ -479,9 +509,6 @@ def test_dupe_username(self): @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_register_when_logged_in(self): - """ - Must be logged out to register - """ user = UserFactory.create(username="student002", email="student002@test.com") self.client.login(username=user.username, password='test') @@ -493,9 +520,6 @@ def test_register_when_logged_in(self): @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_register_page_loads(self): - """ - CME Register page itself renders - """ url = reverse('register_user') response = self.client.post(url, {}) @@ -504,9 +528,6 @@ def test_register_page_loads(self): @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_reroute_activation_email(self): - """ - Registration successful with reroute activation email true - """ settings.MITX_FEATURES['REROUTE_ACTIVATION_EMAIL'] = 'a@b.edu' @@ -520,9 +541,6 @@ def test_reroute_activation_email(self): @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_save_profile_exception(self): - """ - Profile doesn't get created on exception - """ url = reverse('create_account') self.client.post(url, self.post_vars) @@ -534,9 +552,6 @@ def test_save_profile_exception(self): @unittest.skipIf(settings.MITX_FEATURES.get('DISABLE_CME_REGISTRATION_TESTS', False), dedent("""Skipping Test because the url is not in CMS""")) def test_activation_email_exception(self): - """ - Exception if activation email not sent - """ url = reverse('create_account') response = self.client.post(url, self.post_vars) @@ -545,9 +560,7 @@ def test_activation_email_exception(self): self.assertContains(response, 'Could not send activation e-mail.') def test_export_controls(self): - """ - Test export controls verification - """ + for country in DENIED_COUNTRIES: retv = validate_export_controls({'country': country}) self.assertFalse(retv['success']) diff --git a/common/djangoapps/cme_registration/views.py b/common/djangoapps/cme_registration/views.py index d9e54e5a679a..e118df90bd99 100644 --- a/common/djangoapps/cme_registration/views.py +++ b/common/djangoapps/cme_registration/views.py @@ -5,6 +5,7 @@ import json import logging from dogapi import dog_stats_api +import datetime from django_future.csrf import ensure_csrf_cookie from django.conf import settings @@ -22,7 +23,6 @@ from cme_registration.models import CmeUserProfile from mitxmako.shortcuts import render_to_response, render_to_string - log = logging.getLogger("mitx.student") @@ -40,7 +40,8 @@ def cme_register_user(request, extra_context=None): 'enrollment_action': request.GET.get('enrollment_action'), 'patient_population_choices': PATIENT_POPULATION_CHOICES, 'specialty_choices': SPECIALTY_CHOICES, - 'sub_specialty_choices': SUB_SPECIALTY_CHOICES + 'sub_specialty_choices': SUB_SPECIALTY_CHOICES, + 'sub_affiliation_choices': SUB_AFFILIATION_CHOICES, } if extra_context is not None: context.update(extra_context) @@ -56,7 +57,7 @@ def cme_create_account(request, post_override=None): ''' json_string = {'success': False} - post_vars = post_override if post_override else request.POST + post_vars = post_override if post_override else request.POST.copy() # Confirm we have a properly formed request for var in ['username', 'email', 'password', 'name']: @@ -65,27 +66,56 @@ def cme_create_account(request, post_override=None): json_string['field'] = var return HttpResponse(json.dumps(json_string)) - #Validate required felds - error = validate_required_fields(post_vars) + # Validate required fields set1 + error = validate_required_fields_set1(post_vars) if error is not None: return HttpResponse(json.dumps(error)) - #Validate required check boxes - error = validate_required_boxes(post_vars) + # Validate length of middle initial + error = validate_middle_initial_length(post_vars) + if error is not None: + return HttpResponse(json.dumps(error)) + + # Validate birth date + error = validate_birth_date_format(post_vars) + if error is not None: + return HttpResponse(json.dumps(error)) + + # Validate fields dependent on Professional Designation + error = validate_professional_fields(post_vars) if error is not None: return HttpResponse(json.dumps(error)) - #Validate required radio buttons - error = validate_required_radios(post_vars) + # Setup post_vars for correct sub_affiliation field + post_vars = setup_sub_affiliation_field(post_vars) + + # Validate affiliation fields + error = validate_affiliation_fields(post_vars) if error is not None: return HttpResponse(json.dumps(error)) - #Validate required secondary fields + # Validate required fields set2 + error = validate_required_fields_set2(post_vars) + if error is not None: + return HttpResponse(json.dumps(error)) + + # Validate required check boxes + error = validate_required_boxes(post_vars) + if error is not None: + return HttpResponse(json.dumps(error)) + + # Validate required radio buttons + # Commented out while no radios exist +# error = validate_required_radios(post_vars) +# if error is not None: +# return HttpResponse(json.dumps(error)) + + # Validate required secondary fields error = validate_required_secondaries(post_vars) if error is not None: return HttpResponse(json.dumps(error)) - #Validate email address + # Validate email address try: validate_email(post_vars['email']) except ValidationError: @@ -93,7 +123,7 @@ def cme_create_account(request, post_override=None): json_string['field'] = 'email' return HttpResponse(json.dumps(json_string)) - #Validate username conforms + # Validate username conforms try: validate_slug(post_vars['username']) except ValidationError: @@ -101,7 +131,7 @@ def cme_create_account(request, post_override=None): json_string['field'] = 'username' return HttpResponse(json.dumps(json_string)) - #Validate Export controls + # Validate Export controls error = validate_export_controls(post_vars) if error is not None: return HttpResponse(json.dumps(error)) @@ -163,6 +193,7 @@ def _do_cme_create_account(post_vars): Since CmeUserProfile is implemented using multi-table inheritence of UserProfile, the CmeUserProfile object will also contain all the UserProfile fields. """ + user = User(username=post_vars['username'], email=post_vars['email'], is_active=False) @@ -191,19 +222,18 @@ def _do_cme_create_account(post_vars): #UserProfile fields cme_user_profile.name = post_vars['name'] + cme_user_profile.gender = post_vars.get('gender') #CmeUserProfile fields - cme_user_profile.profession = post_vars.get('profession') + cme_user_profile.last_name = post_vars['last_name'] + cme_user_profile.first_name = post_vars['first_name'] + cme_user_profile.middle_initial = post_vars.get('middle_initial') + cme_user_profile.birth_date = post_vars['birth_date'] cme_user_profile.professional_designation = post_vars.get('professional_designation') cme_user_profile.license_number = post_vars.get('license_number') - cme_user_profile.organization = post_vars.get('organization') - cme_user_profile.stanford_affiliated = True if post_vars.get('stanford_affiliated') == '1' else False - - if post_vars.get('how_stanford_affiliated') == 'Other': - cme_user_profile.how_stanford_affiliated = post_vars.get('how_stanford_affiliated_free') - else: - cme_user_profile.how_stanford_affiliated = post_vars.get('how_stanford_affiliated') - + cme_user_profile.license_country = post_vars.get('license_country') + cme_user_profile.license_state = post_vars.get('license_state') + cme_user_profile.physician_status = post_vars.get('physician_status') cme_user_profile.patient_population = post_vars.get('patient_population') if post_vars.get('specialty') == 'Other': @@ -216,32 +246,34 @@ def _do_cme_create_account(post_vars): else: cme_user_profile.sub_specialty = post_vars.get('sub_specialty') + cme_user_profile.affiliation = post_vars.get('affiliation') + + if post_vars.get('affiliation') == 'Other': + cme_user_profile.other_affiliation = post_vars.get('other_affiliation') + else: + cme_user_profile.other_affiliation = None + + cme_user_profile.sub_affiliation = post_vars.get('sub_affiliation') + cme_user_profile.sunet_id = post_vars.get('sunet_id') + cme_user_profile.stanford_department = post_vars.get('stanford_department') cme_user_profile.address_1 = post_vars.get('address_1') cme_user_profile.address_2 = post_vars.get('address_2') cme_user_profile.city = post_vars.get('city') - cme_user_profile.state_province = post_vars.get('state_province') + cme_user_profile.state = post_vars.get('state') + cme_user_profile.county_province = post_vars.get('county_province') cme_user_profile.postal_code = post_vars.get('postal_code') cme_user_profile.country = post_vars.get('country') - cme_user_profile.phone_number = post_vars.get('phone_number') - cme_user_profile.extension = post_vars.get('extension') - cme_user_profile.fax = post_vars.get('fax') - - if post_vars.get('hear_about_us') == 'Other': - cme_user_profile.hear_about_us = post_vars.get('hear_about_us_free') - else: - cme_user_profile.hear_about_us = post_vars.get('hear_about_us') - - cme_user_profile.mailing_list = 1 if post_vars.get('mailing_list') == 'true' else 0 try: cme_user_profile.save() except Exception: + print "Could not create cme_user_profile" log.exception("UserProfile creation failed for user {0}.".format(user.email)) return (user, cme_user_profile, registration) -def validate_required_fields(post_vars): +def validate_required_fields_set1(post_vars): """ Checks that required free text fields contain at least 2 chars `post_vars` is dict of post parameters (a `dict`) @@ -252,29 +284,174 @@ def validate_required_fields(post_vars): required_fields_list = [{'email': 'A properly formatted e-mail is required.'}, {'password': 'A valid password is required.'}, {'username': 'Username must be minimum of two characters long.'}, - {'name': 'Your legal name must be a minimum of two characters long.'}, - {'profession': 'Choose your profession.'}, - {'license_number': 'Enter your license number.'}, + {'name': 'Your full name must be a minimum of two characters long.'}, + {'last_name': 'Enter your last name'}, + {'first_name': 'Enter your first name'}, + {'birth_date': 'Enter your birth date'}, + {'professional_designation': 'Choose your professional designation'}, + ] + + error = {} + for required_field in required_fields_list: + for key, val in required_field.iteritems(): + if len(post_vars.get(key)) < 2: + error['success'] = False + error['value'] = val + error['field'] = key + return error + + +def validate_middle_initial_length(post_vars): + """ + Checks length of middle initial + """ + + if len(post_vars.get('middle_initial')) > 1: + error = {} + error['success'] = False + error['value'] = 'Enter your middle initial as a single character' + error['field'] = 'middle_initial' + return error + + +def validate_birth_date_format(post_vars): + """ + Checks date is in format 'MM/DD' + """ + + birth_date = post_vars.get('birth_date') + date_parts = birth_date.split('/') + + error = {} + if len(date_parts) < 2: + error['success'] = False + error['value'] = 'Enter your birth date as MM/DD' + error['field'] = 'birth_date' + return error + + dummy_year = 2013 + try: + dateobj = datetime.date(dummy_year, int(date_parts[0]), int(date_parts[1])) + except ValueError, e: + error['success'] = False + error['value'] = str(e) + error['field'] = 'birth_date' + return error + + +def validate_professional_fields(post_vars): + """ + Checks that professional fields are filled out correctly + `post_vars` is dict of post parameters (a `dict`) + Returns a dict indicating failure, field and message on empty field else None + """ + + required_fields_list = [{'license_number': 'Enter your license number'}, + {'license_country': 'Choose your license country'}, + {'physician_status': 'Enter your physician status'}, {'patient_population': 'Choose your patient population'}, {'specialty': 'Choose your specialty'}, - {'address_1': 'Enter your Address 01'}, + ] + + error = {} + if post_vars.get('professional_designation') in ['DO', 'MD', 'MD, PhD', 'MBBS']: + for required_field in required_fields_list: + for key, val in required_field.iteritems(): + if len(post_vars.get(key)) < 2: + error['success'] = False + error['value'] = val + error['field'] = key + return error + + # license_state is required if license_country = United States + if post_vars.get('license_country') == 'United States': + if len(post_vars.get('license_state')) < 2: + error['success'] = False + error['value'] = 'Choose your license state' + error['field'] = 'license_state' + return error + + +def setup_sub_affiliation_field(post_vars): + """ + Sets post_vars['sub_affiliation'] to correct value dependent upon affiliation dropdown + """ + + affiliation_values = [{'Packard Children\'s Health Alliance': 'PCHA_affiliation'}, + {'University Healthcare Alliance': 'UHA_affiliation'}, + ] + + post_vars['sub_affiliation'] = '' + for affiliation_value in affiliation_values: + for key, val in affiliation_value.iteritems(): + if post_vars.get('affiliation') == key: + post_vars['sub_affiliation'] = post_vars.get(val) + + return post_vars + + +def validate_affiliation_fields(post_vars): + """ + Checks affiliation fields + """ + + error = {} + affiliation_fields_list = [{'Packard Children\'s Health Alliance': 'Enter your Packard Children\'s Health Alliance affiliation'}, + {'University Healthcare Alliance': 'Enter your University Healthcare Alliance affiliation'}, + ] + + for affiliation_field in affiliation_fields_list: + for key, val in affiliation_field.iteritems(): + if post_vars.get('affiliation') == key and len(post_vars.get('sub_affiliation')) < 2: + error['success'] = False + error['value'] = val + error['field'] = 'sub_affiliation' + return error + + required_fields_list = [{'sunet_id': 'Enter your SUNet ID'}, + {'stanford_department': 'Choose your Stanford department'}, + ] + + if post_vars.get('affiliation') == 'Stanford University': + for required_field in required_fields_list: + for key, val in required_field.iteritems(): + if len(post_vars.get(key)) < 2: + error['success'] = False + error['value'] = val + error['field'] = key + return error + + +def validate_required_fields_set2(post_vars): + """ + Checks that required free text fields contain at least 2 chars + `post_vars` is dict of post parameters (a `dict`) + Returns a dict indicating failure, field and message on empty field else None + """ + + #Add additional required fields here + required_fields_list = [{'address_1': 'Enter your Address 1'}, {'city': 'Enter your city'}, - {'state_province': 'Choose your state/Province'}, - {'postal_code': 'Enter your postal code'}, {'country': 'Choose your country'}, - {'phone_number': 'Enter your phone number'}, - {'hear_about_us': 'Choose how you heard about us'} - ] + {'postal_code': 'Enter your postal code'}, + ] error = {} for required_field in required_fields_list: - for key, val in required_field.iteritems(): + for key, val in required_field.iteritems(): if len(post_vars.get(key)) < 2: error['success'] = False error['value'] = val error['field'] = key return error + if post_vars.get('country') == 'United States': + if len(post_vars.get('state')) < 2: + error['success'] = False + error['value'] = 'Choose your state' + error['field'] = 'state' + return error + def validate_required_boxes(post_vars): """ @@ -307,11 +484,8 @@ def validate_required_secondaries(post_vars): """ #Add additional required secondaries here - required_secondaries_dict = {'stanford_affiliated': ('1', 'how_stanford_affiliated', 'Choose how you are affiliated with Stanford.'), - 'how_stanford_affiliated': ('Other', 'how_stanford_affiliated_free', 'Enter how you are affiliated with Stanford.'), - 'specialty': ('Other', 'specialty_free', 'Enter your specialty.'), + required_secondaries_dict = {'specialty': ('Other', 'specialty_free', 'Enter your specialty.'), 'sub_specialty': ('Other', 'sub_specialty_free', 'Enter your sub-specialty.'), - 'hear_about_us': ('Other', 'hear_about_us_free', 'Enter how you heard about us.') } error = {} @@ -322,25 +496,25 @@ def validate_required_secondaries(post_vars): error['field'] = k return error - -def validate_required_radios(post_vars): - """ - Checks that required radio buttons have been checked - `post_vars is dict of post parameters (a `dict) - Returns a dict indicating failure, field and message on empty field else None - """ - - #Add additional required radios here - required_radios_dict = {'stanford_affiliated': 'Select whether, or not, you are affiliated with Stanford.' - } - - error = {} - for k, val in required_radios_dict.items(): - if k not in post_vars: - error['success'] = False - error['value'] = val - error['field'] = k - return error +# Commented out while no radios exist +# def validate_required_radios(post_vars): +# """ +# Checks that required radio buttons have been checked +# `post_vars is dict of post parameters (a `dict) +# Returns a dict indicating failure, field and message on empty field else None +# """ +# +# #Add additional required radios here +# required_radios_dict = { +# } +# +# error = {} +# for k, val in required_radios_dict.items(): +# if k not in post_vars: +# error['success'] = False +# error['value'] = val +# error['field'] = k +# return error def validate_export_controls(post_vars): @@ -357,21 +531,22 @@ def validate_export_controls(post_vars): } -DENIED_COUNTRIES = [ - 'Sudan', - 'Korea, Democratic People\'s Republic Of', - 'Iran, Islamic Republic Of', - 'Cuba', - 'Syrian Arab Republic', - ] +DENIED_COUNTRIES = ['Sudan', + 'Korea, Democratic People\'s Republic Of', + 'Iran, Islamic Republic Of', + 'Cuba', + 'Syrian Arab Republic', + ] -#Construct dicts for specialty and sub-specialty dropdowns +#Construct dicts for specialty, sub-specialty, sub-affiliation dropdowns SPECIALTY_CHOICES = {} SUB_SPECIALTY_CHOICES = {} +SUB_AFFILIATION_CHOICES = {} PATIENT_POPULATION_CHOICES = (('Adult', 'Adult'), ('Pediatric', 'Pediatric'), - ('Both', 'Both (Adult/Pediatric)')) + ('Both', 'Both'), + ('None', 'None')) SPECIALTY_CHOICES['Adult'] = (('Addiction_Medicine', 'Addiction Medicine'), ('Allergy', 'Allergy'), ('Anesthesiology', 'Anesthesiology'), @@ -604,3 +779,18 @@ def validate_export_controls(post_vars): SUB_SPECIALTY_CHOICES['Transplant'] = (('Solid_Organ', 'Solid Organ'), ('Blood_and_Bone_Marrow', 'Blood and Bone Marrow'), ('Other', 'Other, please enter:')) + +SUB_AFFILIATION_CHOICES['Packard_Childrens_Health_Alliance'] = (('Bayside_Medical_Group', 'Bayside Medical Group'), + ('Diablo_Valley_Child_Neurology', 'Diablo Valley Child Neurology'), + ('Jagdip_Powar_Associates', 'Jagdip Powar, MD and Associates'), + ('Judy_Fuentebella_Associates', 'Judy Fuentebella, MD and Associates'), + ('Livermore_Pleasanton_San_Ramon_Pediatrics_Group', 'Livermore Pleasanton San Ramon Pediatrics Group'), + ('Pediatric_Cardiology_Medical_Group', 'Pediatric Cardiology Medical Group'), + ('Pediatric_Cardiology_Associates', 'Pediatric Cardiology Associates'), + ('Peninsula_Pediatrics', 'Peninsula Pediatrics'), + ('Sabina_Ali_Associates', 'Sabina Ali, MD and Associates')) + +SUB_AFFILIATION_CHOICES['University_Healthcare_Alliance'] = (('Affinity_Medical_Partners_Medical_Group', 'Affinity Medical Partners Medical Group (AMP)'), + ('Bay_Valley_Medical_Group', 'Bay Valley Medical Group (BVMG)'), + ('Cardiovascular_Consultants_Medical_Group', 'Cardiovascular Consultants Medical Group (CCMG)'), + ('Menlo_Medical_Clinic', 'Menlo Medical Clinic (MMC)')) diff --git a/lms/templates/cme_register.html b/lms/templates/cme_register.html index ac58f4e1960b..cd1038ee2982 100644 --- a/lms/templates/cme_register.html +++ b/lms/templates/cme_register.html @@ -24,12 +24,13 @@ $('body').addClass('js').addClass(view_name); // new window/tab opening - $('a[rel="external"], a[class="new-vp"]') - .click( function() { - window.open( $(this).attr('href') ); - return false; + $('a[rel="external"], a[class="new-vp"]').click( function() { + window.open( $(this).attr('href') ); + return false; }); - + +//---------------------------------------- Client side registration behavior ----------------------------------------// + // form field label styling on focus $("form :input").focus(function() { $("label[for='" + this.id + "']").parent().addClass("is-focused"); @@ -38,14 +39,21 @@ }); // display dependent form sections - $('input.controller-show').click(function() { - $(this).parent().siblings('.controlled').slideDown('fast'); - }); - $('input.controller-hide').click(function() { - $(this).parent().siblings('.controlled').slideUp('fast'); + $('select.affiliation-controller').change(function() { + $(this).siblings('.affiliation-controlled').slideUp('fast'); + + if ($(this).children("option:selected").val() === 'Stanford University') { + $(this).siblings('.affiliation-controlled#sunet_id_container, .affiliation-controlled#stanford_department_container').slideDown('fast'); + } else if ($(this).children("option:selected").val() === "Packard Children's Health Alliance") { + $(this).siblings('.affiliation-controlled#PCHA_affiliation_container').slideDown('fast'); + } else if ($(this).children("option:selected").val() === 'University Healthcare Alliance') { + $(this).siblings('.affiliation-controlled#UHA_affiliation_container').slideDown('fast'); + } else if ($(this).children("option:selected").val() === 'Other') { + $(this).siblings('.affiliation-controlled#other_affiliation_container').slideDown('fast'); + } }); - + $('select.controller').change(function() { if ($(this).children("option:selected").val() === 'Other') { $(this).siblings('.controlled').slideDown('fast'); @@ -70,7 +78,44 @@ $(controlledField).html($(controlledFieldContents).html()).parent().show(); } }); - + + // Dependent required fields + $('select#professional_designation').change(function() { + var dependentRequiredFields = 'li#license-number_container, li#license-country_container, li#physician_status_container, li#patient_population_container, li#specialty-container'; + + if ($(this).children("option:selected").val() === 'MD' || $(this).children("option:selected").val() === 'MD, PhD' || $(this).children("option:selected").val() === 'DO' || $(this).children("option:selected").val() === 'MBBS') { + $(this).parent().siblings(dependentRequiredFields).addClass('required'); + } else { + $(this).parent().siblings(dependentRequiredFields).removeClass('required'); + } + }); + $('select#stanford_affiliation').change(function() { + if ($(this).children("option:selected").val() === 'Other' || $(this).children("option:selected").val() === '') { + $(this).parent().siblings('li.field').removeClass('required'); + } else { + $(this).parent().siblings('li.field').addClass('required'); + } + }); + $('select#license_country').change(function() { + var dependentRequiredFields = 'li#license-state_container'; + + if ($(this).children("option:selected").val() === 'United States') { + $(this).parent().siblings(dependentRequiredFields).addClass('required'); + } else { + $(this).parent().siblings(dependentRequiredFields).removeClass('required'); + } + }); + $('select#country').change(function() { + var dependentRequiredFields = 'li#state_container'; + + if ($(this).children("option:selected").val() === 'United States') { + $(this).parent().siblings(dependentRequiredFields).addClass('required'); + } else { + $(this).parent().siblings(dependentRequiredFields).removeClass('required'); + } + }); + +//--------------------------------------- /Client side registration behavior ----------------------------------------// }); (function() { @@ -172,6 +217,37 @@

Required Information

Needed for any certificates you may earn (cannot be changed later) + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + +
  • + + +
  • + % else: @@ -213,22 +289,13 @@

    Welcome ${extauth_id}

    % endif -
    +

    Professional Information

      -
    1. - - -
    2. -
    3. +
    4. -
    5. +
    6. - -
    -
    - -
    -
    -

    Organization Information

    - -
      -
    1. - - -
    2. - -
    3. - -
      - Yes - No - - -
      -
    4. -
    -
    +
  • + + +
  • -
    -
    -

    Your Patient Information

    - -
      -
    1. +
    2. + + +
    3. + +
    4. + + +
    5. + +
    6. -
    7. - + + + + ##################################################### ## Specialty Select Field ##################################################### - @@ -343,7 +394,7 @@

      Your Patient Information

      ## Sub Specialty Select Field ##################################################### - @@ -417,10 +468,72 @@

      Your Patient Information

      %endfor - + +
    - + +
    +
    +

    Affiliation Information

    + +
      + +
    1. + + + + + + + + + + + + +
    2. + +
    +

    @@ -429,37 +542,22 @@

    Professional Contact Information

      -
    1. +
    2. -
    3. +
    4. -
    5. +
    6. - -
    7. - - -
    8. - -
    9. - - -
    10. - -
    11. + +
    12. - -
    13. - - -
    14. - -
    15. - - -
    16. - -
    17. - - -
    18. - -
    19. - - - %for code, about_us in CmeUserProfile.HEAR_ABOUT_US_CHOICES: - % if code == "Other, please enter:": - - % else: - - % endif - %endfor + %for code, state in CmeUserProfile.STATE_CHOICES: + + %endfor -
    20. - - + +
    21. + + +
    22. +
    23. + + +
    24. +
    -
    +

    Account Acknowledgements @@ -543,7 +626,7 @@

    Professional Contact Information

    % endif -
    +