diff --git a/constants/general.constant.js b/constants/general.constant.js index 2f762e4b..6c71e582 100644 --- a/constants/general.constant.js +++ b/constants/general.constant.js @@ -45,7 +45,7 @@ const SAMPLE_DIET_RESTRICTIONS = [ const HACKER = "Hacker"; const VOLUNTEER = "Volunteer"; -const STAFF = "Staff"; +const ADMIN = "Admin"; const SPONSOR = "Sponsor"; const SPONSOR_T1 = "SponsorT1"; @@ -77,10 +77,10 @@ POST_ROLES[SPONSOR_T3] = "postSponsor"; POST_ROLES[SPONSOR_T4] = "postSponsor"; POST_ROLES[SPONSOR_T5] = "postSponsor"; POST_ROLES[VOLUNTEER] = "postVolunteer"; -POST_ROLES[STAFF] = "postStaff"; +POST_ROLES[ADMIN] = "postAdmin"; const SHIRT_SIZES = ["XS", "S", "M", "L", "XL", "XXL"]; -const USER_TYPES = [HACKER, VOLUNTEER, STAFF, SPONSOR]; +const USER_TYPES = [HACKER, VOLUNTEER, ADMIN, SPONSOR]; const SPONSOR_TIERS = [ SPONSOR_T1, SPONSOR_T2, @@ -91,7 +91,7 @@ const SPONSOR_TIERS = [ const EXTENDED_USER_TYPES = [ HACKER, VOLUNTEER, - STAFF, + ADMIN, SPONSOR_T1, SPONSOR_T2, SPONSOR_T3, @@ -138,8 +138,8 @@ CREATE_ACC_EMAIL_SUBJECTS[ VOLUNTEER ] = `You've been invited to create a volunteer account for ${HACKATHON_NAME}`; CREATE_ACC_EMAIL_SUBJECTS[ - STAFF -] = `You've been invited to create a staff account for ${HACKATHON_NAME}`; + ADMIN +] = `You've been invited to create an admin account for ${HACKATHON_NAME}`; const CACHE_TIMEOUT_STATS = 5 * 60 * 1000; const CACHE_KEY_STATS = "hackerStats"; @@ -171,7 +171,7 @@ module.exports = { HACKER: HACKER, SPONSOR: SPONSOR, VOLUNTEER: VOLUNTEER, - STAFF: STAFF, + ADMIN: ADMIN, SPONSOR_T1: SPONSOR_T1, SPONSOR_T2: SPONSOR_T2, SPONSOR_T3: SPONSOR_T3, diff --git a/constants/role.constant.js b/constants/role.constant.js index b2f00147..525fed34 100644 --- a/constants/role.constant.js +++ b/constants/role.constant.js @@ -22,7 +22,7 @@ const accountRole = { const adminRole = { _id: mongoose.Types.ObjectId.createFromTime(1), - name: Constants.General.STAFF, + name: Constants.General.ADMIN, routes: Constants.Routes.listAllRoutes() }; diff --git a/constants/routes.constant.js b/constants/routes.constant.js index e22e1d28..724befe9 100644 --- a/constants/routes.constant.js +++ b/constants/routes.constant.js @@ -229,7 +229,7 @@ const searchRoutes = { } }; -const staffRoutes = { +const adminRoutes = { hackerStats: { requestType: Constants.REQUEST_TYPES.GET, uri: "/api/hacker/stats" @@ -265,7 +265,7 @@ const allRoutes = { Role: roleRoutes, Search: searchRoutes, Settings: settingsRoutes, - Staff: staffRoutes + Admin: adminRoutes }; /** @@ -304,7 +304,7 @@ module.exports = { roleRoutes: roleRoutes, searchRoutes: searchRoutes, settingsRoutes: settingsRoutes, - staffRoutes: staffRoutes, + adminRoutes: adminRoutes, allRoutes: allRoutes, listAllRoutes: listAllRoutes }; diff --git a/docs/api/api_data.js b/docs/api/api_data.js index b88c32e5..411caa90 100644 --- a/docs/api/api_data.js +++ b/docs/api/api_data.js @@ -930,7 +930,7 @@ define({ { title: "Success-Response:", content: - '{"message": "Sucessfully retrieved all roles", "data":\n[{name: "GodStaff", routes: Array(27), id: "5bee20ef3ca9dd4754382880"},\n {name: "Hacker", routes: Array(10), id: "5bee20ef3ca9dd4754382881"},\n {name: "Volunteer", routes: Array(4), id: "5bee20ef3ca9dd4754382882"}]', + '{"message": "Sucessfully retrieved all roles", "data":\n[{name: "GodAdmin", routes: Array(27), id: "5bee20ef3ca9dd4754382880"},\n {name: "Hacker", routes: Array(10), id: "5bee20ef3ca9dd4754382881"},\n {name: "Volunteer", routes: Array(4), id: "5bee20ef3ca9dd4754382882"}]', type: "json" } ] diff --git a/docs/api/api_data.json b/docs/api/api_data.json index a759f28e..b09d3a76 100644 --- a/docs/api/api_data.json +++ b/docs/api/api_data.json @@ -939,7 +939,7 @@ "examples": [ { "title": "Success-Response:", - "content": "{\"message\": \"Sucessfully retrieved all roles\", \"data\":\n[{name: \"GodStaff\", routes: Array(27), id: \"5bee20ef3ca9dd4754382880\"},\n {name: \"Hacker\", routes: Array(10), id: \"5bee20ef3ca9dd4754382881\"},\n {name: \"Volunteer\", routes: Array(4), id: \"5bee20ef3ca9dd4754382882\"}]", + "content": "{\"message\": \"Sucessfully retrieved all roles\", \"data\":\n[{name: \"GodAdmin\", routes: Array(27), id: \"5bee20ef3ca9dd4754382880\"},\n {name: \"Hacker\", routes: Array(10), id: \"5bee20ef3ca9dd4754382881\"},\n {name: \"Volunteer\", routes: Array(4), id: \"5bee20ef3ca9dd4754382882\"}]", "type": "json" } ] diff --git a/docs/index.md b/docs/index.md index 6545133f..207c59ee 100644 --- a/docs/index.md +++ b/docs/index.md @@ -56,7 +56,7 @@ HackerAPI │ ├── role.model.js │ ├── roleBinding.model.js │   ├── sponsor.model.js Schema for sponsor account. -│   ├── staff.model.js Schema for staff members (not volunteers) +│   ├── admin.model.js Schema for admin members (not volunteers) │   ├── team.model.js Schema for a hacker team. │   └── volunteer.model.js Schema for volunteers on the day-of ├── package-lock.json @@ -95,7 +95,7 @@ HackerAPI ├── bus.test.util.js ├── hacker.test.util.js ├── sponsor.test.util.js - ├── staff.test.util.js + ├── admin.test.util.js ├── team.test.util.js └── volunteer.test.util.js ``` \ No newline at end of file diff --git a/docs/standards.md b/docs/standards.md index 9b29cd0e..9b90c31b 100644 --- a/docs/standards.md +++ b/docs/standards.md @@ -406,7 +406,7 @@ This script expects python3, and will not work in python2. Before you run the sc Then, run the following command: ```python3 batch_scripts.py``` -In order for the script to work with all of the actions, you must have a staff account. Otherwise, it's possible that you do not have the proper permission to execute all of the actions. +In order for the script to work with all of the actions, you must have an admin account. Otherwise, it's possible that you do not have the proper permission to execute all of the actions. ### Existing Actions in the Script file @@ -419,7 +419,7 @@ There are 6 batch actions: 5. `inviteUsers`: Invites a set of emails to create accounts. The script asks for a CSV file, which should be formatted in the following way: | email | accountType | | ----------- | ----------- | - | foo@bar.com | Staff | + | foo@bar.com | Admin | | baz@bar.com | Sponsor | 6. `getHackers`: Downloads all of the hacker details whose status matches the inputted status. Places the hacker information into a CSV file in the inputted directory. diff --git a/models/staff.model.js b/models/admin.model.js similarity index 70% rename from models/staff.model.js rename to models/admin.model.js index 9a7d22f8..cbd630ed 100644 --- a/models/staff.model.js +++ b/models/admin.model.js @@ -1,7 +1,7 @@ "use strict"; const mongoose = require("mongoose"); //describes the data type -const StaffSchema = new mongoose.Schema({ +const AdminSchema = new mongoose.Schema({ accountId: { type: mongoose.Schema.Types.ObjectId, ref: "Account", @@ -9,7 +9,7 @@ const StaffSchema = new mongoose.Schema({ } }); -StaffSchema.methods.toJSON = function() { +AdminSchema.methods.toJSON = function() { const ss = this.toObject(); delete ss.__v; ss.id = ss._id; @@ -17,4 +17,4 @@ StaffSchema.methods.toJSON = function() { return ss; }; //export the model -module.exports = mongoose.model("Staff", StaffSchema); +module.exports = mongoose.model("Admin", AdminSchema); diff --git a/routes/api/auth.js b/routes/api/auth.js index d81ee311..73b36bd1 100644 --- a/routes/api/auth.js +++ b/routes/api/auth.js @@ -294,7 +294,7 @@ module.exports = { * @apiSuccess {object} data empty * @apiSuccessExample {json} Success-Response: * {"message": "Sucessfully retrieved all roles", "data": - * [{name: "GodStaff", routes: Array(27), id: "5bee20ef3ca9dd4754382880"}, + * [{name: "GodAdmin", routes: Array(27), id: "5bee20ef3ca9dd4754382880"}, * {name: "Hacker", routes: Array(10), id: "5bee20ef3ca9dd4754382881"}, * {name: "Volunteer", routes: Array(4), id: "5bee20ef3ca9dd4754382882"}] * diff --git a/services/accountConfirmation.service.js b/services/accountConfirmation.service.js index 09c0ed5f..c7aceed1 100644 --- a/services/accountConfirmation.service.js +++ b/services/accountConfirmation.service.js @@ -175,8 +175,8 @@ function generateAccountInvitationEmail(address, receiverEmail, type, token) { emailSubject = Constants.CREATE_ACC_EMAIL_SUBJECTS[Constants.VOLUNTEER]; } else if (Constants.SPONSOR_TIERS.includes(type)) { emailSubject = Constants.CREATE_ACC_EMAIL_SUBJECTS[Constants.SPONSOR]; - } else if (type === Constants.STAFF) { - emailSubject = Constants.CREATE_ACC_EMAIL_SUBJECTS[Constants.STAFF]; + } else if (type === Constants.ADMIN) { + emailSubject = Constants.CREATE_ACC_EMAIL_SUBJECTS[Constants.ADMIN]; } const handlebarPath = path.join( __dirname, diff --git a/tests/account.test.js b/tests/account.test.js index 467f4101..31a3f45c 100644 --- a/tests/account.test.js +++ b/tests/account.test.js @@ -24,7 +24,7 @@ const confirmationToken = util.accountConfirmation.ConfirmationToken; const fakeToken = util.accountConfirmation.FakeToken; const resetToken = util.reset.ResetToken; // accounts -const Admin0 = util.account.staffAccounts.stored[0]; +const Admin0 = util.account.adminAccounts.stored[0]; const teamHackerAccount0 = util.account.hackerAccounts.stored.team[0]; //This account has a confirmation token in the db diff --git a/tests/hacker.test.js b/tests/hacker.test.js index 4ad47f27..29b44640 100644 --- a/tests/hacker.test.js +++ b/tests/hacker.test.js @@ -22,7 +22,7 @@ const util = { }; const StorageService = require("../services/storage.service"); -const Admin0 = util.account.staffAccounts.stored[0]; +const Admin0 = util.account.adminAccounts.stored[0]; const volunteerAccount0 = util.account.volunteerAccounts.stored[0]; diff --git a/tests/role.test.js b/tests/role.test.js index 43298793..503b8381 100644 --- a/tests/role.test.js +++ b/tests/role.test.js @@ -18,11 +18,11 @@ const Constants = { Success: require("../constants/success.constant") }; -const Admin0 = util.account.staffAccounts.stored[0]; +const Admin0 = util.account.adminAccounts.stored[0]; const Hacker0 = util.account.hackerAccounts.stored.team[0]; describe("POST create role", function() { - it("should Fail to create a role because staff is not logged in", function(done) { + it("should Fail to create a role because admin is not logged in", function(done) { chai.request(server.app) .post(`/api/role/`) .type("application/json") diff --git a/tests/search.service.spec.js b/tests/search.service.spec.js index 0495c1a2..8bf5c6ec 100644 --- a/tests/search.service.spec.js +++ b/tests/search.service.spec.js @@ -44,7 +44,7 @@ const badQuery = [ } ]; -const Admin0 = util.account.staffAccounts.stored[0]; +const Admin0 = util.account.adminAccounts.stored[0]; const noTeamHackerAccount0 = util.account.hackerAccounts.stored.noTeam[0]; @@ -141,7 +141,7 @@ describe("Searching for hackers", function() { }); }); - it("Should return an error as staff aren't searchable", function(done) { + it("Should return an error as admin aren't searchable", function(done) { util.auth.login(agent, Admin0, (error) => { if (error) { agent.close(); @@ -150,7 +150,7 @@ describe("Searching for hackers", function() { return agent .get("/api/search") .query({ - model: "staff", + model: "admin", q: JSON.stringify(badQuery) }) .end(function(err, res) { diff --git a/tests/settings.test.js b/tests/settings.test.js index f456a4a4..cc733764 100644 --- a/tests/settings.test.js +++ b/tests/settings.test.js @@ -16,7 +16,7 @@ const Constants = { }; const invalidAccount = util.account.hackerAccounts.stored.noTeam[0]; -const Admin = util.account.staffAccounts.stored[0]; +const Admin = util.account.adminAccounts.stored[0]; describe("GET settings", function() { it("should get the current settings", function(done) { diff --git a/tests/setup.spec.js b/tests/setup.spec.js index fd04be3b..5ee2f1ab 100644 --- a/tests/setup.spec.js +++ b/tests/setup.spec.js @@ -10,7 +10,7 @@ const Util = { RoleBinding: require("./util/roleBinding.test.util"), Settings: require("./util/settings.test.util"), Sponsor: require("./util/sponsor.test.util"), - Staff: require("./util/staff.test.util"), + Admin: require("./util/admin.test.util"), Team: require("./util/team.test.util"), Volunteer: require("./util/volunteer.test.util"), AccountConfirmation: require("./util/accountConfirmation.test.util"), @@ -62,7 +62,7 @@ async function storeAll() { await Util.Hacker.storeAll(); await Util.Sponsor.storeAll(); await Util.Team.storeAll(); - await Util.Staff.storeAll(); + await Util.Admin.storeAll(); await Util.AccountConfirmation.storeAll(); await Util.ResetPassword.storeAll(); await Util.Bus.storeAll(); @@ -78,7 +78,7 @@ async function dropAll() { await Util.AccountConfirmation.dropAll(); await Util.Volunteer.dropAll(); await Util.Settings.dropAll(); - await Util.Staff.dropAll(); + await Util.Admin.dropAll(); await Util.Team.dropAll(); await Util.Sponsor.dropAll(); await Util.Bus.dropAll(); diff --git a/tests/sponsor.test.js b/tests/sponsor.test.js index e48d1076..5f478ad5 100644 --- a/tests/sponsor.test.js +++ b/tests/sponsor.test.js @@ -18,7 +18,7 @@ const util = { account: require("./util/account.test.util") }; -const Admin0 = util.account.staffAccounts.stored[0]; +const Admin0 = util.account.adminAccounts.stored[0]; const HackerAccount0 = util.account.hackerAccounts.stored.team[0]; const T1SponsorAccount0 = util.account.sponsorT1Accounts.stored[0]; const newT2SponsorAccount0 = util.account.sponsorT2Accounts.new[0]; diff --git a/tests/team.test.js b/tests/team.test.js index b95d5575..12427690 100644 --- a/tests/team.test.js +++ b/tests/team.test.js @@ -20,7 +20,7 @@ const Constants = { const agent = chai.request.agent(server.app); -const Admin0 = util.account.staffAccounts.stored[0]; +const Admin0 = util.account.adminAccounts.stored[0]; const teamHackerAccount0 = util.account.hackerAccounts.stored.team[0]; const noTeamHackerAccount0 = util.account.hackerAccounts.stored.noTeam[0]; const sponsorT1Account0 = util.account.sponsorT1Accounts.stored[0]; diff --git a/tests/util/account.test.util.js b/tests/util/account.test.util.js index 1b624821..b05af7cb 100644 --- a/tests/util/account.test.util.js +++ b/tests/util/account.test.util.js @@ -157,9 +157,9 @@ let volunteerAccounts = { }) }; -let staffAccounts = { +let adminAccounts = { stored: createNAccounts(5, { - accountType: Constants.STAFF, + accountType: Constants.ADMIN, confirmed: true }) }; @@ -314,7 +314,7 @@ const extraAccounts = [ module.exports = { hackerAccounts: hackerAccounts, volunteerAccounts: volunteerAccounts, - staffAccounts: staffAccounts, + adminAccounts: adminAccounts, sponsorT1Accounts: sponsorT1Accounts, sponsorT2Accounts: sponsorT2Accounts, sponsorT3Accounts: sponsorT3Accounts, @@ -357,7 +357,7 @@ async function storeAll() { await store(hackerAccounts.stored.noTeam); await store(hackerAccounts.stored.unconfirmed); await store(volunteerAccounts.stored); - await store(staffAccounts.stored); + await store(adminAccounts.stored); await store(sponsorT1Accounts.stored); await store(sponsorT2Accounts.stored); await store(sponsorT3Accounts.stored); diff --git a/tests/util/staff.test.util.js b/tests/util/admin.test.util.js similarity index 52% rename from tests/util/staff.test.util.js rename to tests/util/admin.test.util.js index 45867221..4ecf6266 100644 --- a/tests/util/staff.test.util.js +++ b/tests/util/admin.test.util.js @@ -2,37 +2,37 @@ const Util = { Account: require("./account.test.util") }; -const Staff = require("../../models/staff.model"); +const Admin = require("../../models/admin.model"); const mongoose = require("mongoose"); const logger = require("../../services/logger.service"); -const Staff0 = { +const Admin0 = { _id: mongoose.Types.ObjectId(), - accountId: Util.Account.staffAccounts.stored[0] + accountId: Util.Account.adminAccounts.stored[0] }; -const Staffs = [Staff0]; +const Admins = [Admin0]; function store(attributes) { - const staffDocs = []; - const staffIds = []; + const adminDocs = []; + const adminIds = []; attributes.forEach((attribute) => { - staffDocs.push(new Staff(attribute)); - staffIds.push(attribute._id); + adminDocs.push(new Admin(attribute)); + adminIds.push(attribute._id); }); - return Staff.collection.insertMany(staffDocs); + return Admin.collection.insertMany(adminDocs); } async function storeAll() { - await store(Staffs); + await store(Admins); } async function dropAll() { try { - await Staff.collection.drop(); + await Admin.collection.drop(); } catch (e) { if (e.code === 26) { - logger.info("namespace %s not found", Staff.collection.name); + logger.info("namespace %s not found", Admin.collection.name); } else { throw e; } @@ -40,8 +40,8 @@ async function dropAll() { } module.exports = { - Staff0: Staff0, - Staffs: Staffs, + Admin0: Admin0, + Admins: Admins, storeAll: storeAll, dropAll: dropAll }; diff --git a/tests/util/roleBinding.test.util.js b/tests/util/roleBinding.test.util.js index 56c566d6..7b5fba60 100644 --- a/tests/util/roleBinding.test.util.js +++ b/tests/util/roleBinding.test.util.js @@ -22,7 +22,7 @@ function createRoleBinding(accountId, accountType = null, specificRoles = []) { case Constants.General.VOLUNTEER: roleBinding.roles.push(Constants.Role.volunteerRole); break; - case Constants.General.STAFF: + case Constants.General.ADMIN: roleBinding.roles.push(Constants.Role.adminRole); break; case Constants.General.SPONSOR_T1: @@ -69,7 +69,7 @@ const UnconfirmedHackerRB = createRoleBindings( Util.Account.hackerAccounts.stored.unconfirmed ); const VolunteerRB = createRoleBindings(Util.Account.volunteerAccounts.stored); -const StaffRB = createRoleBindings(Util.Account.staffAccounts.stored); +const AdminRB = createRoleBindings(Util.Account.adminAccounts.stored); const SponsorT1RB = createRoleBindings(Util.Account.sponsorT1Accounts.stored); const SponsorT2RB = createRoleBindings(Util.Account.sponsorT2Accounts.stored); const SponsorT3RB = createRoleBindings(Util.Account.sponsorT3Accounts.stored); @@ -110,7 +110,7 @@ async function storeAll() { await store(NoTeamHackerRB); await store(UnconfirmedHackerRB); await store(VolunteerRB); - await store(StaffRB); + await store(AdminRB); await store(SponsorT1RB); await store(SponsorT2RB); await store(SponsorT3RB); @@ -145,7 +145,7 @@ module.exports = { NoTeamHackerRB: NoTeamHackerRB, UnconfirmedHackerRB: UnconfirmedHackerRB, VolunteerRB: VolunteerRB, - StaffRB: StaffRB, + AdminRB: AdminRB, SponsorT1RB: SponsorT1RB, SponsorT2RB: SponsorT2RB, SponsorT3RB: SponsorT3RB, diff --git a/tests/util/volunteer.test.util.js b/tests/util/volunteer.test.util.js index a8ef4903..760679b5 100644 --- a/tests/util/volunteer.test.util.js +++ b/tests/util/volunteer.test.util.js @@ -21,7 +21,7 @@ const Volunteer0 = { const invalidVolunteer0 = { _id: mongoose.Types.ObjectId(), - accountId: Util.Account.staffAccounts.stored[0]._id + accountId: Util.Account.adminAccounts.stored[0]._id }; const Volunteers = [Volunteer0]; diff --git a/tests/volunteer.test.js b/tests/volunteer.test.js index df42dbbc..77b8cfc1 100644 --- a/tests/volunteer.test.js +++ b/tests/volunteer.test.js @@ -17,7 +17,7 @@ const util = { auth: require("./util/auth.test.util") }; -const Admin0 = util.account.staffAccounts.stored[0]; +const Admin0 = util.account.adminAccounts.stored[0]; const HackerAccount0 = util.account.hackerAccounts.stored.team[0]; const VolunteerAccount0 = util.account.volunteerAccounts.stored[0];