diff --git a/ap/database_access/forms.py b/ap/database_access/forms.py index 725ceb8..d150745 100644 --- a/ap/database_access/forms.py +++ b/ap/database_access/forms.py @@ -21,14 +21,14 @@ class AccessForm(forms.ModelForm): queryset=None, widget=forms.CheckboxSelectMultiple, template_name="forms/fields/checkbox.html", - help_text="Select all that apply", + help_text="Choose actions the selected user will have on the table", required=True, ) grantable_permissions = forms.ModelMultipleChoiceField( queryset=None, widget=forms.CheckboxSelectMultiple, template_name="forms/fields/checkbox.html", - help_text="Select all that apply", + help_text="Choose actions the selected user can grant to other users", required=False, ) @@ -75,14 +75,14 @@ class ManageAccessForm(forms.ModelForm): queryset=None, widget=forms.CheckboxSelectMultiple, template_name="forms/fields/checkbox.html", - help_text="Select all that apply", + help_text="Choose actions the selected user will have on the table", required=True, ) grantable_permissions = forms.ModelMultipleChoiceField( queryset=None, widget=forms.CheckboxSelectMultiple, template_name="forms/fields/checkbox.html", - help_text="Grantable permissions allow the user to grant the selected permissions to other users.", # noqa + help_text="Choose actions the selected user can grant to other users", required=False, ) diff --git a/ap/database_access/views.py b/ap/database_access/views.py index eaddadd..514ac85 100644 --- a/ap/database_access/views.py +++ b/ap/database_access/views.py @@ -9,6 +9,7 @@ from django.views.generic.detail import SingleObjectMixin import botocore +import sentry_sdk from ap import aws from ap.auth.views.mixins import OIDCLoginRequiredMixin @@ -97,6 +98,7 @@ def get_context_data(self, **kwargs: Any) -> dict[str, Any]: context = super().get_context_data(**kwargs) context["access_queryset"] = ( models.TableAccess.objects.select_related("database_access__user") + .prefetch_related("grantable_permissions") .filter( database_access__name=self.kwargs["database_name"], name=self.kwargs["table_name"] ) @@ -147,9 +149,9 @@ def form_valid(self, form: BaseModelForm) -> HttpResponse: return super().form_valid(form) except botocore.exceptions.ClientError as error: if error.response["Error"]["Code"] == "InvalidInputException": - form.add_error(None, str(error)) + sentry_sdk.capture_exception(error) + form.add_error(None, "An error occured granting permissions") return self.form_invalid(form) - raise error class GrantTableAccessView(OIDCLoginRequiredMixin, TableAccessMixin, CreateView): diff --git a/ap/users/admin.py b/ap/users/admin.py index 21fb487..84f4410 100644 --- a/ap/users/admin.py +++ b/ap/users/admin.py @@ -6,3 +6,4 @@ @admin.register(models.User) class UserAdmin(admin.ModelAdmin): list_display = ("email", "user_id", "name", "is_superuser") + exclude = ["password"] diff --git a/chart/Chart.yaml b/chart/Chart.yaml index 4aed347..2f0a316 100644 --- a/chart/Chart.yaml +++ b/chart/Chart.yaml @@ -3,8 +3,8 @@ apiVersion: v2 name: analytical-platform-ui description: Analytical Platform UI type: application -version: 0.2.0 -appVersion: 0.2.0 +version: 0.2.1 +appVersion: 0.2.1 icon: https://upload.wikimedia.org/wikipedia/en/thumb/4/4a/Ministry_of_Justice_logo_%28United_Kingdom%29.svg/611px-Ministry_of_Justice_logo_%28United_Kingdom%29.svg.png maintainers: - name: moj-data-platform-robot diff --git a/templates/database_access/database/grant_access.html b/templates/database_access/database/grant_access.html index 1d97233..33e6fef 100644 --- a/templates/database_access/database/grant_access.html +++ b/templates/database_access/database/grant_access.html @@ -9,6 +9,7 @@

Grant Table Access

{% csrf_token %} + {{ form.non_field_errors }} {{ form.user.as_field_group }} {{ form.permissions.as_field_group }} {{ form.grantable_permissions.as_field_group }} diff --git a/templates/database_access/database/table.html b/templates/database_access/database/table.html index 8b3d2b7..10df27e 100644 --- a/templates/database_access/database/table.html +++ b/templates/database_access/database/table.html @@ -23,7 +23,7 @@

User Access

{% for table_access in access_queryset %} {{ table_access.database_access.user.email }} - {{ can_manage_access }} + {{ table_access.grantable_permissions.exists }} {% if can_manage_access %}