Skip to content
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

i18n: Fix untranslated strings in views and errors #152

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion invenio_stats/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

"""Errors used in Invenio-Stats."""

from invenio_i18n import gettext as _
from invenio_rest.errors import RESTException

##
Expand Down Expand Up @@ -71,6 +72,6 @@ def __init__(self, query_name):
"""
super(RESTException, self).__init__()
self.query_name = query_name
self.description = "Unknown statistic '{}'".format(query_name)
self.description = _("Unknown statistic '{}'").format(query_name)

code = 400
17 changes: 10 additions & 7 deletions invenio_stats/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"""InvenioStats views."""

from flask import Blueprint, abort, jsonify, request
from invenio_i18n import gettext as _
from invenio_rest.views import ContentNegotiatedMethodView
from invenio_search.engine import search

Expand Down Expand Up @@ -38,7 +39,7 @@ def __init__(self, **kwargs):
"GET": "application/json",
},
default_media_type="application/json",
**kwargs
**kwargs,
)

def post(self, **kwargs):
Expand All @@ -60,9 +61,11 @@ def post(self, **kwargs):
# 'config' has to be a dictionary with mandatory 'stat' key and
# optional 'params' key, and nothing else
raise InvalidRequestInputError(
"Invalid Input. It should be of the form "
'{ STATISTIC_NAME: { "stat": STAT_TYPE, '
'"params": STAT_PARAMS }}'
_(
"Invalid Input. It should be of the form "
'{ STATISTIC_NAME: { "stat": STAT_TYPE, '
'"params": STAT_PARAMS }}'
)
)

stat = config["stat"]
Expand All @@ -74,11 +77,11 @@ def post(self, **kwargs):

permission = current_stats.permission_factory(stat, params)
if permission is not None and not permission.can():
message = (
message = _(
"You do not have a permission to query the "
'statistic "{}" with those '
"parameters".format(stat)
)
"parameters"
).format(stat)

if current_user.is_authenticated:
abort(403, message)
Expand Down
1 change: 0 additions & 1 deletion tests/test_aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
"""Aggregation tests."""

import datetime
from turtle import pd
from unittest.mock import patch

import pytest
Expand Down