Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit b645911

Browse files
WardormeurDanielBrierton
authored andcommitted
Add view for join requests (#224)
* Add view for join requests add handler for join_requests listing * Simplify view * Add users associated to this view for tests
1 parent b27eb38 commit b645911

File tree

4 files changed

+118
-0
lines changed

4 files changed

+118
-0
lines changed

lib/users/join-request.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
'use strict';
2+
var _ = require('lodash');
3+
4+
/**
5+
* @param {Object} user
6+
* @example "curl 'http://localhost:10303/act' -H 'Content-Type: application/json' --data-binary '{"role":"cd-users", "domain": "join_requests", "cmd": "search", "query": {"userType":"champion"} }'
7+
*/
8+
function joinRequests (seneca, role) {
9+
var joinRequests = {};
10+
var entity = seneca.make$('cd/v_join_requests');
11+
12+
joinRequests.search = function (args, done) {
13+
var query = args.query;
14+
entity.list$(query, done);
15+
};
16+
17+
_.each(_.keys(joinRequests), function (cmd) {
18+
seneca.add({role: role, domain: 'join_requests', cmd: cmd}, joinRequests[cmd]);
19+
});
20+
21+
return joinRequests;
22+
}
23+
24+
module.exports = joinRequests;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
DO $$
2+
BEGIN
3+
CREATE OR REPLACE VIEW cd_v_join_requests AS
4+
(SELECT join_request->>'id' AS id,
5+
user_id,
6+
join_request->>'dojoId' AS dojo_id,
7+
join_request->>'userType' AS user_type,
8+
join_request->>'timestamp' AS timestamp
9+
FROM (select unnest(join_requests) AS join_request, user_id FROM cd_user_profile) x);
10+
END;
11+
$$

test/fixtures/e2e/users.json

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,5 +874,85 @@
874874
"address" : "CHQ building, Dublin 1",
875875
"requiredFieldsComplete": true
876876
}
877+
},
878+
{
879+
"user": {
880+
"name": "userRequestingAccess1",
881+
"email": "[email protected]",
882+
"password": "testuserRequestingAccess1",
883+
"termsConditionsAccepted": true,
884+
"initUserType": {"name": "parent-guardian", "title": "Parent/Guardian"},
885+
"g-recaptcha-response": "03AHJ_VuufpHRAc3bbYfeMunZ-nOYP5rjdSwlw7e4Btq-RGYYvCRTJJkXptbQuBwJDL0ZWQ7eHeQRoTI9iRZlakVlpVDB9rd0kYw2iNcMXG9qNNNBNv_qNjTyE4RwZ3x0zAt2aqg-LjboEqRyLqbOO032kal8wz_GGKbrykJMV0kiSdCbABlSalNHUwlP9II7nGs1me9x84owsr5ZCFkCYtQehguTm6nMe9HRq7hLbQb4hK8HuWwfqQ1z5CIuKk7el5taxNC1h4QuqWsNgGlWAv_Gqp4dJjz683kNCV2vbTlofz6FwttNZwD-mS1l4OrTCdvdX9JBcipXbjlIF1RFyBbXGvSAftp3_ajmoAjstwSdAZVtD1Whm_x8nUo_0pFp6x0n0Y1j8Ztc87oxAXswI-Yvf8JFu8Bhaw_SwAz2Qk7meR2Mvx5lKz_3IzK_b15gnmXenqamBpksv"
886+
},
887+
"profile": {
888+
"dob": "1982-01-31T22:00:00.000Z",
889+
"country": {
890+
"countryName": "Ireland",
891+
"countryNumber": "372",
892+
"continent": "EU",
893+
"alpha2": "IE",
894+
"alpha3": "IRL"
895+
},
896+
"userType": "parent-guardian",
897+
"city": {},
898+
"countryname": "Ireland",
899+
"countrynumber": null,
900+
"continent": "EU",
901+
"alpha2": "IE",
902+
"alpha3": "IRL",
903+
"admin1Code": null,
904+
"admin1Name": null,
905+
"admin2Code": null,
906+
"admin2Name": null,
907+
"admin3Code": null,
908+
"admin3Name": null,
909+
"admin4Code": null,
910+
"admin4Name": null,
911+
"state": {},
912+
"county": {},
913+
"place": {"nameWithHierarchy":"Dublin"},
914+
"placeName": "Dublin",
915+
"requiredFieldsComplete": true
916+
}
917+
},
918+
{
919+
"user": {
920+
"name": "userRequestingAccess2",
921+
"email": "[email protected]",
922+
"password": "testuserRequestingAccess2",
923+
"termsConditionsAccepted": true,
924+
"initUserType": {"name": "parent-guardian", "title": "Parent/Guardian"},
925+
"g-recaptcha-response": "03AHJ_VuufpHRAc3bbYfeMunZ-nOYP5rjdSwlw7e4Btq-RGYYvCRTJJkXptbQuBwJDL0ZWQ7eHeQRoTI9iRZlakVlpVDB9rd0kYw2iNcMXG9qNNNBNv_qNjTyE4RwZ3x0zAt2aqg-LjboEqRyLqbOO032kal8wz_GGKbrykJMV0kiSdCbABlSalNHUwlP9II7nGs1me9x84owsr5ZCFkCYtQehguTm6nMe9HRq7hLbQb4hK8HuWwfqQ1z5CIuKk7el5taxNC1h4QuqWsNgGlWAv_Gqp4dJjz683kNCV2vbTlofz6FwttNZwD-mS1l4OrTCdvdX9JBcipXbjlIF1RFyBbXGvSAftp3_ajmoAjstwSdAZVtD1Whm_x8nUo_0pFp6x0n0Y1j8Ztc87oxAXswI-Yvf8JFu8Bhaw_SwAz2Qk7meR2Mvx5lKz_3IzK_b15gnmXenqamBpksv"
926+
},
927+
"profile": {
928+
"dob": "1982-01-31T22:00:00.000Z",
929+
"country": {
930+
"countryName": "Ireland",
931+
"countryNumber": "372",
932+
"continent": "EU",
933+
"alpha2": "IE",
934+
"alpha3": "IRL"
935+
},
936+
"userType": "parent-guardian",
937+
"city": {},
938+
"countryname": "Ireland",
939+
"countrynumber": null,
940+
"continent": "EU",
941+
"alpha2": "IE",
942+
"alpha3": "IRL",
943+
"admin1Code": null,
944+
"admin1Name": null,
945+
"admin2Code": null,
946+
"admin2Name": null,
947+
"admin3Code": null,
948+
"admin3Name": null,
949+
"admin4Code": null,
950+
"admin4Name": null,
951+
"state": {},
952+
"county": {},
953+
"place": {"nameWithHierarchy":"Dublin"},
954+
"placeName": "Dublin",
955+
"requiredFieldsComplete": true
956+
}
877957
}
878958
]

users.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ module.exports = function (options) {
5151
this.prior(data, cb);
5252
});
5353

54+
// Define patterns for join_request view
55+
require('./lib/users/join-request')(seneca, plugin);
56+
5457
function cmd_load_prev_founder (args, done) {
5558
var seneca = this;
5659
seneca.act({role: plugin, cmd: 'load', id: args.id}, function (err, user) {

0 commit comments

Comments
 (0)