----
2022-07-11
- Introduce class based views. Function based views are still supported
and will be supported until at least 0.23.
Migration to class based views is simple. Only your project's ``urls.py``
would change:
.. code-block:: python
urlpatterns = [
...
url(r'^fobi/', include('fobi.urls.class_based.view')),
url(r'^fobi/', include('fobi.urls.class_based.edit')),
...
]
To use function based views, simply replace the previous line with:
.. code-block:: python
urlpatterns = [
...
url(r'^fobi/', include('fobi.urls.view')),
url(r'^fobi/', include('fobi.urls.edit')),
...
]
- Class-based permissions (work only in combination with class-based views).
Example:
.. code-block:: python
from fobi.permissions.definitions import edit_form_entry_permissions
from fobi.permissions.generic import BasePermission
from fobi.permissions.helpers import (
any_permission_required_func, login_required,
)
class EditFormEntryPermission(BasePermission):
"""Permission to edit form entries."""
def has_permission(self, request, view) -> bool:
return login_required(request) and any_permission_required_func(
edit_form_entry_permissions
)(request.user)
def has_object_permission(self, request, view, obj) -> bool:
return login_required(request) and any_permission_required_func(
edit_form_entry_permissions
)(request.user) and obj.user == request.user