diff --git a/iranian_cities/constants.py b/iranian_cities/constants.py index 8581873..7b9bfb0 100644 --- a/iranian_cities/constants.py +++ b/iranian_cities/constants.py @@ -2,8 +2,8 @@ # Default values for permissions DEFAULT_SETTINGS: Dict[str, bool] = { - "IRANIAN_CITIES_ADMIN_ADD_READONLY_ENABLED": True, - "IRANIAN_CITIES_ADMIN_DELETE_READONLY_ENABLED": True, - "IRANIAN_CITIES_ADMIN_CHANGE_READONLY_ENABLED": True, + "IRANIAN_CITIES_ADMIN_ADD_READONLY_ENABLED": False, + "IRANIAN_CITIES_ADMIN_DELETE_READONLY_ENABLED": False, + "IRANIAN_CITIES_ADMIN_CHANGE_READONLY_ENABLED": False, "IRANIAN_CITIES_ADMIN_INLINE_ENABLED": False, } diff --git a/iranian_cities/mixins/dynamic_permission.py b/iranian_cities/mixins/dynamic_permission.py index 54473dc..f9bc69c 100644 --- a/iranian_cities/mixins/dynamic_permission.py +++ b/iranian_cities/mixins/dynamic_permission.py @@ -3,13 +3,13 @@ class IranianCitiesAdminReadOnlyEnabled: def has_add_permission(self, request): - return sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_ADD_READONLY_ENABLED + return not sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_ADD_READONLY_ENABLED def has_delete_permission(self, request, obj=None): - return sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_DELETE_READONLY_ENABLED + return not sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_DELETE_READONLY_ENABLED def has_change_permission(self, request, obj=None): - return sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_CHANGE_READONLY_ENABLED + return not sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_CHANGE_READONLY_ENABLED class DynamicInlineAdmin: diff --git a/tests/settings/test_admin_permissions.py b/tests/settings/test_admin_permissions.py index b088e24..96a51fc 100644 --- a/tests/settings/test_admin_permissions.py +++ b/tests/settings/test_admin_permissions.py @@ -42,9 +42,9 @@ def test_iranian_cities_admin_permissions(self) -> None: sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_DELETE_READONLY_ENABLED = False sage_iranian_cities_settings.IRANIAN_CITIES_ADMIN_CHANGE_READONLY_ENABLED = True - assert settings_instance.has_add_permission(request) is True - assert settings_instance.has_delete_permission(request) is False - assert settings_instance.has_change_permission(request) is True + assert settings_instance.has_add_permission(request) is False + assert settings_instance.has_delete_permission(request) is True + assert settings_instance.has_change_permission(request) is False def test_dynamic_inline_admin(self) -> None: """