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

endpoint for users to delete a project in draft status from DB #1519

Closed
divine-comedian opened this issue May 1, 2024 · 6 comments
Closed

Comments

@divine-comedian
Copy link
Collaborator

Related to Giveth/giveth-dapps-v2#1271 - Users should be able to delete a project they own in draft status from the DB.

We will need an endpoint for the front-end to call to trigger this action in our DB

@jainkrati
Copy link
Collaborator

@divine-comedian pls add priority

@mohammadranjbarz
Copy link
Collaborator

mohammadranjbarz commented Jul 30, 2024

@Reshzera Please take this issue, it's a straight forward issue and will help you to get more familiar with impact-graph.
You should implement a new endpoint in projectResolver for deleting draft projects from DB, and create a ProjectStatusHistory type to add a record on that for this purpose to can keep track of this activity

Please write test cases for below scenarios ( and if there is any scenario that I forgot to mention it, please implement them

  • Success scenario, project owner should can delete his/her project
  • Project owner should not be able to delete a project with non-draft status, especially write test cases for active (statusId : 5)
  • User should not be able to delete someone else's project
  • When deleting projects delete all related stuffs to the project like project_address,
    project_verification_form, project_udpate if exist
  • Make sure it creates a record in ProjectStatusHistory table

PS If you had any questions from me, feel free to ask it here or DM me

@Reshzera
Copy link
Contributor

Reshzera commented Aug 12, 2024

I've implemented the deleteDraftProject mutation. Please note that the endpoint for this mutation is now available. To call it, use the following mutation query:

mutation ($projectId: Float!) {
  deleteDraftProject(projectId: $projectId)
}

Make sure to pass the projectId as a Float in the mutation variables.

Logic Overview:

  1. User Authentication: The mutation ensures that the user attempting to delete the draft project is authenticated by retrieving the currently logged-in user.

  2. Project Existence: It checks whether the project with the provided projectId exists in the system. If the project does not exist, an error is thrown indicating that the project could not be found.

  3. Ownership Verification: The mutation verifies that the authenticated user is the owner of the project. If the user is not the owner (i.e., their user ID does not match the adminUserId of the project), an error is thrown to prevent unauthorized deletion.

  4. Draft Status Check: The mutation ensures that only projects with a status of drafted can be deleted. If the project is not in the draft status, an error is thrown indicating that only drafted projects can be deleted.

However, note that a ProjectStatusHistory record will not be created because, as I talked to @mohammadranjbarz the project will be deleted from the database, there won't be a projectId to reference for this record.

@Reshzera Reshzera reopened this Aug 12, 2024
@divine-comedian
Copy link
Collaborator Author

divine-comedian commented Aug 12, 2024

@Reshzera - since you moved this to QA is there a way for the QA to test this? if so can you please share any endpoint links or resources they might need

@Reshzera
Copy link
Contributor

Reshzera commented Aug 13, 2024

@divine-comedian I spoke with @mohammadranjbarz and I don't think there is an easy way to test this issue, so I'll tag the FE guys and wait they integrate this endpoint, so QA can test this in FE. In this case, is there a correct status for this issue?

@divine-comedian
Copy link
Collaborator Author

sure thing @Reshzera - please update here once the FE issue is approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

4 participants