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

Hotfix/fix project option #83

Merged
merged 2 commits into from
Jun 18, 2023
Merged
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
3 changes: 2 additions & 1 deletion src/controllers/option.bp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ async function doGetProjectOptions(projectId: string) {

const options = await Option.find({
option_parent: projectId,
delete: false
delete: false,
option_status: { $gte: 2 }
}).exec();

if (!options || options.length === 0) {
Expand Down
16 changes: 10 additions & 6 deletions src/controllers/project.bp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,16 @@ async function doGetProject(projectId: string) {
proposer_project: 1,
proposer_tax_id: 1
})
.populate("option", {
_id: 1,
option_name: 1,
option_price: 1,
option_content: 1,
option_cover: 1
.populate({
path: "option",
match: { option_status: { $gte: 2 } }, // 只關聯 option_status >= 2 的 option
select: {
_id: 1,
option_name: 1,
option_price: 1,
option_content: 1,
option_cover: 1
}
})
.populate("qas", {
_id: 1,
Expand Down
4 changes: 4 additions & 0 deletions src/controllers/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export const putOwnerProject: RequestHandler = async (
return next(createError(400, "找不到專案"));
}

await isUserProposer(userId, projectId);

// TODO: verify data

const project = await doPutOwnerProject(userId, projectId, data);
Expand All @@ -107,6 +109,8 @@ export const deleteOwnerProject: RequestHandler = async (
return next(createError(400, "找不到專案"));
}

await isUserProposer(userId, projectId);

const result = await doDeleteOwnerProject(userId, projectId);
return handleSuccess(res, result);
};
Expand Down
Loading