Skip to content

Commit

Permalink
Merge pull request #5 from jonsayer/master
Browse files Browse the repository at this point in the history
Work up to June 10
  • Loading branch information
daveb-501commons authored Jun 11, 2019
2 parents c5a0d0f + 194cd51 commit 889bd2f
Show file tree
Hide file tree
Showing 10 changed files with 258 additions and 90 deletions.
17 changes: 16 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
@@ -1 +1,16 @@
Test readme
How to Install

1) In the target org, install the Twilio Helper Library: https://github.com/twilio/twilio-salesforce
2) Ensure your target org has all of the fields associated with our fieldsets pre-installed. Those can be found in src/Objects, in the Account.object file and the Contact.object file. A TBG sandbox should work just fine.
3) Install this package to your instance.
4) After install, configure the Custom Settings for "TwilioConfig".
a) For TBG sites, please see those relevant docs.
b) The settings must have the name "default", no quotes, all lower case.
5) Create a Force.com site with these permissions:
a) Access to all of the Visualforce Pages in this package/
i) C501_ClassReg_CreateAcct
ii) C501_ClassReg_Home
iii) C501_ClassReg_Login
b) Set the site template to C501_ClassRegSiteTemplate
c) Configure the PubliC Access Settings to have access to all of the fields on the Contact, Account, and School Term objects that are needed (this will shift through the lifetime of this project)
d) Also, make sure the Public Access Settings have full access to the Class Site Login Attempt object.
92 changes: 87 additions & 5 deletions src/classes/C501_CTRL_ClassReg_CreateAcct.cls
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,22 @@ public class C501_CTRL_ClassReg_CreateAcct {
public Account family {get; set;}
public String pageStatus {get; set;}
public ID loginID {get; set;}
public List<SelectOption> schoolList {get;set;}
public String schoolName {get;set;}
public String schoolRegion {get;set;}
public School_Term__c term {get;set;}
private String RegType {get;set;}

public List<SelectOption> schoolList {get;set;}

public List<Schema.FieldSetMember> hhFieldSet {get;set;}
public List<Schema.FieldSetMember> parentFieldSet {get;set;}
public List<Schema.FieldSetMember> childFieldSet {get;set;}

public C501_CTRL_ClassReg_CreateAcct(){
Boolean loggedIn = false;
loginID = null;
RegType = null;

Cookie aId = ApexPages.currentPage().getCookies().get('LoginIdClassRegSite');
if (aId != null){
loginID = aId.getValue();
Expand Down Expand Up @@ -51,12 +60,34 @@ public class C501_CTRL_ClassReg_CreateAcct {
);
if(confirmMeth != null && confirmMeth.contains('@')){
parent.Email = confirmMeth;
RegType = 'byEmail';
} else {
parent.MobilePhone = confirmMeth;
RegType = 'byText';
}

schoolList = C501_UTIL_ClassRegUtilities.getSelectOptionsActiveSchools(null);
schoolRegion = '';
schoolList = getSelectOptionsActiveSchools('');
schoolName = '';

Map<String, Schema.FieldSet> FsAcctMap = Schema.SObjectType.Account.fieldSets.getMap();
Map<String, Schema.FieldSet> FsContMap = Schema.SObjectType.Contact.fieldSets.getMap();

try{
hhFieldSet = FsAcctMap.get('C501_ClassReg_Site_HH_Acct_Custom').getFields();
} catch(Exception e){
hhFieldSet = FsAcctMap.get('C501_Class_Registration_Site_HH_Acct').getFields();
}
try{
parentFieldSet = FsContMap.get('C501_ClassReg_Site_Parent_Custom').getFields();
} catch(Exception e){
parentFieldSet = FsContMap.get('C501_Class_Registration_Site_Parent').getFields();
}
try{
childFieldSet = FsContMap.get('C501_ClassReg_Site_Child_Custom').getFields();
} catch(Exception e){
childFieldSet = FsContMap.get('C501_Class_Registration_Site_Child').getFields();
}
}

/*public PageReference confirmLogin(){
Expand All @@ -75,9 +106,7 @@ public class C501_CTRL_ClassReg_CreateAcct {
}*/

public Pagereference refreshSchools(){

schoolList = C501_UTIL_ClassRegUtilities.getSelectOptionsActiveSchools( C501_UTIL_ClassRegUtilities.getRegionFromAddy(family.BillingCity,family.BillingState) );
//schoolList = C501_UTIL_ClassRegUtilities.getSelectOptionsActiveSchools( C501_UTIL_ClassRegUtilities.getRegionFromAddy('Renton','WA') );
schoolList = getSelectOptionsActiveSchools( schoolRegion );
return null;
}

Expand Down Expand Up @@ -119,14 +148,67 @@ public class C501_CTRL_ClassReg_CreateAcct {
insert child;

term.Student__c = child.Id;
term.Parent__c = parent.Id;
term.School__c = schoolName;

// future version, need to make this dynamic
term.School_Year__c = '2019-2020';
term.C501_Sign_Up_Source__c = RegType;

insert term;

return null;
}

public static List<SelectOption> getRegions(){
List<SelectOption> regions = new List<SelectOption>();

regions.add(new SelectOption( '', 'Select One' ) );
regions.add(new SelectOption( 'East Bay', Label.C501_ClassReg_eastBay ) );
regions.add(new SelectOption( 'South Bay', Label.C501_ClassReg_southBay ) );
regions.add(new SelectOption( 'Seattle', Label.C501_ClassReg_seattleArea ) );
regions.add(new SelectOption( 'DC', Label.C501_ClassReg_dcArea ) );
return regions;
}

public static List<Account> getListOfActiveSchools(String regionFilter){
Id schoolRecordType = [select id from Recordtype where Name='School'].Id;
List<Account> schoolList = new List<Account>();
schoolList = [
SELECT id,
Name,
School_District_Lookup__c,
School_District_Lookup__r.Name,
Region__c
FROM Account
WHERE RecordTypeId = :schoolRecordType
AND Region__c = :regionFilter
ORDER BY School_District_Lookup__r.Name, Name
];
if(schoolList.size() == 0){
schoolList = [
SELECT id,
Name,
School_District_Lookup__c,
School_District_Lookup__r.Name,
Region__c
FROM Account
WHERE RecordTypeId = :schoolRecordType
ORDER BY School_District_Lookup__r.Name, Name
];
}
return schoolList;
}

public static List<SelectOption> getSelectOptionsActiveSchools(String regionFilter){
List<Account> schoolList = getListOfActiveSchools(regionFilter);
List<SelectOption> schoolOptions = new List<SelectOption>();
schoolOptions.add(new SelectOption( '', 'Select One: '+ regionFilter) );
for(Account school : schoolList ){
schoolOptions.add(new SelectOption( school.Id, school.School_District_Lookup__r.Name+': '+school.Name ) );
}

return schoolOptions;
}

}
19 changes: 19 additions & 0 deletions src/classes/C501_TEST_ClassReg_CreateAcct.cls
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public class C501_TEST_ClassReg_CreateAcct {
Test.setCurrentPage(createAcctPage);
System.currentPageReference().getParameters().put('a', att.id);
System.currentPageReference().getParameters().put('r', '1');

Test.startTest();
C501_CTRL_ClassReg_CreateAcct controller = new C501_CTRL_ClassReg_CreateAcct();
System.assert(controller.pageStatus == 'new');

Expand All @@ -71,12 +73,29 @@ public class C501_TEST_ClassReg_CreateAcct {
controller.family.BillingState = 'WA';
controller.family.BillingPostalCode = '98101';

controller.refreshSchools();

controller.child.FirstName = 'Child';
controller.child.LastName = 'Name';
controller.schoolName = school.Id;

controller.createAccount();

Test.stopTest();

List<School_Term__c> lookupTest = [
SELECT id,
Parent__c,
Parent__r.FirstName,
Student__c,
School__c,
School__r.Name
FROM School_Term__c
];

System.assert( lookupTest.size() == 1 );
System.assert( lookupTest[0].Parent__r.FirstName == 'Test' );
System.assert( lookupTest[0].School__r.Name == 'TestSchool' );
}

public static Class_Site_Login_Attempt__c createLoggedInTestUser(){
Expand Down
55 changes: 0 additions & 55 deletions src/classes/C501_UTIL_ClassRegUtilities.cls
Original file line number Diff line number Diff line change
Expand Up @@ -13,62 +13,7 @@ public class C501_UTIL_ClassRegUtilities {
}
}

public static List<Account> getListOfActiveSchools(String regionFilter){
Id schoolRecordType = [select id from Recordtype where Name='School'].Id;
List<Account> schoolList = new List<Account>();

if(regionFilter == null){
schoolList = [
SELECT id,
Name,
School_District_Lookup__c,
School_District_Lookup__r.Name,
Region__c
FROM Account
WHERE RecordTypeId = :schoolRecordType
ORDER BY School_District_Lookup__r.Name, Name
];
} else if(regionFilter == 'SF Bay'){
schoolList = [
SELECT id,
Name,
School_District_Lookup__c,
School_District_Lookup__r.Name,
Region__c
FROM Account
WHERE RecordTypeId = :schoolRecordType
AND (Region__c = 'East Bay'
OR Region__c = 'South Bay'
)
ORDER BY School_District_Lookup__r.Name, Name
];
} else {
schoolList = [
SELECT id,
Name,
School_District_Lookup__c,
School_District_Lookup__r.Name,
Region__c
FROM Account
WHERE RecordTypeId = :schoolRecordType
AND Region__c = :regionFilter
ORDER BY School_District_Lookup__r.Name, Name
];
}
return schoolList;
}

public static List<SelectOption> getSelectOptionsActiveSchools(String regionFilter){
List<Account> schoolList = getListOfActiveSchools(regionFilter);
List<SelectOption> schoolOptions = new List<SelectOption>();
for(Account school : schoolList ){
schoolOptions.add(new SelectOption( school.Id, school.School_District_Lookup__r.Name+': '+school.Name ) );
}
if(schoolOptions.size() == 0){
schoolOptions.add(new SelectOption( 'heyhey', 'New Yawk City: School of Hard Knocks' ));
}
return schoolOptions;
}

public static PageReference confirmLogin(String confirmation,ID acctID,Boolean remember){
String pageStatus = C501_UTIL_ClassRegUtilities.checkVerificationCode(confirmation,acctID);
Expand Down
35 changes: 35 additions & 0 deletions src/labels/CustomLabels.labels
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
<shortDescription>C501_ClassReg_ChildSchoolName</shortDescription>
<value>Student&apos;s School</value>
</labels>
<labels>
<fullName>C501_ClassReg_ChildSchoolRegion</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_ChildSchoolRegion</shortDescription>
<value>Techbridge serves girls in four different regions. Which region is your child&apos;s school in?</value>
</labels>
<labels>
<fullName>C501_ClassReg_HHhomePhone</fullName>
<language>en_US</language>
Expand Down Expand Up @@ -42,6 +49,34 @@
<shortDescription>C501_ClassReg_ParentWorkPhone</shortDescription>
<value>Parent/Guardian Work Phone</value>
</labels>
<labels>
<fullName>C501_ClassReg_dcArea</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_dcArea</shortDescription>
<value>Washington DC Area</value>
</labels>
<labels>
<fullName>C501_ClassReg_eastBay</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_eastBay</shortDescription>
<value>East San Francisco Bay Area (eg. Oakland)</value>
</labels>
<labels>
<fullName>C501_ClassReg_seattleArea</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_seattleArea</shortDescription>
<value>Seattle Area</value>
</labels>
<labels>
<fullName>C501_ClassReg_southBay</fullName>
<language>en_US</language>
<protected>false</protected>
<shortDescription>C501_ClassReg_southBay</shortDescription>
<value>South San Francisco Bay Area (eg. San Jose)</value>
</labels>
<labels>
<fullName>C501_RegSite_ChildEmail</fullName>
<language>en_US</language>
Expand Down
4 changes: 4 additions & 0 deletions src/layouts/School_Term__c-School Term Layout.layout
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<behavior>Readonly</behavior>
<field>School_Region__c</field>
</layoutItems>
<layoutItems>
<behavior>Edit</behavior>
<field>C501_Sign_Up_Source__c</field>
</layoutItems>
</layoutColumns>
<layoutColumns>
<layoutItems>
Expand Down
17 changes: 6 additions & 11 deletions src/objects/Contact.object
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<fieldSets>
<fullName>C501_Class_Registration_Site_Child_Con</fullName>
<description>Used by the class registration site to define the fields needed for the student/child of a family.</description>
<label>Class Registration Site Child Contact Fields</label>
<fullName>C501_Class_Registration_Site_Child</fullName>
<description>Used by the class registration site to define the fields used on the child contact.</description>
<label>C501_Class_Registration_Site_Child</label>
</fieldSets>
<fieldSets>
<fullName>C501_Class_Registration_Site_Parent_Con</fullName>
<description>Used on the class registration site to indicate the Contact fields needed for the primary logged-in parent.</description>
<displayedFields>
<field>Translation_Needed__c</field>
<isFieldManaged>false</isFieldManaged>
<isRequired>false</isRequired>
</displayedFields>
<label>Class Registration Site Parent Contact Fields</label>
<fullName>C501_Class_Registration_Site_Parent</fullName>
<description>Used by the class registration site to define the fields used on the parent contact.</description>
<label>C501_Class_Registration_Site_Parent</label>
</fieldSets>
<fields>
<fullName>Emergency_Preferred_Medical_Provider__c</fullName>
Expand Down
30 changes: 30 additions & 0 deletions src/objects/School_Term__c.object
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,36 @@
<trackTrending>false</trackTrending>
<type>Checkbox</type>
</fields>
<fields>
<fullName>C501_Sign_Up_Source__c</fullName>
<externalId>false</externalId>
<inlineHelpText>How this School Term record came to be in Salesforce. (default = Paper, byText and byEmail mean it was the Site)</inlineHelpText>
<label>Sign Up Source</label>
<required>false</required>
<trackHistory>false</trackHistory>
<trackTrending>false</trackTrending>
<type>Picklist</type>
<valueSet>
<valueSetDefinition>
<sorted>false</sorted>
<value>
<fullName>Paper</fullName>
<default>true</default>
<label>Paper</label>
</value>
<value>
<fullName>byText</fullName>
<default>false</default>
<label>byText</label>
</value>
<value>
<fullName>byEmail</fullName>
<default>false</default>
<label>byEmail</label>
</value>
</valueSetDefinition>
</valueSet>
</fields>
<fields>
<fullName>Contract__c</fullName>
<defaultValue>false</defaultValue>
Expand Down
Loading

0 comments on commit 889bd2f

Please sign in to comment.