Uploaded image for project: 'BookBrainz'
  1. BookBrainz
  2. BB-458

It is possible to delete an already deleted entity

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: High High
    • None
    • None
    • Site Backend

      Although the 'delete' button is not clickable for a deleted entity, manually entering a `…/delete` route works.

      After re-deleting the entity, the name is no longer showing (the mechanism is to fetch the last know alias from the previous revision; in this case it'll be empty).

      Instead, there should be a check when hitting the /delete endpoint for the loaded entity's `dataId: if it's null (and hence a 'deleted' entity), throw an error (400 Bad Request? 409 Conflict ? )

      In more detail:
      Each entity type (author, work, edition, edition group, publisher, series) defines a "/delete" endpoint which we need to modify. Here's where you find them.
      The following modifications will need to be done for the /delete route of each entity, so modifying 6 files in total.

      We will need to check if the entity has already been deleted. We do that by checking if has a `dataId` attribute.
      When the delete route is called, the entity has already been automatically loaded into res.locals in a previous step, so we'll do:

      if(!res.locals.entity.dataId) {...
      

      If that condition is true, we want to return an error page to the user.
      We do this by calling the "next" function with our ConflictError object (this already exists but will need to be imported) like it is done here for example and with a nice user-friendly message along the lines of "This entity has already been deleted".

            shubh Shubham
            mr_monkey Monkey
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Version Package