Repository: bookwyrm-social/bookwyrm

Issue:
Internal Server Errors (e.g. on delete of user)
**Describe the bug**
Internal server error for some actions. I have set up a dockerless  installation and am able to access the application and the admin pages. However, some actions create errors.  For example: 

**To Reproduce**
Steps to reproduce the behavior:
1. Clicking delete user after providing admin password. Browser shows internal server error. Error in application is:

```
Internal Server Error: /settings/reports/2/delete
Traceback (most recent call last):
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/core/handlers/base.py", line 204, in _get_response
    response = response.render()
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py", line 81, in rendered_content
    template = self.resolve_template(self.template_name)
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/response.py", line 65, in resolve_template
    return get_template(template, using=self.using)
  File "/opt/bookwyrm/venv/lib/python3.10/site-packages/django/template/loader.py", line 19, in get_template
    raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: user_admin/user.html
```




Discussion:
This is a silly error on my part -- I need to write a unit test as well as fix it. It's just the wrong template path. Thank you!

Resolving patch:
diff --git a/bookwyrm/views/admin/reports.py b/bookwyrm/views/admin/reports.py
--- a/bookwyrm/views/admin/reports.py
+++ b/bookwyrm/views/admin/reports.py
@@ -128,7 +128,7 @@ def moderator_delete_user(request, user_id):
     form.errors["password"] = ["Invalid password"]
 
     data = {"user": user, "group_form": forms.UserGroupForm(), "form": form}
-    return TemplateResponse(request, "user_admin/user.html", data)
+    return TemplateResponse(request, "settings/users/user.html", data)
 
 
 @login_required


Test patch:
diff --git a/bookwyrm/tests/views/admin/test_reports.py b/bookwyrm/tests/views/admin/test_reports.py
--- a/bookwyrm/tests/views/admin/test_reports.py
+++ b/bookwyrm/tests/views/admin/test_reports.py
@@ -15,6 +15,7 @@
 class ReportViews(TestCase):
     """every response to a get request, html or json"""
 
+    # pylint: disable=invalid-name
     def setUp(self):
         """we need basic test data and mocks"""
         self.factory = RequestFactory()
@@ -147,3 +148,16 @@ def test_delete_user(self, *_):
         self.rat.refresh_from_db()
         self.assertFalse(self.rat.is_active)
         self.assertEqual(self.rat.deactivation_reason, "moderator_deletion")
+
+    def test_delete_user_error(self, *_):
+        """toggle whether a user is able to log in"""
+        self.assertTrue(self.rat.is_active)
+        request = self.factory.post("", {"password": "wrong password"})
+        request.user = self.local_user
+
+        result = views.moderator_delete_user(request, self.rat.id)
+        self.assertIsInstance(result, TemplateResponse)
+        validate_html(result.render())
+
+        self.rat.refresh_from_db()
+        self.assertTrue(self.rat.is_active)