We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Implement 'Shares'
## Issues
- [x] https://github.com/centerofci/mathesar/issues/3033
- [x] https://github.com/centerofci/mathesar/issues/3034
- [x] https://github.com/centerofci/mathesar/issues/3035
- [x] https://github.com/centerofci/mathesar/issues/3036

## Tasks:
- [ ] Add regenerate slug endpoints

### https://github.com/centerofci/mathesar/pull/3093#pullrequestreview-1546069582
- [ ] Address the following in shared table consumer page
   - [ ] Disable re-reordering of columns
   - [ ] Don't show the icon hyperlink to the record page within the PK cell
   - [ ] Remove the following entries in the cell context menu:
       - "Set to NULL"
       - "Go to Record Page"
       - "Go to Linked Record" (shown only for FK columns)
   - [ ] Remove the "Go to Record Page" entry from the row header context menu
   - [ ] Disable record selector in filtering for FK columns
- [ ] Come up with a better term for 'ShareConsumer'. Some suggestions:
    - ShareAccessInfo
    - SharedLink
    - ConsumableShare

## Related:
* [Product spec](https://wiki.mathesar.org/en/product/specs/publicly-shareable-links)

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `mathesar/api/ui/viewsets/shares.py`
Content:
```
1 from rest_framework import viewsets
2 from rest_access_policy import AccessViewSetMixin
3 
4 from mathesar.api.pagination import DefaultLimitOffsetPagination
5 from mathesar.api.ui.serializers.shares import SharedTableSerializer, SharedQuerySerializer
6 from mathesar.api.ui.permissions.shares import SharedTableAccessPolicy, SharedQueryAccessPolicy
7 from mathesar.models.shares import SharedTable, SharedQuery
8 
9 
10 class SharedTableViewSet(AccessViewSetMixin, viewsets.ModelViewSet):
11     pagination_class = DefaultLimitOffsetPagination
12     serializer_class = SharedTableSerializer
13     access_policy = SharedTableAccessPolicy
14 
15     def get_queryset(self):
16         return SharedTable.objects.filter(table_id=self.kwargs['table_pk']).order_by('-created_at')
17 
18     def perform_create(self, serializer):
19         serializer.save(table_id=self.kwargs['table_pk'])
20 
21 
22 class SharedQueryViewSet(AccessViewSetMixin, viewsets.ModelViewSet):
23     pagination_class = DefaultLimitOffsetPagination
24     serializer_class = SharedQuerySerializer
25     access_policy = SharedQueryAccessPolicy
26 
27     def get_queryset(self):
28         return SharedQuery.objects.filter(query_id=self.kwargs['query_pk']).order_by('-created_at')
29 
30     def perform_create(self, serializer):
31         serializer.save(query_id=self.kwargs['query_pk'])
32
```

Path: `mathesar/api/ui/permissions/shares.py`
Content:
```
1 from rest_access_policy import AccessPolicy
2 
3 from mathesar.api.utils import get_query_or_404
4 from mathesar.api.permission_utils import QueryAccessInspector
5 
6 
7 class SharedTableAccessPolicy(AccessPolicy):
8     statements = [
9         {
10             'action': ['list', 'retrieve'],
11             'principal': 'authenticated',
12             'effect': 'allow',
13             'condition_expression': 'is_atleast_viewer_nested_table_resource'
14         },
15         {
16             'action': ['create', 'destroy', 'update', 'partial_update'],
17             'principal': 'authenticated',
18             'effect': 'allow',
19             'condition_expression': 'is_atleast_editor_nested_table_resource'
20         },
21     ]
22 
23 
24 class SharedQueryAccessPolicy(AccessPolicy):
25     statements = [
26         {
27             'action': ['list', 'retrieve'],
28             'principal': 'authenticated',
29             'effect': 'allow',
30             'condition_expression': 'is_atleast_query_viewer'
31         },
32         {
33             'action': ['create', 'destroy', 'update', 'partial_update'],
34             'principal': 'authenticated',
35             'effect': 'allow',
36             'condition_expression': 'is_atleast_query_editor'
37         },
38     ]
39 
40     def is_atleast_query_viewer(self, request, view, action):
41         query = get_query_or_404(view.kwargs['query_pk'])
42         return QueryAccessInspector(request.user, query).is_atleast_viewer()
43 
44     def is_atleast_query_editor(self, request, view, action):
45         query = get_query_or_404(view.kwargs['query_pk'])
46         return QueryAccessInspector(request.user, query).is_atleast_editor()
47
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/mathesar/api/ui/permissions/shares.py b/mathesar/api/ui/permissions/shares.py
--- a/mathesar/api/ui/permissions/shares.py
+++ b/mathesar/api/ui/permissions/shares.py
@@ -13,7 +13,7 @@
             'condition_expression': 'is_atleast_viewer_nested_table_resource'
         },
         {
-            'action': ['create', 'destroy', 'update', 'partial_update'],
+            'action': ['create', 'destroy', 'update', 'partial_update', 'regenerate'],
             'principal': 'authenticated',
             'effect': 'allow',
             'condition_expression': 'is_atleast_editor_nested_table_resource'
@@ -30,7 +30,7 @@
             'condition_expression': 'is_atleast_query_viewer'
         },
         {
-            'action': ['create', 'destroy', 'update', 'partial_update'],
+            'action': ['create', 'destroy', 'update', 'partial_update', 'regenerate'],
             'principal': 'authenticated',
             'effect': 'allow',
             'condition_expression': 'is_atleast_query_editor'
diff --git a/mathesar/api/ui/viewsets/shares.py b/mathesar/api/ui/viewsets/shares.py
--- a/mathesar/api/ui/viewsets/shares.py
+++ b/mathesar/api/ui/viewsets/shares.py
@@ -1,5 +1,8 @@
+import uuid
 from rest_framework import viewsets
 from rest_access_policy import AccessViewSetMixin
+from rest_framework.decorators import action
+from rest_framework.response import Response
 
 from mathesar.api.pagination import DefaultLimitOffsetPagination
 from mathesar.api.ui.serializers.shares import SharedTableSerializer, SharedQuerySerializer
@@ -7,7 +10,17 @@
 from mathesar.models.shares import SharedTable, SharedQuery
 
 
-class SharedTableViewSet(AccessViewSetMixin, viewsets.ModelViewSet):
+class RegenerateSlugMixin(viewsets.GenericViewSet):
+    @action(methods=['post'], detail=True)
+    def regenerate(self, *args, **kwargs):
+        share = self.get_object()
+        share.slug = uuid.uuid4()
+        share.save()
+        serializer = self.get_serializer(share)
+        return Response(serializer.data)
+
+
+class SharedTableViewSet(AccessViewSetMixin, viewsets.ModelViewSet, RegenerateSlugMixin):
     pagination_class = DefaultLimitOffsetPagination
     serializer_class = SharedTableSerializer
     access_policy = SharedTableAccessPolicy
@@ -19,7 +32,7 @@
         serializer.save(table_id=self.kwargs['table_pk'])
 
 
-class SharedQueryViewSet(AccessViewSetMixin, viewsets.ModelViewSet):
+class SharedQueryViewSet(AccessViewSetMixin, viewsets.ModelViewSet, RegenerateSlugMixin):
     pagination_class = DefaultLimitOffsetPagination
     serializer_class = SharedQuerySerializer
     access_policy = SharedQueryAccessPolicy

{"golden_diff": "diff --git a/mathesar/api/ui/permissions/shares.py b/mathesar/api/ui/permissions/shares.py\n--- a/mathesar/api/ui/permissions/shares.py\n+++ b/mathesar/api/ui/permissions/shares.py\n@@ -13,7 +13,7 @@\n             'condition_expression': 'is_atleast_viewer_nested_table_resource'\n         },\n         {\n-            'action': ['create', 'destroy', 'update', 'partial_update'],\n+            'action': ['create', 'destroy', 'update', 'partial_update', 'regenerate'],\n             'principal': 'authenticated',\n             'effect': 'allow',\n             'condition_expression': 'is_atleast_editor_nested_table_resource'\n@@ -30,7 +30,7 @@\n             'condition_expression': 'is_atleast_query_viewer'\n         },\n         {\n-            'action': ['create', 'destroy', 'update', 'partial_update'],\n+            'action': ['create', 'destroy', 'update', 'partial_update', 'regenerate'],\n             'principal': 'authenticated',\n             'effect': 'allow',\n             'condition_expression': 'is_atleast_query_editor'\ndiff --git a/mathesar/api/ui/viewsets/shares.py b/mathesar/api/ui/viewsets/shares.py\n--- a/mathesar/api/ui/viewsets/shares.py\n+++ b/mathesar/api/ui/viewsets/shares.py\n@@ -1,5 +1,8 @@\n+import uuid\n from rest_framework import viewsets\n from rest_access_policy import AccessViewSetMixin\n+from rest_framework.decorators import action\n+from rest_framework.response import Response\n \n from mathesar.api.pagination import DefaultLimitOffsetPagination\n from mathesar.api.ui.serializers.shares import SharedTableSerializer, SharedQuerySerializer\n@@ -7,7 +10,17 @@\n from mathesar.models.shares import SharedTable, SharedQuery\n \n \n-class SharedTableViewSet(AccessViewSetMixin, viewsets.ModelViewSet):\n+class RegenerateSlugMixin(viewsets.GenericViewSet):\n+    @action(methods=['post'], detail=True)\n+    def regenerate(self, *args, **kwargs):\n+        share = self.get_object()\n+        share.slug = uuid.uuid4()\n+        share.save()\n+        serializer = self.get_serializer(share)\n+        return Response(serializer.data)\n+\n+\n+class SharedTableViewSet(AccessViewSetMixin, viewsets.ModelViewSet, RegenerateSlugMixin):\n     pagination_class = DefaultLimitOffsetPagination\n     serializer_class = SharedTableSerializer\n     access_policy = SharedTableAccessPolicy\n@@ -19,7 +32,7 @@\n         serializer.save(table_id=self.kwargs['table_pk'])\n \n \n-class SharedQueryViewSet(AccessViewSetMixin, viewsets.ModelViewSet):\n+class SharedQueryViewSet(AccessViewSetMixin, viewsets.ModelViewSet, RegenerateSlugMixin):\n     pagination_class = DefaultLimitOffsetPagination\n     serializer_class = SharedQuerySerializer\n     access_policy = SharedQueryAccessPolicy\n", "issue": "Implement 'Shares'\n## Issues\r\n- [x] https://github.com/centerofci/mathesar/issues/3033\r\n- [x] https://github.com/centerofci/mathesar/issues/3034\r\n- [x] https://github.com/centerofci/mathesar/issues/3035\r\n- [x] https://github.com/centerofci/mathesar/issues/3036\r\n\r\n## Tasks:\r\n- [ ] Add regenerate slug endpoints\r\n\r\n### https://github.com/centerofci/mathesar/pull/3093#pullrequestreview-1546069582\r\n- [ ] Address the following in shared table consumer page\r\n   - [ ] Disable re-reordering of columns\r\n   - [ ] Don't show the icon hyperlink to the record page within the PK cell\r\n   - [ ] Remove the following entries in the cell context menu:\r\n       - \"Set to NULL\"\r\n       - \"Go to Record Page\"\r\n       - \"Go to Linked Record\" (shown only for FK columns)\r\n   - [ ] Remove the \"Go to Record Page\" entry from the row header context menu\r\n   - [ ] Disable record selector in filtering for FK columns\r\n- [ ] Come up with a better term for 'ShareConsumer'. Some suggestions:\r\n    - ShareAccessInfo\r\n    - SharedLink\r\n    - ConsumableShare\r\n\r\n## Related:\r\n* [Product spec](https://wiki.mathesar.org/en/product/specs/publicly-shareable-links)\n", "before_files": [{"content": "from rest_framework import viewsets\nfrom rest_access_policy import AccessViewSetMixin\n\nfrom mathesar.api.pagination import DefaultLimitOffsetPagination\nfrom mathesar.api.ui.serializers.shares import SharedTableSerializer, SharedQuerySerializer\nfrom mathesar.api.ui.permissions.shares import SharedTableAccessPolicy, SharedQueryAccessPolicy\nfrom mathesar.models.shares import SharedTable, SharedQuery\n\n\nclass SharedTableViewSet(AccessViewSetMixin, viewsets.ModelViewSet):\n    pagination_class = DefaultLimitOffsetPagination\n    serializer_class = SharedTableSerializer\n    access_policy = SharedTableAccessPolicy\n\n    def get_queryset(self):\n        return SharedTable.objects.filter(table_id=self.kwargs['table_pk']).order_by('-created_at')\n\n    def perform_create(self, serializer):\n        serializer.save(table_id=self.kwargs['table_pk'])\n\n\nclass SharedQueryViewSet(AccessViewSetMixin, viewsets.ModelViewSet):\n    pagination_class = DefaultLimitOffsetPagination\n    serializer_class = SharedQuerySerializer\n    access_policy = SharedQueryAccessPolicy\n\n    def get_queryset(self):\n        return SharedQuery.objects.filter(query_id=self.kwargs['query_pk']).order_by('-created_at')\n\n    def perform_create(self, serializer):\n        serializer.save(query_id=self.kwargs['query_pk'])\n", "path": "mathesar/api/ui/viewsets/shares.py"}, {"content": "from rest_access_policy import AccessPolicy\n\nfrom mathesar.api.utils import get_query_or_404\nfrom mathesar.api.permission_utils import QueryAccessInspector\n\n\nclass SharedTableAccessPolicy(AccessPolicy):\n    statements = [\n        {\n            'action': ['list', 'retrieve'],\n            'principal': 'authenticated',\n            'effect': 'allow',\n            'condition_expression': 'is_atleast_viewer_nested_table_resource'\n        },\n        {\n            'action': ['create', 'destroy', 'update', 'partial_update'],\n            'principal': 'authenticated',\n            'effect': 'allow',\n            'condition_expression': 'is_atleast_editor_nested_table_resource'\n        },\n    ]\n\n\nclass SharedQueryAccessPolicy(AccessPolicy):\n    statements = [\n        {\n            'action': ['list', 'retrieve'],\n            'principal': 'authenticated',\n            'effect': 'allow',\n            'condition_expression': 'is_atleast_query_viewer'\n        },\n        {\n            'action': ['create', 'destroy', 'update', 'partial_update'],\n            'principal': 'authenticated',\n            'effect': 'allow',\n            'condition_expression': 'is_atleast_query_editor'\n        },\n    ]\n\n    def is_atleast_query_viewer(self, request, view, action):\n        query = get_query_or_404(view.kwargs['query_pk'])\n        return QueryAccessInspector(request.user, query).is_atleast_viewer()\n\n    def is_atleast_query_editor(self, request, view, action):\n        query = get_query_or_404(view.kwargs['query_pk'])\n        return QueryAccessInspector(request.user, query).is_atleast_editor()\n", "path": "mathesar/api/ui/permissions/shares.py"}], "after_files": [{"content": "import uuid\nfrom rest_framework import viewsets\nfrom rest_access_policy import AccessViewSetMixin\nfrom rest_framework.decorators import action\nfrom rest_framework.response import Response\n\nfrom mathesar.api.pagination import DefaultLimitOffsetPagination\nfrom mathesar.api.ui.serializers.shares import SharedTableSerializer, SharedQuerySerializer\nfrom mathesar.api.ui.permissions.shares import SharedTableAccessPolicy, SharedQueryAccessPolicy\nfrom mathesar.models.shares import SharedTable, SharedQuery\n\n\nclass RegenerateSlugMixin(viewsets.GenericViewSet):\n    @action(methods=['post'], detail=True)\n    def regenerate(self, *args, **kwargs):\n        share = self.get_object()\n        share.slug = uuid.uuid4()\n        share.save()\n        serializer = self.get_serializer(share)\n        return Response(serializer.data)\n\n\nclass SharedTableViewSet(AccessViewSetMixin, viewsets.ModelViewSet, RegenerateSlugMixin):\n    pagination_class = DefaultLimitOffsetPagination\n    serializer_class = SharedTableSerializer\n    access_policy = SharedTableAccessPolicy\n\n    def get_queryset(self):\n        return SharedTable.objects.filter(table_id=self.kwargs['table_pk']).order_by('-created_at')\n\n    def perform_create(self, serializer):\n        serializer.save(table_id=self.kwargs['table_pk'])\n\n\nclass SharedQueryViewSet(AccessViewSetMixin, viewsets.ModelViewSet, RegenerateSlugMixin):\n    pagination_class = DefaultLimitOffsetPagination\n    serializer_class = SharedQuerySerializer\n    access_policy = SharedQueryAccessPolicy\n\n    def get_queryset(self):\n        return SharedQuery.objects.filter(query_id=self.kwargs['query_pk']).order_by('-created_at')\n\n    def perform_create(self, serializer):\n        serializer.save(query_id=self.kwargs['query_pk'])\n", "path": "mathesar/api/ui/viewsets/shares.py"}, {"content": "from rest_access_policy import AccessPolicy\n\nfrom mathesar.api.utils import get_query_or_404\nfrom mathesar.api.permission_utils import QueryAccessInspector\n\n\nclass SharedTableAccessPolicy(AccessPolicy):\n    statements = [\n        {\n            'action': ['list', 'retrieve'],\n            'principal': 'authenticated',\n            'effect': 'allow',\n            'condition_expression': 'is_atleast_viewer_nested_table_resource'\n        },\n        {\n            'action': ['create', 'destroy', 'update', 'partial_update', 'regenerate'],\n            'principal': 'authenticated',\n            'effect': 'allow',\n            'condition_expression': 'is_atleast_editor_nested_table_resource'\n        },\n    ]\n\n\nclass SharedQueryAccessPolicy(AccessPolicy):\n    statements = [\n        {\n            'action': ['list', 'retrieve'],\n            'principal': 'authenticated',\n            'effect': 'allow',\n            'condition_expression': 'is_atleast_query_viewer'\n        },\n        {\n            'action': ['create', 'destroy', 'update', 'partial_update', 'regenerate'],\n            'principal': 'authenticated',\n            'effect': 'allow',\n            'condition_expression': 'is_atleast_query_editor'\n        },\n    ]\n\n    def is_atleast_query_viewer(self, request, view, action):\n        query = get_query_or_404(view.kwargs['query_pk'])\n        return QueryAccessInspector(request.user, query).is_atleast_viewer()\n\n    def is_atleast_query_editor(self, request, view, action):\n        query = get_query_or_404(view.kwargs['query_pk'])\n        return QueryAccessInspector(request.user, query).is_atleast_editor()\n", "path": "mathesar/api/ui/permissions/shares.py"}]}