Skip to content

Commit

Permalink
Merge branch 'main' into feature/add-search-functionality-for-models
Browse files Browse the repository at this point in the history
  • Loading branch information
amstilp authored Oct 12, 2023
2 parents 9214a1d + 8f2c902 commit 027512e
Show file tree
Hide file tree
Showing 33 changed files with 1,462 additions and 427 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@

## Devel

* Add filtering in list views.

## 0.18 (2023-10-03)

* Include a workspace_data_object context variable for the `WorkspaceDetail` and `WorkspaceUpdate` views.
* Refactor auditing classes.
* Add filtering in list views.
* Add ability to specify a custom `Workspace` form in the workspace adapter.
* Add informational text to tables on Detail pages.
* Add a new "Limited view" permission. This permission is not yet used anywhere in the app, but can be used by projects using the app (e.g., to show a custom page to users with this permission).

## 0.17 (2023-07-11)

Expand Down
2 changes: 1 addition & 1 deletion anvil_consortium_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.17.2dev1"
__version__ = "0.19dev1"
1 change: 1 addition & 0 deletions anvil_consortium_manager/adapters/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class DefaultWorkspaceAdapter(BaseWorkspaceAdapter):
name = "Workspace"
type = "workspace"
description = "Default workspace"
workspace_form_class = forms.WorkspaceForm
workspace_data_model = models.DefaultWorkspaceData
workspace_data_form_class = forms.DefaultWorkspaceDataForm
list_table_class = tables.WorkspaceTable
Expand Down
22 changes: 22 additions & 0 deletions anvil_consortium_manager/adapters/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.forms import ModelForm
from django.utils.module_loading import import_string

from .. import models
Expand Down Expand Up @@ -36,6 +37,11 @@ def list_table_class(self):
"""Table class to use in a list of workspaces."""
...

@abstractproperty
def workspace_form_class(self):
"""Custom form to use when creating a Workspace."""
...

@abstractproperty
def workspace_data_model(self):
"""Model to use for storing extra data about workspaces."""
Expand Down Expand Up @@ -77,6 +83,22 @@ def get_list_table_class(self):
)
return self.list_table_class

def get_workspace_form_class(self):
"""Return the form used to create a `Workspace`."""
if not self.workspace_form_class:
raise ImproperlyConfigured("Set `workspace_data_form_class`.")
# Make sure it is a model form
if not issubclass(self.workspace_form_class, ModelForm):
raise ImproperlyConfigured(
"workspace_form_class must be a subclass of ModelForm."
)
# Make sure it has the correct model set.
if self.workspace_form_class.Meta.model != models.Workspace:
raise ImproperlyConfigured(
"workspace_form_class Meta model field must be anvil_consortium_manager.models.Workspace."
)
return self.workspace_form_class

def get_workspace_data_model(self):
"""Return the `workspace_data_model`."""
if not self.workspace_data_model:
Expand Down
264 changes: 0 additions & 264 deletions anvil_consortium_manager/anvil_audit.py

This file was deleted.

Empty file.
17 changes: 16 additions & 1 deletion anvil_consortium_manager/auth.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.contrib.auth.mixins import PermissionRequiredMixin, UserPassesTestMixin
from django.contrib.contenttypes.models import ContentType

from .models import AnVILProjectManagerAccess


class AnVILConsortiumManagerLimitedViewRequired(UserPassesTestMixin):
"""AnVIL global app limited view permission required mixin.
This mixin allows anyone with either LIMITED_VIEW or VIEW permission to access a view."""

def test_func(self):
apm_content_type = ContentType.objects.get_for_model(AnVILProjectManagerAccess)
perm_1 = f"{apm_content_type.app_label}.{AnVILProjectManagerAccess.LIMITED_VIEW_PERMISSION_CODENAME}"
perm_2 = f"{apm_content_type.app_label}.{AnVILProjectManagerAccess.VIEW_PERMISSION_CODENAME}"
has_perms = self.request.user.has_perms(
(perm_1,)
) or self.request.user.has_perms((perm_2,))
return has_perms


class AnVILConsortiumManagerViewRequired(PermissionRequiredMixin):
"""AnVIL global app view permission required mixin"""

Expand Down
Loading

0 comments on commit 027512e

Please sign in to comment.