Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed instances of staff to admin #616

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions constants/general.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand All @@ -91,7 +91,7 @@ const SPONSOR_TIERS = [
const EXTENDED_USER_TYPES = [
HACKER,
VOLUNTEER,
STAFF,
ADMIN,
SPONSOR_T1,
SPONSOR_T2,
SPONSOR_T3,
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion constants/role.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
};

Expand Down
6 changes: 3 additions & 3 deletions constants/routes.constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const searchRoutes = {
}
};

const staffRoutes = {
const adminRoutes = {
hackerStats: {
requestType: Constants.REQUEST_TYPES.GET,
uri: "/api/hacker/stats"
Expand Down Expand Up @@ -265,7 +265,7 @@ const allRoutes = {
Role: roleRoutes,
Search: searchRoutes,
Settings: settingsRoutes,
Staff: staffRoutes
Admin: adminRoutes
};

/**
Expand Down Expand Up @@ -304,7 +304,7 @@ module.exports = {
roleRoutes: roleRoutes,
searchRoutes: searchRoutes,
settingsRoutes: settingsRoutes,
staffRoutes: staffRoutes,
adminRoutes: adminRoutes,
allRoutes: allRoutes,
listAllRoutes: listAllRoutes
};
2 changes: 1 addition & 1 deletion docs/api/api_data.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
Expand Down
2 changes: 1 addition & 1 deletion docs/api/api_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
]
Expand Down
4 changes: 2 additions & 2 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
```
4 changes: 2 additions & 2 deletions docs/standards.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 |
| ----------- | ----------- |
| [email protected] | Staff |
| [email protected] | Admin |
| [email protected] | 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.

Expand Down
6 changes: 3 additions & 3 deletions models/staff.model.js → models/admin.model.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"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",
required: true
}
});

StaffSchema.methods.toJSON = function() {
AdminSchema.methods.toJSON = function() {
const ss = this.toObject();
delete ss.__v;
ss.id = ss._id;
delete ss._id;
return ss;
};
//export the model
module.exports = mongoose.model("Staff", StaffSchema);
module.exports = mongoose.model("Admin", AdminSchema);
2 changes: 1 addition & 1 deletion routes/api/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"}]
*
Expand Down
4 changes: 2 additions & 2 deletions services/accountConfirmation.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/account.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/hacker.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
4 changes: 2 additions & 2 deletions tests/role.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions tests/search.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion tests/settings.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions tests/setup.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/sponsor.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
2 changes: 1 addition & 1 deletion tests/team.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
8 changes: 4 additions & 4 deletions tests/util/account.test.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ let volunteerAccounts = {
})
};

let staffAccounts = {
let adminAccounts = {
stored: createNAccounts(5, {
accountType: Constants.STAFF,
accountType: Constants.ADMIN,
confirmed: true
})
};
Expand Down Expand Up @@ -314,7 +314,7 @@ const extraAccounts = [
module.exports = {
hackerAccounts: hackerAccounts,
volunteerAccounts: volunteerAccounts,
staffAccounts: staffAccounts,
adminAccounts: adminAccounts,
sponsorT1Accounts: sponsorT1Accounts,
sponsorT2Accounts: sponsorT2Accounts,
sponsorT3Accounts: sponsorT3Accounts,
Expand Down Expand Up @@ -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);
Expand Down
28 changes: 14 additions & 14 deletions tests/util/staff.test.util.js → tests/util/admin.test.util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,46 @@
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;
}
}
}

module.exports = {
Staff0: Staff0,
Staffs: Staffs,
Admin0: Admin0,
Admins: Admins,
storeAll: storeAll,
dropAll: dropAll
};
Loading