15094 review change

This commit is contained in:
Arthur 2024-02-16 11:50:37 -08:00
parent 07ee64e6bd
commit 5aa5b325df
5 changed files with 27 additions and 12 deletions

View File

@ -122,7 +122,9 @@ class APISelect(forms.Select):
except IndexError as error:
raise RuntimeError(
_("Missing required value for dynamic query param: '{dynamic_params}'").format(
dynamic_params=self.dynamic_params)) from error
dynamic_params=self.dynamic_params
)
) from error
def _add_static_params(self):
"""
@ -137,7 +139,9 @@ class APISelect(forms.Select):
except IndexError as error:
raise RuntimeError(
_("Missing required value for static query param: '{static_params}'").format(
static_params=self.static_params)) from error
static_params=self.static_params
)
) from error
def add_query_params(self, query_params):
"""

View File

@ -45,5 +45,6 @@ def register_table_column(column, name, *tables):
reg = registry['tables'][table]
if name in reg:
raise ValueError(_("A column named {name} is already defined for table {table_name}").format(
name=name, table_name=table.__name__))
name=name, table_name=table.__name__
))
reg[name] = column

View File

@ -313,8 +313,11 @@ def to_meters(length, unit):
valid_units = CableLengthUnitChoices.values()
if unit not in valid_units:
raise ValueError(_("Unknown unit {unit}. Must be one of the following: {valid_units}".format(
unit=unit, valid_units=', '.join(valid_units))))
raise ValueError(
_("Unknown unit {unit}. Must be one of the following: {valid_units}").format(
unit=unit, valid_units=', '.join(valid_units)
)
)
if unit == CableLengthUnitChoices.UNIT_KILOMETER:
return length * 1000
@ -343,8 +346,11 @@ def to_grams(weight, unit):
valid_units = WeightUnitChoices.values()
if unit not in valid_units:
raise ValueError(_("Unknown unit {unit}. Must be one of the following: {valid_units}".format(
unit=unit, valid_units=', '.join(valid_units))))
raise ValueError(
_("Unknown unit {unit}. Must be one of the following: {valid_units}").format(
unit=unit, valid_units=', '.join(valid_units)
)
)
if unit == WeightUnitChoices.UNIT_KILOGRAM:
return weight * 1000

View File

@ -36,7 +36,8 @@ class ContentTypePermissionRequiredMixin(AccessMixin):
Return the specific permission necessary to perform the requested action on an object.
"""
raise NotImplementedError(_("{self.__class__.__name__} must implement get_required_permission()").format(
class_name=self.__class__.__name__))
class_name=self.__class__.__name__
))
def has_permission(self):
user = self.request.user
@ -71,7 +72,8 @@ class ObjectPermissionRequiredMixin(AccessMixin):
Return the specific permission necessary to perform the requested action on an object.
"""
raise NotImplementedError(_("{class_name} must implement get_required_permission()").format(
class_name=self.__class__.__name__))
class_name=self.__class__.__name__
))
def has_permission(self):
user = self.request.user
@ -92,8 +94,10 @@ class ObjectPermissionRequiredMixin(AccessMixin):
if not hasattr(self, 'queryset'):
raise ImproperlyConfigured(
_('{} has no queryset defined. ObjectPermissionRequiredMixin may only be used on views which define a base queryset').format(
self.__class__.__name__)
_(
'{class_name} has no queryset defined. ObjectPermissionRequiredMixin may only be used on views which '
'define a base queryset'
).format(class_name=self.__class__.__name__)
)
if not self.has_permission():

View File

@ -23,6 +23,6 @@ def get_channel_attr(channel, attr):
'width': Decimal(channel_values[3]),
}
if attr not in attrs:
raise ValueError(_("Invalid channel attribute: {attr}").format(attr=attr))
raise ValueError(_("Invalid channel attribute: {name}").format(name=attr))
return attrs[attr]