Skip to content

Commit

Permalink
Add AllowIdSignInWithProhibitions member to v3 teacher response
Browse files Browse the repository at this point in the history
This is a short term solution so that ID can prevent sign in (or
registration) of prohibited teachers *unless* a flag has been set on
the matched DQT record.

As it's for our use only and short term, I've hidden it from the Swagger
doc and prefixed the include entry with an '_'.
  • Loading branch information
gunndabad committed Nov 13, 2023
1 parent e2d69ab commit 5614045
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace TeachingRecordSystem.Api.Infrastructure.OpenApi;

[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
public sealed class ExcludeFromSchemaAttribute : Attribute
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Reflection;
using NJsonSchema.Generation;

namespace TeachingRecordSystem.Api.Infrastructure.OpenApi;

public class RemoveExcludedEnumOptionsSchemaProcessor : ISchemaProcessor
{
public void Process(SchemaProcessorContext context)
{
var type = context.ContextualType.Type;

if (!type.IsEnum)
{
return;
}

foreach (var memberName in Enum.GetNames(type))
{
var member = type.GetField(memberName)!;
if (member.GetCustomAttribute<ExcludeFromSchemaAttribute>() is not null)
{
context.Schema.Enumeration.Remove(memberName);
context.Schema.EnumerationNames.Remove(memberName);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public static IServiceCollection AddOpenApi(this IServiceCollection services, IC
settings.DocumentProcessors.Add(new PopulateResponseDescriptionOperationProcessor());

settings.SchemaProcessors.Add(new RemoveCompositeValuesFromFlagsEnumSchemaProcessor());
settings.SchemaProcessors.Add(new RemoveExcludedEnumOptionsSchemaProcessor());

settings.OperationProcessors.Add(new ResponseContentTypeOperationProcessor());
settings.OperationProcessors.Add(new PopulateResponseDescriptionOperationProcessor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public GetTeacherHandler(IDataverseAdapter dataverseAdapter, ICrmQueryDispatcher
Contact.Fields.dfeta_NINumber,
Contact.Fields.dfeta_QTSDate,
Contact.Fields.dfeta_EYTSDate,
Contact.Fields.EMailAddress1
Contact.Fields.EMailAddress1,
Contact.Fields.dfeta_AllowIDSignInWithProhibitions
});

if (teacher is null)
Expand Down Expand Up @@ -214,6 +215,10 @@ public GetTeacherHandler(IDataverseAdapter dataverseAdapter, ICrmQueryDispatcher

var qtsAwardedInWales = qtsRegistrations.Any(qts => qts.dfeta_QTSDate is not null && qts.dfeta_TeacherStatusId.Id == qtsAwardedInWalesStatus.Id);

var allowIdSignInWithProhibitions = request.Include.HasFlag(GetTeacherRequestIncludes._AllowIdSignInWithProhibitions) ?
Option.Some(teacher.dfeta_AllowIDSignInWithProhibitions == true) :
default;

return new GetTeacherResponse()
{
Trn = request.Trn,
Expand Down Expand Up @@ -270,7 +275,8 @@ public GetTeacherHandler(IDataverseAdapter dataverseAdapter, ICrmQueryDispatcher
AlertType = AlertType.Prohibition,
DqtSanctionCode = s.SanctionCode
})) :
default
default,
AllowIdSignInWithProhibitions = allowIdSignInWithProhibitions
};
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.ComponentModel;
using MediatR;
using TeachingRecordSystem.Api.Infrastructure.OpenApi;
using TeachingRecordSystem.Api.V3.Responses;

namespace TeachingRecordSystem.Api.V3.Requests;
Expand All @@ -26,5 +27,8 @@ public enum GetTeacherRequestIncludes
Sanctions = 1 << 6,
Alerts = 1 << 7,

[ExcludeFromSchema]
_AllowIdSignInWithProhibitions = 1 << 8,

All = Induction | InitialTeacherTraining | NpqQualifications | MandatoryQualifications | PendingDetailChanges | HigherEducationQualifications | Sanctions | Alerts
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public record GetTeacherResponse
public required Option<IEnumerable<GetTeacherResponseHigherEducationQualification>> HigherEducationQualifications { get; init; }
public required Option<IEnumerable<SanctionInfo>> Sanctions { get; init; }
public required Option<IEnumerable<AlertInfo>> Alerts { get; init; }
public required Option<bool> AllowIdSignInWithProhibitions { get; init; }
}

public record GetTeacherResponseQts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,7 @@ public static class Fields
public const string Id = "contactid";
public const string CreatedOn = "createdon";
public const string dfeta_ActiveSanctions = "dfeta_activesanctions";
public const string dfeta_AllowIDSignInWithProhibitions = "dfeta_allowidsigninwithprohibitions";
public const string dfeta_AllowPiiUpdatesFromRegister = "dfeta_allowpiiupdatesfromregister";
public const string dfeta_EYTSDate = "dfeta_eytsdate";
public const string dfeta_HUSID = "dfeta_husid";
Expand Down Expand Up @@ -1605,6 +1606,26 @@ public System.Nullable<bool> dfeta_ActiveSanctions
}
}

/// <summary>
///
/// </summary>
[Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("dfeta_allowidsigninwithprohibitions")]
public System.Nullable<bool> dfeta_AllowIDSignInWithProhibitions
{
[System.Diagnostics.DebuggerNonUserCode()]
get
{
return this.GetAttributeValue<System.Nullable<bool>>("dfeta_allowidsigninwithprohibitions");
}
[System.Diagnostics.DebuggerNonUserCode()]
set
{
this.OnPropertyChanging("dfeta_AllowIDSignInWithProhibitions");
this.SetAttributeValue("dfeta_allowidsigninwithprohibitions", value);
this.OnPropertyChanged("dfeta_AllowIDSignInWithProhibitions");
}
}

/// <summary>
///
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion crm_attributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"telephone1",
"dfeta_slugid",
"dfeta_allowpiiupdatesfromregister",
"dfeta_previouslastname"
"dfeta_previouslastname",
"dfeta_AllowIDSignInWithProhibitions"
],
"dfeta_businesseventaudit":[
"createdon",
Expand Down
2 changes: 1 addition & 1 deletion tools/coretools/CrmSvcUtil.exe.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<add key="EntityCommandLineText" />
<add key="EntitiesToSkip" />
<add key="EntitiesWhitelist" value="account|annotation|contact|dfeta_businesseventaudit|dfeta_country|dfeta_document|dfeta_earlyyearsstatus|dfeta_hequalification|dfeta_hesubject|dfeta_induction|dfeta_inductionperiod|dfeta_initialteachertraining|dfeta_ittqualification|dfeta_ittsubject|dfeta_previousname|dfeta_qtsregistration|dfeta_qualification|dfeta_sanction|dfeta_sanctioncode|dfeta_specialism|dfeta_teacherstatus|incident|incidentresolution|plugintype|sdkmessage|sdkmessagefilter|sdkmessageprocessingstep|sdkmessageprocessingstepimage|sdkmessageprocessingstepsecureconfig|subject|systemuser|task" />
<add key="AttributesWhitelist" value="account:dfeta_trainingprovider,dfeta_ukprn,name,statecode|annotation:annotationid,documentbody,filename,mimetype,modifiedby,modifiedon,notetext,objectid,objecttypecode,statecode,subject|contact:address1_city,address1_country,address1_line1,address1_line2,address1_line3,address1_postalcode,birthdate,contactid,createdon,dfeta_activesanctions,dfeta_allowpiiupdatesfromregister,dfeta_eytsdate,dfeta_husid,dfeta_inductionStatus,dfeta_lastidentityupdate,dfeta_loginfailedcounter,dfeta_ninumber,dfeta_previouslastname,dfeta_qtsdate,dfeta_slugid,dfeta_statedfirstname,dfeta_statedlastname,dfeta_statedmiddlename,dfeta_trn,dfeta_trnallocaterequest,dfeta_trnrequired,dfeta_tspersonid,emailaddress1,emailaddress2,firstname,fullname,gendercode,lastname,masterid,merged,middlename,mobilephone,modifiedon,statecode,telephone1|dfeta_businesseventaudit:createdon,dfeta_changedfield,dfeta_newvalue,dfeta_oldvalue,dfeta_person,statecode|dfeta_country:dfeta_name,dfeta_value,statecode|dfeta_document:dfeta_caseid,dfeta_documentid,dfeta_name,dfeta_personid,dfeta_type,statecode,statuscode|dfeta_earlyyearsstatus:dfeta_name,dfeta_value,statecode|dfeta_hequalification:dfeta_hequalificationid,dfeta_name,dfeta_value,statecode|dfeta_hesubject:dfeta_name,dfeta_value,statecode|dfeta_induction:CreatedOn,dfeta_completiondate,dfeta_inductionexemptionreason,dfeta_inductionstatus,dfeta_personid,dfeta_startdate,statecode|dfeta_inductionperiod:dfeta_appropriatebodyid,dfeta_enddate,dfeta_inductionid,dfeta_numberofterms,dfeta_startdate,statecode|dfeta_initialteachertraining:dfeta_agerangefrom,dfeta_agerangeto,dfeta_cohortyear,dfeta_countryid,dfeta_establishmentid,dfeta_ittqualificationaim,dfeta_ittqualificationid,dfeta_personid,dfeta_programmeenddate,dfeta_programmestartdate,dfeta_programmetype,dfeta_result,dfeta_slugid,dfeta_subject1id,dfeta_subject2id,dfeta_subject3id,dfeta_traineeid,statecode|dfeta_ittqualification:dfeta_name,dfeta_value,statecode|dfeta_ittsubject:dfeta_name,dfeta_value,statecode|dfeta_previousname:createdon,dfeta_changedon,dfeta_name,dfeta_personid,dfeta_previousnameid,dfeta_type,statecode|dfeta_qtsregistration:dfeta_earlyyearsstatusid,dfeta_eytsdate,dfeta_inductionid,dfeta_name,dfeta_personid,dfeta_qtsdate,dfeta_teacherstatusid,statecode|dfeta_qualification:CreatedOn,dfeta_completionorawarddate,dfeta_createdbyapi,dfeta_he_classdivision,dfeta_he_completiondate,dfeta_he_countryid,dfeta_he_establishmentid,dfeta_he_hequalificationid,dfeta_he_hesubject1id,dfeta_he_hesubject2id,dfeta_he_hesubject3id,dfeta_mq_date,dfeta_mq_specialismid,dfeta_npqel_awarded,dfeta_npqel_date,dfeta_npqeyl_awarded,dfeta_npqeyl_date,dfeta_NPQH_Awarded,dfeta_NPQH_Date,dfeta_npqlbc_awarded,dfeta_npqlbc_date,dfeta_npqll_awarded,dfeta_npqll_date,dfeta_npqlt_awarded,dfeta_npqlt_date,dfeta_npqltd_awarded,dfeta_npqltd_date,dfeta_npqml_awarded,dfeta_npqml_date,dfeta_npqsl_awarded,dfeta_npqsl_date,dfeta_personid,dfeta_type,statecode|dfeta_sanction:dfeta_detailslink,dfeta_enddate,dfeta_noreappuntildate,dfeta_personid,dfeta_sanctioncodeid,dfeta_sanctiondetails,dfeta_sanctionid,dfeta_spent,dfeta_startdate,statecode|dfeta_sanctioncode:dfeta_name,dfeta_sanctioncodeid,dfeta_value,statecode|dfeta_specialism:dfeta_name,dfeta_value,statecode|dfeta_teacherstatus:dfeta_name,dfeta_qtsdaterequired,dfeta_value,statecode|incident:createdon,customerid,description,dfeta_fromidentity,dfeta_newdateofbirth,dfeta_newfirstname,dfeta_newlastname,dfeta_newmiddlename,dfeta_statedfirstname,dfeta_statedlastname,dfeta_statedmiddlename,incidentid,statecode,statuscode,subjectid,ticketnumber,title|incidentresolution:activityid,createdby,incidentid,modifiedby,modifiedon,statecode,subject|plugintype:|sdkmessage:|sdkmessagefilter:|sdkmessageprocessingstep:|sdkmessageprocessingstepimage:|sdkmessageprocessingstepsecureconfig:|subject:description,statecode,subjectid,title|systemuser:azureactivedirectoryobjectid,firstname,isdisabled,lastname,systemuserid|task:activityid,category,description,dfeta_potentialduplicateid,modifiedby,modifiedon,regardingobjectid,scheduledend,statecode,subject" />
<add key="AttributesWhitelist" value="account:dfeta_trainingprovider,dfeta_ukprn,name,statecode|annotation:annotationid,documentbody,filename,mimetype,modifiedby,modifiedon,notetext,objectid,objecttypecode,statecode,subject|contact:address1_city,address1_country,address1_line1,address1_line2,address1_line3,address1_postalcode,birthdate,contactid,createdon,dfeta_activesanctions,dfeta_AllowIDSignInWithProhibitions,dfeta_allowpiiupdatesfromregister,dfeta_eytsdate,dfeta_husid,dfeta_inductionStatus,dfeta_lastidentityupdate,dfeta_loginfailedcounter,dfeta_ninumber,dfeta_previouslastname,dfeta_qtsdate,dfeta_slugid,dfeta_statedfirstname,dfeta_statedlastname,dfeta_statedmiddlename,dfeta_trn,dfeta_trnallocaterequest,dfeta_trnrequired,dfeta_tspersonid,emailaddress1,emailaddress2,firstname,fullname,gendercode,lastname,masterid,merged,middlename,mobilephone,modifiedon,statecode,telephone1|dfeta_businesseventaudit:createdon,dfeta_changedfield,dfeta_newvalue,dfeta_oldvalue,dfeta_person,statecode|dfeta_country:dfeta_name,dfeta_value,statecode|dfeta_document:dfeta_caseid,dfeta_documentid,dfeta_name,dfeta_personid,dfeta_type,statecode,statuscode|dfeta_earlyyearsstatus:dfeta_name,dfeta_value,statecode|dfeta_hequalification:dfeta_hequalificationid,dfeta_name,dfeta_value,statecode|dfeta_hesubject:dfeta_name,dfeta_value,statecode|dfeta_induction:CreatedOn,dfeta_completiondate,dfeta_inductionexemptionreason,dfeta_inductionstatus,dfeta_personid,dfeta_startdate,statecode|dfeta_inductionperiod:dfeta_appropriatebodyid,dfeta_enddate,dfeta_inductionid,dfeta_numberofterms,dfeta_startdate,statecode|dfeta_initialteachertraining:dfeta_agerangefrom,dfeta_agerangeto,dfeta_cohortyear,dfeta_countryid,dfeta_establishmentid,dfeta_ittqualificationaim,dfeta_ittqualificationid,dfeta_personid,dfeta_programmeenddate,dfeta_programmestartdate,dfeta_programmetype,dfeta_result,dfeta_slugid,dfeta_subject1id,dfeta_subject2id,dfeta_subject3id,dfeta_traineeid,statecode|dfeta_ittqualification:dfeta_name,dfeta_value,statecode|dfeta_ittsubject:dfeta_name,dfeta_value,statecode|dfeta_previousname:createdon,dfeta_changedon,dfeta_name,dfeta_personid,dfeta_previousnameid,dfeta_type,statecode|dfeta_qtsregistration:dfeta_earlyyearsstatusid,dfeta_eytsdate,dfeta_inductionid,dfeta_name,dfeta_personid,dfeta_qtsdate,dfeta_teacherstatusid,statecode|dfeta_qualification:CreatedOn,dfeta_completionorawarddate,dfeta_createdbyapi,dfeta_he_classdivision,dfeta_he_completiondate,dfeta_he_countryid,dfeta_he_establishmentid,dfeta_he_hequalificationid,dfeta_he_hesubject1id,dfeta_he_hesubject2id,dfeta_he_hesubject3id,dfeta_mq_date,dfeta_mq_specialismid,dfeta_npqel_awarded,dfeta_npqel_date,dfeta_npqeyl_awarded,dfeta_npqeyl_date,dfeta_NPQH_Awarded,dfeta_NPQH_Date,dfeta_npqlbc_awarded,dfeta_npqlbc_date,dfeta_npqll_awarded,dfeta_npqll_date,dfeta_npqlt_awarded,dfeta_npqlt_date,dfeta_npqltd_awarded,dfeta_npqltd_date,dfeta_npqml_awarded,dfeta_npqml_date,dfeta_npqsl_awarded,dfeta_npqsl_date,dfeta_personid,dfeta_type,statecode|dfeta_sanction:dfeta_detailslink,dfeta_enddate,dfeta_noreappuntildate,dfeta_personid,dfeta_sanctioncodeid,dfeta_sanctiondetails,dfeta_sanctionid,dfeta_spent,dfeta_startdate,statecode|dfeta_sanctioncode:dfeta_name,dfeta_sanctioncodeid,dfeta_value,statecode|dfeta_specialism:dfeta_name,dfeta_value,statecode|dfeta_teacherstatus:dfeta_name,dfeta_qtsdaterequired,dfeta_value,statecode|incident:createdon,customerid,description,dfeta_fromidentity,dfeta_newdateofbirth,dfeta_newfirstname,dfeta_newlastname,dfeta_newmiddlename,dfeta_statedfirstname,dfeta_statedlastname,dfeta_statedmiddlename,incidentid,statecode,statuscode,subjectid,ticketnumber,title|incidentresolution:activityid,createdby,incidentid,modifiedby,modifiedon,statecode,subject|plugintype:|sdkmessage:|sdkmessagefilter:|sdkmessageprocessingstep:|sdkmessageprocessingstepimage:|sdkmessageprocessingstepsecureconfig:|subject:description,statecode,subjectid,title|systemuser:azureactivedirectoryobjectid,firstname,isdisabled,lastname,systemuserid|task:activityid,category,description,dfeta_potentialduplicateid,modifiedby,modifiedon,regardingobjectid,scheduledend,statecode,subject" />
<add key="EntityPrefixesToSkip" />
<add key="EntityPrefixesWhitelist" />
<add key="FilePrefixText" />
Expand Down

0 comments on commit 5614045

Please sign in to comment.