Skip to content

Commit

Permalink
Merge pull request #1928 from manyfold3d/fix-deletion-redirects
Browse files Browse the repository at this point in the history
Don't redirect back to deleted files or models
  • Loading branch information
Floppy authored Mar 4, 2024
2 parents aa87b6c + cf22ebf commit e6d6f03
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/controllers/model_files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ def bulk_update
def destroy
authorize @file
@file.delete_from_disk_and_destroy
redirect_back_or_to library_model_path(@library, @model), notice: t(".success")
if URI.parse(request.referer).path == library_model_model_file_path(@library, @model, @file)
# If we're coming from the file page itself, we can't go back there
redirect_to library_model_path(@library, @model), notice: t(".success")
else
redirect_back_or_to library_model_path(@library, @model), notice: t(".success")
end
end

private
Expand Down
7 changes: 6 additions & 1 deletion app/controllers/models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ def bulk_update
def destroy
authorize @model
@model.delete_from_disk_and_destroy
redirect_back_or_to library_path(@library), notice: t(".success")
if URI.parse(request.referer).path == library_model_path(@library, @model)
# If we're coming from the model page itself, we can't go back there
redirect_to library_path(@library), notice: t(".success")
else
redirect_back_or_to library_path(@library), notice: t(".success")
end
end

private
Expand Down

0 comments on commit e6d6f03

Please sign in to comment.