-
Notifications
You must be signed in to change notification settings - Fork 4
FIXME: Move format methods from Layout to utils #1835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
FIXME: Move format methods from Layout to utils #1835
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
... and 15 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
src/onegov/core/utils.py
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're always retrieving the locale
from request
it might be better to make these methods on CoreRequest
. That way we can also put the date formats on CoreRequest
and keep the API the same as for the methods on Layout
. That way we also easily can change the date formats, without having to modify each call site.
720069c
to
6cdb226
Compare
6cdb226
to
ad9e17a
Compare
return babel.dates.format_datetime(dt, format=fmt, locale=locale) | ||
else: | ||
return babel.dates.format_date(dt, format=fmt, locale=locale) | ||
fmt = getattr(self, f'{format}_format', format) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would move this part to CoreRequest
as well, we should never manually specify a fmt
string, it should always be one of our pre-configured format options. If one of the applications overwrites the formats in their specific layout class, you would need to instead overwrite them in their specific request class, but I'm not sure if we do overwrite them anywhere.
@pytest.fixture(scope='function') | ||
def org_app(request): | ||
yield create_org_app(request, use_elasticsearch=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use OrgApp
in core tests, the tests here are supposed to pass with a CoreRequest
without any org specific features, so you should create a basic Framework
instance here like e.g. maildir_app
above.
Layout: Make formatter methods available in utils
With the formatters as utility functions it is not needed to initiate a
Layout
in order to use the formatters.TYPE: Feature
LINK: None