diff --git a/authentication/auth.go b/authentication/auth.go index 2e39f2fc..c8cd3ac7 100644 --- a/authentication/auth.go +++ b/authentication/auth.go @@ -143,8 +143,7 @@ func generateClaims(claimValues map[string][]string, launcherSchema surveys.Laun claims[key] = value } } - var isCensusTestSchema = len(claimValues["schema_name"]) > 0 && claimValues["schema_name"][0] == "test_individual_response" - if !isCensusTestSchema && (len(claimValues["survey"]) > 0 || len(claimValues["form_type"]) > 0 || len(claimValues["region_code"]) > 0) { + if len(claimValues["form_type"]) > 0 && len(claimValues["eq_id"]) > 0 { log.Println("Deleting schema name from claims") delete(claims, "schema_name") } else { @@ -389,25 +388,15 @@ func GenerateTokenFromDefaults(surveyURL string, accountServiceURL string, accou return token, "" } -// TransformSchemaParamsToName Returns a schema name from census schema parameters -// This function can be removed after census claims are removed. +// TransformSchemaParamsToName Returns a schema name from business schema parameters func TransformSchemaParamsToName(postValues url.Values) string { if postValues.Get("schema_name") != "" { return postValues["schema_name"][0] } - formTypeMap := map[string]string{ - "H": "household", - "I": "individual", - "C": "communal_establishment", - } - - regionCode := strings.Replace(postValues.Get("region_code"), "-", "_", -1) - regionCode = strings.ToLower(regionCode) - - survey := postValues.Get("survey") - formType := formTypeMap[postValues.Get("form_type")] - schemaName := fmt.Sprintf("%s_%s_%s", survey, formType, regionCode) + eqId := postValues.Get("eq_id") + formType := postValues.Get("form_type") + schemaName := fmt.Sprintf("%s_%s", eqId, formType) return schemaName } diff --git a/surveys/surveys.go b/surveys/surveys.go index 9656b490..0ff4e5e8 100644 --- a/surveys/surveys.go +++ b/surveys/surveys.go @@ -24,8 +24,6 @@ type LauncherSchema struct { // LauncherSchemas is a separation of Test and Live schemas type LauncherSchemas struct { Business []LauncherSchema - CCS []LauncherSchema - Census []LauncherSchema Social []LauncherSchema Test []LauncherSchema Other []LauncherSchema @@ -63,13 +61,9 @@ func GetAvailableSchemas() LauncherSchemas { for _, launcherSchema := range runnerSchemas { if strings.HasPrefix(launcherSchema.Name, "test_") { schemaList.Test = append(schemaList.Test, launcherSchema) - } else if strings.HasPrefix(launcherSchema.Name, "census_") { - schemaList.Census = append(schemaList.Census, launcherSchema) - } else if strings.HasPrefix(launcherSchema.Name, "lms_") { + } else if strings.HasPrefix(launcherSchema.Name, "lms_") { schemaList.Social = append(schemaList.Social, launcherSchema) - } else if strings.HasPrefix(launcherSchema.Name, "ccs_") { - schemaList.CCS = append(schemaList.CCS, launcherSchema) - } else { + } else { schemaList.Business = append(schemaList.Business, launcherSchema) } } @@ -77,10 +71,8 @@ func GetAvailableSchemas() LauncherSchemas { schemaList.Other = getAvailableSchemasFromRegister() sort.Sort(ByFilename(schemaList.Business)) - sort.Sort(ByFilename(schemaList.Census)) sort.Sort(ByFilename(schemaList.Social)) sort.Sort(ByFilename(schemaList.Test)) - sort.Sort(ByFilename(schemaList.CCS)) return schemaList } @@ -183,16 +175,6 @@ func FindSurveyByName(name string) LauncherSchema { return survey } } - for _, survey := range availableSchemas.CCS { - if survey.Name == name { - return survey - } - } - for _, survey := range availableSchemas.Census { - if survey.Name == name { - return survey - } - } for _, survey := range availableSchemas.Social { if survey.Name == name { return survey diff --git a/templates/launch.html b/templates/launch.html index 126a239b..b294ba1c 100644 --- a/templates/launch.html +++ b/templates/launch.html @@ -15,16 +15,6 @@

Launch a survey

{{end}} - - {{range .Schemas.CCS}} - - {{end}} - - - {{range .Schemas.Census}} - - {{end}} - {{range .Schemas.Social}} @@ -43,7 +33,7 @@

Launch a survey

-
+

Survey Metadata

@@ -132,46 +122,24 @@

Runner Data

// uuidv4: from https://github.com/kelektiv/node-uuid !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.uuidv4=e()}}(function(){return function e(n,r,o){function t(f,u){if(!r[f]){if(!n[f]){var a="function"==typeof require&&require;if(!u&&a)return a(f,!0);if(i)return i(f,!0);var d=new Error("Cannot find module '"+f+"'");throw d.code="MODULE_NOT_FOUND",d}var p=r[f]={exports:{}};n[f][0].call(p.exports,function(e){var r=n[f][1][e];return t(r?r:e)},p,p.exports,e,n,r,o)}return r[f].exports}for(var i="function"==typeof require&&require,f=0;f>>((3&n)<<3)&255;return i}}},{}],3:[function(e,n,r){function o(e,n,r){var o=n&&r||0;"string"==typeof e&&(n="binary"===e?new Array(16):null,e=null),e=e||{};var f=e.random||(e.rng||t)();if(f[6]=15&f[6]|64,f[8]=63&f[8]|128,n)for(var u=0;u<16;++u)n[o+u]=f[u];return n||i(f)}var t=e("./lib/rng"),i=e("./lib/bytesToUuid");n.exports=o},{"./lib/bytesToUuid":1,"./lib/rng":2}]},{},[3])(3)}); - const schema_name_census_regex = /^(census|ccs)_(household|individual|communal_establishment)_(gb_[a-z]{3})\s*$/ - const form_types = { - 'household': 'H', - 'individual': 'I', - 'communal_establishment': 'C', - } - - function clearCensusClaims() { - document.getElementById('census_claims').innerHTML = "" + function clearBusinessClaims() { + document.getElementById('business_claims').innerHTML = "" } - function includeCensusClaims(schema_name, is_census_test_schema = false) { - let surveyValue = "CENSUS" - let formTypeValue = "C" - let regionCodeValue = "GB-ENG" + function includeBusinessClaims(schema_name) { + let eqIdValue = schema_name.split('_')[0] + let formTypeValue = schema_name.split('_')[1] - if (!is_census_test_schema) { - const matches = schema_name_census_regex.exec(schema_name) - surveyValue = matches[1].toUpperCase() - formTypeValue = form_types[matches[2]] - regionCodeValue = matches[3].toUpperCase().replace('_', '-') - } - - document.getElementById('census_claims').innerHTML = ` + document.getElementById('business_claims').innerHTML = ` +

Business Survey Metadata

- - + +
- +
-
- - -
-
- - -
` } @@ -180,11 +148,11 @@

Runner Data

document.getElementById("flush-btn").disabled = true; const schema_name = document.getElementById("schema_name").value - const is_census_test_schema = schema_name === "test_individual_response" - if (is_census_test_schema || schema_name.startsWith('census') || schema_name.startsWith('ccs')) { - includeCensusClaims(schema_name, is_census_test_schema) + + if (schema_name.startsWith('test_')) { + clearBusinessClaims() } else { - clearCensusClaims() + includeBusinessClaims(schema_name) } var xhttp = new XMLHttpRequest();