diff --git a/CHANGELOG.md b/CHANGELOG.md index 4483972..974176f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,17 +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.28.1 (2025-12-31) - -### Fix - -- add model title hints to core models -- add `html` flag param for `app.render_datetime()` -- tweak subcommand docstring, to match others/convention -- add `--comment` param for wutta typer commands -- auto-add doc string for uuid primary key columns -- add `--runas` param for wutta typer commands - ## v0.28.0 (2025-12-28) ### Feat diff --git a/pyproject.toml b/pyproject.toml index a8c75f8..bd0d5df 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "hatchling.build" [project] name = "WuttJamaican" -version = "0.28.1" +version = "0.28.0" description = "Base package for Wutta Framework" readme = "README.md" authors = [{name = "Lance Edgar", email = "lance@wuttaproject.org"}] diff --git a/src/wuttjamaican/app.py b/src/wuttjamaican/app.py index a623af8..9f4f41b 100644 --- a/src/wuttjamaican/app.py +++ b/src/wuttjamaican/app.py @@ -34,7 +34,6 @@ import importlib from importlib.metadata import version import humanize -from webhelpers2.html import HTML from wuttjamaican.util import ( get_timezone_by_name, @@ -916,7 +915,7 @@ class AppHandler: # pylint: disable=too-many-public-methods return "" return value.strftime(self.display_format_date) - def render_datetime(self, value, local=True, html=False): + def render_datetime(self, value, local=True): """ Return a human-friendly display string for the given datetime. @@ -929,33 +928,13 @@ class AppHandler: # pylint: disable=too-many-public-methods :meth:`localtime()` to normalize it for display. Specify ``local=False`` to skip that and render the value as-is. - :param html: If true, return HTML (with tooltip showing - relative time delta) instead of plain text. - - :returns: Rendered datetime as string (or HTML with tooltip). + :returns: Rendered datetime as string. """ if value is None: return "" - - # we usually want to render a "local" time if local: value = self.localtime(value) - - # simple formatted text - text = value.strftime(self.display_format_datetime) - - if html: - - # calculate time diff - # nb. if both times are naive, they should be UTC; - # otherwise if both are zone-aware, this should work even - # if they use different zones. - delta = self.make_utc(tzinfo=bool(value.tzinfo)) - value - - # show text w/ time diff as tooltip - return HTML.tag("span", c=text, title=self.render_time_ago(delta)) - - return text + return value.strftime(self.display_format_datetime) def render_error(self, error): """ diff --git a/src/wuttjamaican/db/model/auth.py b/src/wuttjamaican/db/model/auth.py index 59fc900..2a48369 100644 --- a/src/wuttjamaican/db/model/auth.py +++ b/src/wuttjamaican/db/model/auth.py @@ -282,10 +282,6 @@ class UserRole(Base): # pylint: disable=too-few-public-methods __tablename__ = "user_x_role" __versioned__ = {} - __wutta_hint__ = { - "model_title": "User Role", - "model_title_plural": "User Roles", - } uuid = uuid_column() @@ -316,10 +312,6 @@ class UserAPIToken(Base): # pylint: disable=too-few-public-methods """ __tablename__ = "user_api_token" - __wutta_hint__ = { - "model_title": "User API Token", - "model_title_plural": "User API Tokens", - } uuid = uuid_column() diff --git a/src/wuttjamaican/db/model/base.py b/src/wuttjamaican/db/model/base.py index e66e6d9..db2a2a1 100644 --- a/src/wuttjamaican/db/model/base.py +++ b/src/wuttjamaican/db/model/base.py @@ -166,10 +166,6 @@ class Person(Base): __tablename__ = "person" __versioned__ = {} - __wutta_hint__ = { - "model_title": "Person", - "model_title_plural": "People", - } uuid = uuid_column() diff --git a/src/wuttjamaican/testing.py b/src/wuttjamaican/testing.py index 59db454..76a1da0 100644 --- a/src/wuttjamaican/testing.py +++ b/src/wuttjamaican/testing.py @@ -105,9 +105,9 @@ class FileTestCase(TestCase): f.write(content) return path - def mkdir( + def mkdir( # pragma: no cover; pylint: disable=unused-argument,empty-docstring self, dirname - ): # pragma: no cover; pylint: disable=unused-argument,empty-docstring + ): """ """ warnings.warn( "FileTestCase.mkdir() is deprecated; " diff --git a/tests/test_app.py b/tests/test_app.py index 3693b2d..bf51576 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -595,42 +595,38 @@ app_title = WuttaTest self.assertEqual(self.app.render_date(dt), "2024-12-11") def test_render_datetime(self): - self.config.setdefault("wuttatest.timezone.default", "America/Los_Angeles") tzlocal = get_timezone_by_name("America/Los_Angeles") + with patch.object(self.app, "get_timezone", return_value=tzlocal): - # null value - self.assertEqual(self.app.render_datetime(None), "") + # null value + self.assertEqual(self.app.render_datetime(None), "") - # naive UTC - dt = datetime.datetime(2024, 12, 17, 1, 12) - self.assertEqual( - self.app.render_datetime(dt, local=True), "2024-12-16 17:12-0800" - ) - self.assertEqual(self.app.render_datetime(dt, local=False), "2024-12-17 01:12") + # naive UTC + dt = datetime.datetime(2024, 12, 17, 1, 12) + self.assertEqual( + self.app.render_datetime(dt, local=True), "2024-12-16 17:12-0800" + ) + self.assertEqual( + self.app.render_datetime(dt, local=False), "2024-12-17 01:12" + ) - # aware UTC - dt = datetime.datetime(2024, 12, 17, 1, 12, tzinfo=datetime.timezone.utc) - self.assertEqual( - self.app.render_datetime(dt, local=True), "2024-12-16 17:12-0800" - ) - self.assertEqual( - self.app.render_datetime(dt, local=False), "2024-12-17 01:12+0000" - ) + # aware UTC + dt = datetime.datetime(2024, 12, 17, 1, 12, tzinfo=datetime.timezone.utc) + self.assertEqual( + self.app.render_datetime(dt, local=True), "2024-12-16 17:12-0800" + ) + self.assertEqual( + self.app.render_datetime(dt, local=False), "2024-12-17 01:12+0000" + ) - # aware local - dt = datetime.datetime(2024, 12, 16, 19, 12, tzinfo=tzlocal) - self.assertEqual( - self.app.render_datetime(dt, local=True), "2024-12-16 19:12-0800" - ) - self.assertEqual( - self.app.render_datetime(dt, local=False), "2024-12-16 19:12-0800" - ) - - # as html - dt = datetime.datetime(2024, 12, 16, 19, 12, tzinfo=tzlocal) - html = self.app.render_datetime(dt, local=True, html=True) - self.assertTrue(html.startswith('