mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Merge pull request #1430 from SchrodingersGat/missing-permission-fix
Emit warning rather than raise error
This commit is contained in:
commit
fd01e23245
@ -12,6 +12,11 @@ from django.utils.translation import gettext_lazy as _
|
||||
from django.dispatch import receiver
|
||||
from django.db.models.signals import post_save, post_delete
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class RuleSet(models.Model):
|
||||
"""
|
||||
@ -345,7 +350,7 @@ def update_group_roles(group, debug=False):
|
||||
content_type = ContentType.objects.get(app_label=app, model=model)
|
||||
permission = Permission.objects.get(content_type=content_type, codename=perm)
|
||||
except ContentType.DoesNotExist:
|
||||
raise ValueError(f"Error: Could not find permission matching '{permission_string}'")
|
||||
logger.warning(f"Error: Could not find permission matching '{permission_string}'")
|
||||
permission = None
|
||||
|
||||
return permission
|
||||
|
38
InvenTree/users/test_migrations.py
Normal file
38
InvenTree/users/test_migrations.py
Normal file
@ -0,0 +1,38 @@
|
||||
"""
|
||||
Unit tests for the user model database migrations
|
||||
"""
|
||||
|
||||
from django_test_migrations.contrib.unittest_case import MigratorTestCase
|
||||
|
||||
from InvenTree import helpers
|
||||
|
||||
|
||||
class TestForwardMigrations(MigratorTestCase):
|
||||
"""
|
||||
Test entire schema migration sequence for the users app
|
||||
"""
|
||||
|
||||
migrate_from = ('users', helpers.getOldestMigrationFile('users'))
|
||||
migrate_to = ('users', helpers.getNewestMigrationFile('users'))
|
||||
|
||||
def prepare(self):
|
||||
|
||||
User = self.old_state.apps.get_model('auth', 'user')
|
||||
|
||||
User.objects.create(
|
||||
username='fred',
|
||||
email='fred@fred.com',
|
||||
password='password'
|
||||
)
|
||||
|
||||
User.objects.create(
|
||||
username='brad',
|
||||
email='brad@fred.com',
|
||||
password='password'
|
||||
)
|
||||
|
||||
def test_users_exist(self):
|
||||
|
||||
User = self.new_state.apps.get_model('auth', 'user')
|
||||
|
||||
self.assertEqual(User.objects.count(), 2)
|
Loading…
Reference in New Issue
Block a user