FIXME: Move format methods from Layout to utils#1835
FIXME: Move format methods from Layout to utils#1835Tschuppi81 wants to merge 6 commits intomasterfrom
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:
|
There was a problem hiding this comment.
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.
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.
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
Layoutin order to use the formatters.TYPE: Feature
LINK: None