diff --git a/CHANGELOG.md b/CHANGELOG.md index 554f41e..049ccaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,13 +5,6 @@ All notable changes to WuttJamaican will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## v0.8.3 (2024-08-05) - -### Fix - -- add `AuthHandler.user_is_admin()` method -- add `AppHandler.make_title()` convenience method - ## v0.8.2 (2024-07-18) ### Fix diff --git a/pyproject.toml b/pyproject.toml index 3fd56ab..4d9be0b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "WuttJamaican" -version = "0.8.3" +version = "0.8.2" description = "Base package for Wutta Framework" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@edbob.org"}] diff --git a/src/wuttjamaican/app.py b/src/wuttjamaican/app.py index fef2b30..53d378b 100644 --- a/src/wuttjamaican/app.py +++ b/src/wuttjamaican/app.py @@ -28,7 +28,7 @@ import importlib import os import warnings -from wuttjamaican.util import load_entry_points, load_object, make_title, make_uuid, parse_bool +from wuttjamaican.util import load_entry_points, load_object, make_uuid, parse_bool class AppHandler: @@ -232,20 +232,6 @@ class AppHandler: return Session(**kwargs) - def make_title(self, text, **kwargs): - """ - Return a human-friendly "title" for the given text. - - This is mostly useful for converting a Python variable name (or - similar) to a human-friendly string, e.g.:: - - make_title('foo_bar') # => 'Foo Bar' - - By default this just invokes - :func:`wuttjamaican.util.make_title()`. - """ - return make_title(text) - def make_uuid(self): """ Generate a new UUID value. diff --git a/src/wuttjamaican/auth.py b/src/wuttjamaican/auth.py index 008d352..d9300ed 100644 --- a/src/wuttjamaican/auth.py +++ b/src/wuttjamaican/auth.py @@ -369,20 +369,6 @@ class AuthHandler(GenericHandler): """ return self._special_role(session, 'b765a9cc331a11e6ac2a3ca9f40bc550', "Authenticated") - def user_is_admin(self, user, **kwargs): - """ - Check if given user is a member of the "Administrator" role. - - :rtype: bool - """ - if user: - session = self.app.get_session(user) - admin = self.get_role_administrator(session) - if admin in user.roles: - return True - - return False - def get_permissions(self, session, principal, include_anonymous=True, include_authenticated=True): diff --git a/src/wuttjamaican/util.py b/src/wuttjamaican/util.py index 78a755a..5ebc73a 100644 --- a/src/wuttjamaican/util.py +++ b/src/wuttjamaican/util.py @@ -114,21 +114,6 @@ def load_object(spec): return getattr(module, name) -def make_title(text): - """ - Return a human-friendly "title" for the given text. - - This is mostly useful for converting a Python variable name (or - similar) to a human-friendly string, e.g.:: - - make_title('foo_bar') # => 'Foo Bar' - """ - text = text.replace('_', ' ') - text = text.replace('-', ' ') - words = text.split() - return ' '.join([x.capitalize() for x in words]) - - def make_uuid(): """ Generate a universally-unique identifier. diff --git a/tests/test_app.py b/tests/test_app.py index b2aa391..03a9cc3 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -116,10 +116,6 @@ class TestAppHandler(TestCase): def test_get_title(self): self.assertEqual(self.app.get_title(), 'WuttJamaican') - def test_make_title(self): - text = self.app.make_title('foo_bar') - self.assertEqual(text, "Foo Bar") - def test_make_uuid(self): uuid = self.app.make_uuid() self.assertEqual(len(uuid), 32) diff --git a/tests/test_auth.py b/tests/test_auth.py index cf37417..e8d5e15 100644 --- a/tests/test_auth.py +++ b/tests/test_auth.py @@ -253,23 +253,6 @@ else: self.assertEqual(self.session.query(model.Role).count(), 1) self.assertEqual(role.name, "Authenticated") - def test_user_is_admin(self): - model = self.app.model - - # non-user is not admin - self.assertFalse(self.handler.user_is_admin(None)) - - # new user but not yet admin - user = self.handler.make_user(session=self.session) - self.session.commit() - self.assertFalse(self.handler.user_is_admin(user)) - - # but we can make them an admin - admin = self.handler.get_role_administrator(self.session) - user.roles.append(admin) - self.session.commit() - self.assertTrue(self.handler.user_is_admin(user)) - def test_get_permissions(self): model = self.app.model diff --git a/tests/test_util.py b/tests/test_util.py index 921e416..7e0bac5 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -232,10 +232,3 @@ class TestParseList(TestCase): self.assertEqual(value[0], 'foo') self.assertEqual(value[1], 'C:\\some path\\with spaces\\and, a comma') self.assertEqual(value[2], 'baz') - - -class TestMakeTitle(TestCase): - - def test_basic(self): - text = util.make_title('foo_bar') - self.assertEqual(text, "Foo Bar")