Skip to content

Commit

Permalink
Merge pull request #83 from rabbitfund/hotfix/fixProjectOption
Browse files Browse the repository at this point in the history
Hotfix/fix project option
  • Loading branch information
EstherDev2 committed Jun 18, 2023
2 parents b4dbebc + f8d8549 commit 2c6fbc3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
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

0 comments on commit 2c6fbc3

Please sign in to comment.