mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 03:30:54 +00:00
refactor: remove blank lines after docstring (#5736)
There shouldn't be any blank lines after the function docstring. Remove the blank lines to fix this issue. Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
This commit is contained in:
@ -113,7 +113,6 @@ class CurrencyExchangeView(APIView):
|
||||
|
||||
def get(self, request, format=None):
|
||||
"""Return information on available currency conversions"""
|
||||
|
||||
# Extract a list of all available rates
|
||||
try:
|
||||
rates = Rate.objects.all()
|
||||
@ -157,7 +156,6 @@ class CurrencyRefreshView(APIView):
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
"""Performing a POST request will update currency exchange rates"""
|
||||
|
||||
from InvenTree.tasks import update_exchange_rates
|
||||
|
||||
update_exchange_rates(force=True)
|
||||
@ -194,7 +192,6 @@ class GlobalSettingsList(SettingsList):
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
"""Ensure all global settings are created"""
|
||||
|
||||
common.models.InvenTreeSetting.build_default_values()
|
||||
return super().list(request, *args, **kwargs)
|
||||
|
||||
@ -253,7 +250,6 @@ class UserSettingsList(SettingsList):
|
||||
|
||||
def list(self, request, *args, **kwargs):
|
||||
"""Ensure all user settings are created"""
|
||||
|
||||
common.models.InvenTreeUserSetting.build_default_values(user=request.user)
|
||||
return super().list(request, *args, **kwargs)
|
||||
|
||||
@ -385,7 +381,6 @@ class NotificationList(NotificationMessageMixin, BulkDeleteMixin, ListAPI):
|
||||
|
||||
def filter_delete_queryset(self, queryset, request):
|
||||
"""Ensure that the user can only delete their *own* notifications"""
|
||||
|
||||
queryset = queryset.filter(user=request.user)
|
||||
return queryset
|
||||
|
||||
|
@ -84,7 +84,6 @@ class BaseURLValidator(URLValidator):
|
||||
|
||||
def __init__(self, schemes=None, **kwargs):
|
||||
"""Custom init routine"""
|
||||
|
||||
super().__init__(schemes, **kwargs)
|
||||
|
||||
# Override default host_re value - allow optional tld regex
|
||||
@ -204,7 +203,6 @@ class BaseInvenTreeSetting(models.Model):
|
||||
|
||||
If a particular setting is not present, create it with the default value
|
||||
"""
|
||||
|
||||
cache_key = f"BUILD_DEFAULT_VALUES:{str(cls.__name__)}"
|
||||
|
||||
if InvenTree.helpers.str2bool(cache.get(cache_key, False)):
|
||||
@ -255,7 +253,6 @@ class BaseInvenTreeSetting(models.Model):
|
||||
|
||||
def save_to_cache(self):
|
||||
"""Save this setting object to cache"""
|
||||
|
||||
ckey = self.cache_key
|
||||
|
||||
# skip saving to cache if no pk is set
|
||||
@ -283,7 +280,6 @@ class BaseInvenTreeSetting(models.Model):
|
||||
- The unique KEY string
|
||||
- Any key:value kwargs associated with the particular setting type (e.g. user-id)
|
||||
"""
|
||||
|
||||
key = f"{str(cls.__name__)}:{setting_key}"
|
||||
|
||||
for k, v in kwargs.items():
|
||||
@ -992,7 +988,6 @@ def validate_email_domains(setting):
|
||||
|
||||
def currency_exchange_plugins():
|
||||
"""Return a set of plugin choices which can be used for currency exchange"""
|
||||
|
||||
try:
|
||||
from plugin import registry
|
||||
plugs = registry.with_mixin('currencyexchange', active=True)
|
||||
@ -1006,7 +1001,6 @@ def currency_exchange_plugins():
|
||||
|
||||
def update_exchange_rates(setting):
|
||||
"""Update exchange rates when base currency is changed"""
|
||||
|
||||
if InvenTree.ready.isImportingData():
|
||||
return
|
||||
|
||||
@ -1018,7 +1012,6 @@ def update_exchange_rates(setting):
|
||||
|
||||
def reload_plugin_registry(setting):
|
||||
"""When a core plugin setting is changed, reload the plugin registry"""
|
||||
|
||||
from plugin import registry
|
||||
|
||||
logger.info("Reloading plugin registry due to change in setting '%s'", setting.key)
|
||||
@ -2891,7 +2884,6 @@ class NewsFeedEntry(models.Model):
|
||||
|
||||
def rename_notes_image(instance, filename):
|
||||
"""Function for renaming uploading image file. Will store in the 'notes' directory."""
|
||||
|
||||
fname = os.path.basename(filename)
|
||||
return os.path.join('notes', fname)
|
||||
|
||||
@ -2936,7 +2928,6 @@ class CustomUnit(models.Model):
|
||||
|
||||
def clean(self):
|
||||
"""Validate that the provided custom unit is indeed valid"""
|
||||
|
||||
super().clean()
|
||||
|
||||
from InvenTree.conversion import get_unit_registry
|
||||
@ -2994,7 +2985,6 @@ class CustomUnit(models.Model):
|
||||
@receiver(post_delete, sender=CustomUnit, dispatch_uid='custom_unit_deleted')
|
||||
def after_custom_unit_updated(sender, instance, **kwargs):
|
||||
"""Callback when a custom unit is updated or deleted"""
|
||||
|
||||
# Force reload of the unit registry
|
||||
from InvenTree.conversion import reload_unit_registry
|
||||
reload_unit_registry()
|
||||
|
@ -242,7 +242,6 @@ class UIMessageNotification(SingleNotificationMethod):
|
||||
|
||||
def get_targets(self):
|
||||
"""Only send notifications for active users"""
|
||||
|
||||
return [target for target in self.targets if target.is_active]
|
||||
|
||||
def send(self, target):
|
||||
|
@ -192,7 +192,6 @@ class NotificationMessageSerializer(InvenTreeModelSerializer):
|
||||
|
||||
def get_target(self, obj):
|
||||
"""Function to resolve generic object reference to target."""
|
||||
|
||||
target = get_objectreference(obj, 'target_content_type', 'target_object_id')
|
||||
|
||||
if target and 'link' not in target:
|
||||
|
@ -12,7 +12,6 @@ logger = logging.getLogger('inventree')
|
||||
|
||||
def currency_code_default():
|
||||
"""Returns the default currency code (or USD if not specified)"""
|
||||
|
||||
from common.models import InvenTreeSetting
|
||||
|
||||
cached_value = cache.get('currency_code_default', '')
|
||||
|
@ -268,7 +268,6 @@ class SettingsTest(InvenTreeTestCase):
|
||||
|
||||
def test_global_setting_caching(self):
|
||||
"""Test caching operations for the global settings class"""
|
||||
|
||||
key = 'PART_NAME_FORMAT'
|
||||
|
||||
cache_key = InvenTreeSetting.create_cache_key(key)
|
||||
@ -290,7 +289,6 @@ class SettingsTest(InvenTreeTestCase):
|
||||
|
||||
def test_user_setting_caching(self):
|
||||
"""Test caching operation for the user settings class"""
|
||||
|
||||
cache.clear()
|
||||
|
||||
# Generate a number of new users
|
||||
@ -610,7 +608,6 @@ class NotificationUserSettingsApiTest(InvenTreeAPITestCase):
|
||||
|
||||
def test_setting(self):
|
||||
"""Test the string name for NotificationUserSetting."""
|
||||
|
||||
NotificationUserSetting.set_setting('NOTIFICATION_METHOD_MAIL', True, change_user=self.user, user=self.user)
|
||||
test_setting = NotificationUserSetting.get_setting_object('NOTIFICATION_METHOD_MAIL', user=self.user)
|
||||
self.assertEqual(str(test_setting), 'NOTIFICATION_METHOD_MAIL (for testuser): True')
|
||||
@ -823,7 +820,6 @@ class NotificationTest(InvenTreeAPITestCase):
|
||||
|
||||
def test_api_list(self):
|
||||
"""Test list URL."""
|
||||
|
||||
url = reverse('api-notifications-list')
|
||||
|
||||
self.get(url, expected_code=200)
|
||||
@ -843,7 +839,6 @@ class NotificationTest(InvenTreeAPITestCase):
|
||||
|
||||
def test_bulk_delete(self):
|
||||
"""Tests for bulk deletion of user notifications"""
|
||||
|
||||
from error_report.models import Error
|
||||
|
||||
# Create some notification messages by throwing errors
|
||||
@ -1019,7 +1014,6 @@ class CurrencyAPITests(InvenTreeAPITestCase):
|
||||
|
||||
def test_exchange_endpoint(self):
|
||||
"""Test that the currency exchange endpoint works as expected"""
|
||||
|
||||
response = self.get(reverse('api-currency-exchange'), expected_code=200)
|
||||
|
||||
self.assertIn('base_currency', response.data)
|
||||
@ -1027,7 +1021,6 @@ class CurrencyAPITests(InvenTreeAPITestCase):
|
||||
|
||||
def test_refresh_endpoint(self):
|
||||
"""Call the 'refresh currencies' endpoint"""
|
||||
|
||||
from djmoney.contrib.exchange.models import Rate
|
||||
|
||||
# Delete any existing exchange rate data
|
||||
@ -1053,7 +1046,6 @@ class NotesImageTest(InvenTreeAPITestCase):
|
||||
|
||||
def test_invalid_files(self):
|
||||
"""Test that invalid files are rejected."""
|
||||
|
||||
n = NotesImage.objects.count()
|
||||
|
||||
# Test upload of a simple text file
|
||||
@ -1085,7 +1077,6 @@ class NotesImageTest(InvenTreeAPITestCase):
|
||||
|
||||
def test_valid_image(self):
|
||||
"""Test upload of a valid image file"""
|
||||
|
||||
n = NotesImage.objects.count()
|
||||
|
||||
# Construct a simple image file
|
||||
@ -1132,13 +1123,11 @@ class ProjectCodesTest(InvenTreeAPITestCase):
|
||||
|
||||
def test_list(self):
|
||||
"""Test that the list endpoint works as expected"""
|
||||
|
||||
response = self.get(self.url, expected_code=200)
|
||||
self.assertEqual(len(response.data), ProjectCode.objects.count())
|
||||
|
||||
def test_delete(self):
|
||||
"""Test we can delete a project code via the API"""
|
||||
|
||||
n = ProjectCode.objects.count()
|
||||
|
||||
# Get the first project code
|
||||
@ -1155,7 +1144,6 @@ class ProjectCodesTest(InvenTreeAPITestCase):
|
||||
|
||||
def test_duplicate_code(self):
|
||||
"""Test that we cannot create two project codes with the same code"""
|
||||
|
||||
# Create a new project code
|
||||
response = self.post(
|
||||
self.url,
|
||||
@ -1170,7 +1158,6 @@ class ProjectCodesTest(InvenTreeAPITestCase):
|
||||
|
||||
def test_write_access(self):
|
||||
"""Test that non-staff users have read-only access"""
|
||||
|
||||
# By default user has staff access, can create a new project code
|
||||
response = self.post(
|
||||
self.url,
|
||||
@ -1240,13 +1227,11 @@ class CustomUnitAPITest(InvenTreeAPITestCase):
|
||||
|
||||
def test_list(self):
|
||||
"""Test API list functionality"""
|
||||
|
||||
response = self.get(self.url, expected_code=200)
|
||||
self.assertEqual(len(response.data), CustomUnit.objects.count())
|
||||
|
||||
def test_edit(self):
|
||||
"""Test edit permissions for CustomUnit model"""
|
||||
|
||||
unit = CustomUnit.objects.first()
|
||||
|
||||
# Try to edit without permission
|
||||
@ -1278,7 +1263,6 @@ class CustomUnitAPITest(InvenTreeAPITestCase):
|
||||
|
||||
def test_validation(self):
|
||||
"""Test that validation works as expected"""
|
||||
|
||||
unit = CustomUnit.objects.first()
|
||||
|
||||
self.user.is_staff = True
|
||||
|
Reference in New Issue
Block a user