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

View File

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

View File

@ -313,8 +313,11 @@ def to_meters(length, unit):
valid_units = CableLengthUnitChoices.values() valid_units = CableLengthUnitChoices.values()
if unit not in valid_units: if unit not in valid_units:
raise ValueError(_("Unknown unit {unit}. Must be one of the following: {valid_units}".format( raise ValueError(
unit=unit, valid_units=', '.join(valid_units)))) _("Unknown unit {unit}. Must be one of the following: {valid_units}").format(
unit=unit, valid_units=', '.join(valid_units)
)
)
if unit == CableLengthUnitChoices.UNIT_KILOMETER: if unit == CableLengthUnitChoices.UNIT_KILOMETER:
return length * 1000 return length * 1000
@ -343,8 +346,11 @@ def to_grams(weight, unit):
valid_units = WeightUnitChoices.values() valid_units = WeightUnitChoices.values()
if unit not in valid_units: if unit not in valid_units:
raise ValueError(_("Unknown unit {unit}. Must be one of the following: {valid_units}".format( raise ValueError(
unit=unit, valid_units=', '.join(valid_units)))) _("Unknown unit {unit}. Must be one of the following: {valid_units}").format(
unit=unit, valid_units=', '.join(valid_units)
)
)
if unit == WeightUnitChoices.UNIT_KILOGRAM: if unit == WeightUnitChoices.UNIT_KILOGRAM:
return weight * 1000 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. Return the specific permission necessary to perform the requested action on an object.
""" """
raise NotImplementedError(_("{self.__class__.__name__} must implement get_required_permission()").format( 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): def has_permission(self):
user = self.request.user user = self.request.user
@ -71,7 +72,8 @@ class ObjectPermissionRequiredMixin(AccessMixin):
Return the specific permission necessary to perform the requested action on an object. Return the specific permission necessary to perform the requested action on an object.
""" """
raise NotImplementedError(_("{class_name} must implement get_required_permission()").format( raise NotImplementedError(_("{class_name} must implement get_required_permission()").format(
class_name=self.__class__.__name__)) class_name=self.__class__.__name__
))
def has_permission(self): def has_permission(self):
user = self.request.user user = self.request.user
@ -92,8 +94,10 @@ class ObjectPermissionRequiredMixin(AccessMixin):
if not hasattr(self, 'queryset'): if not hasattr(self, 'queryset'):
raise ImproperlyConfigured( 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(): if not self.has_permission():

View File

@ -23,6 +23,6 @@ def get_channel_attr(channel, attr):
'width': Decimal(channel_values[3]), 'width': Decimal(channel_values[3]),
} }
if attr not in attrs: 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] return attrs[attr]