mirror of
https://github.com/inventree/InvenTree.git
synced 2025-07-02 11:40:58 +00:00
Add ProjectCode support to build orders (#4808)
* Add "project_code" field to Build model * Add "project_code" field to Build model * build javascript updates (cherry picked from commit3e27a3b739
) * Update table filters (cherry picked from commit196c675585
) * Adds API filtering * Bump API version * Hide project code field from build form if project codes not enabled (cherry picked from commit4e210e3dfa
) * refactoring to attempt to fix circular imports * Upgrade django-test-migrations package * Fix broken import * Further fixes for unit tests * Update unit tests for migration files * Fix typo in build.js * Migration test updates - Need to specify MPTT stuff * Fix build.js * Fix migration order * Update API version
This commit is contained in:
@ -525,7 +525,7 @@ settings_api_urls = [
|
||||
path(r'<int:pk>/', NotificationUserSettingsDetail.as_view(), name='api-notification-setting-detail'),
|
||||
|
||||
# Notification Settings List
|
||||
re_path(r'^.*$', NotificationUserSettingsList.as_view(), name='api-notifcation-setting-list'),
|
||||
re_path(r'^.*$', NotificationUserSettingsList.as_view(), name='api-notification-setting-list'),
|
||||
])),
|
||||
|
||||
# Global settings
|
||||
|
@ -8,8 +8,8 @@ from django.contrib.auth import get_user_model
|
||||
from django.contrib.auth.models import Group
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
import common.models
|
||||
import InvenTree.helpers
|
||||
from common.models import NotificationEntry, NotificationMessage
|
||||
from InvenTree.ready import isImportingData
|
||||
from plugin import registry
|
||||
from plugin.models import NotificationUserSetting, PluginConfig
|
||||
@ -247,7 +247,7 @@ class UIMessageNotification(SingleNotificationMethod):
|
||||
|
||||
def send(self, target):
|
||||
"""Send a UI notification to a user."""
|
||||
NotificationMessage.objects.create(
|
||||
common.models.NotificationMessage.objects.create(
|
||||
target_object=self.obj,
|
||||
source_object=target,
|
||||
user=target,
|
||||
@ -338,7 +338,7 @@ def trigger_notification(obj, category=None, obj_ref='pk', **kwargs):
|
||||
# Check if we have notified recently...
|
||||
delta = timedelta(days=1)
|
||||
|
||||
if NotificationEntry.check_recent(category, obj_ref_value, delta):
|
||||
if common.models.NotificationEntry.check_recent(category, obj_ref_value, delta):
|
||||
logger.info(f"Notification '{category}' has recently been sent for '{str(obj)}' - SKIPPING")
|
||||
return
|
||||
|
||||
@ -398,7 +398,7 @@ def trigger_notification(obj, category=None, obj_ref='pk', **kwargs):
|
||||
logger.error(error)
|
||||
|
||||
# Set delivery flag
|
||||
NotificationEntry.notify(category, obj_ref_value)
|
||||
common.models.NotificationEntry.notify(category, obj_ref_value)
|
||||
else:
|
||||
logger.info(f"No possible users for notification '{category}'")
|
||||
|
||||
|
@ -6,9 +6,7 @@ from django.urls import reverse
|
||||
from flags.state import flag_state
|
||||
from rest_framework import serializers
|
||||
|
||||
from common.models import (InvenTreeSetting, InvenTreeUserSetting,
|
||||
NewsFeedEntry, NotesImage, NotificationMessage,
|
||||
ProjectCode)
|
||||
import common.models as common_models
|
||||
from InvenTree.helpers import get_objectreference
|
||||
from InvenTree.helpers_model import construct_absolute_url
|
||||
from InvenTree.serializers import (InvenTreeImageSerializerField,
|
||||
@ -64,7 +62,7 @@ class GlobalSettingsSerializer(SettingsSerializer):
|
||||
class Meta:
|
||||
"""Meta options for GlobalSettingsSerializer."""
|
||||
|
||||
model = InvenTreeSetting
|
||||
model = common_models.InvenTreeSetting
|
||||
fields = [
|
||||
'pk',
|
||||
'key',
|
||||
@ -85,7 +83,7 @@ class UserSettingsSerializer(SettingsSerializer):
|
||||
class Meta:
|
||||
"""Meta options for UserSettingsSerializer."""
|
||||
|
||||
model = InvenTreeUserSetting
|
||||
model = common_models.InvenTreeUserSetting
|
||||
fields = [
|
||||
'pk',
|
||||
'key',
|
||||
@ -148,7 +146,7 @@ class NotificationMessageSerializer(InvenTreeModelSerializer):
|
||||
class Meta:
|
||||
"""Meta options for NotificationMessageSerializer."""
|
||||
|
||||
model = NotificationMessage
|
||||
model = common_models.NotificationMessage
|
||||
fields = [
|
||||
'pk',
|
||||
'target',
|
||||
@ -209,7 +207,7 @@ class NewsFeedEntrySerializer(InvenTreeModelSerializer):
|
||||
class Meta:
|
||||
"""Meta options for NewsFeedEntrySerializer."""
|
||||
|
||||
model = NewsFeedEntry
|
||||
model = common_models.NewsFeedEntry
|
||||
fields = [
|
||||
'pk',
|
||||
'feed_id',
|
||||
@ -243,7 +241,7 @@ class NotesImageSerializer(InvenTreeModelSerializer):
|
||||
class Meta:
|
||||
"""Meta options for NotesImageSerializer."""
|
||||
|
||||
model = NotesImage
|
||||
model = common_models.NotesImage
|
||||
fields = [
|
||||
'pk',
|
||||
'image',
|
||||
@ -265,7 +263,7 @@ class ProjectCodeSerializer(InvenTreeModelSerializer):
|
||||
class Meta:
|
||||
"""Meta options for ProjectCodeSerializer."""
|
||||
|
||||
model = ProjectCode
|
||||
model = common_models.ProjectCode
|
||||
fields = [
|
||||
'pk',
|
||||
'code',
|
||||
|
@ -226,7 +226,7 @@ class SettingsTest(InvenTreeTestCase):
|
||||
|
||||
cache.clear()
|
||||
|
||||
# Generate a number of new usesr
|
||||
# Generate a number of new users
|
||||
for idx in range(5):
|
||||
get_user_model().objects.create(
|
||||
username=f"User_{idx}",
|
||||
@ -417,7 +417,7 @@ class UserSettingsApiTest(InvenTreeAPITestCase):
|
||||
|
||||
self.assertTrue(str2bool(response.data['value']))
|
||||
|
||||
# Assign some falsey values
|
||||
# Assign some false(ish) values
|
||||
for v in ['false', False, '0', 'n', 'FalSe']:
|
||||
self.patch(
|
||||
url,
|
||||
@ -535,7 +535,7 @@ class NotificationUserSettingsApiTest(InvenTreeAPITestCase):
|
||||
|
||||
def test_api_list(self):
|
||||
"""Test list URL."""
|
||||
url = reverse('api-notifcation-setting-list')
|
||||
url = reverse('api-notification-setting-list')
|
||||
|
||||
self.get(url, expected_code=200)
|
||||
|
||||
@ -583,7 +583,7 @@ class PluginSettingsApiTest(PluginMixin, InvenTreeAPITestCase):
|
||||
|
||||
# Failure mode tests
|
||||
|
||||
# Non - exsistant plugin
|
||||
# Non-existent plugin
|
||||
url = reverse('api-plugin-setting-detail', kwargs={'plugin': 'doesnotexist', 'key': 'doesnotmatter'})
|
||||
response = self.get(url, expected_code=404)
|
||||
self.assertIn("Plugin 'doesnotexist' not installed", str(response.data))
|
||||
@ -729,7 +729,7 @@ class WebhookMessageTests(TestCase):
|
||||
|
||||
|
||||
class NotificationTest(InvenTreeAPITestCase):
|
||||
"""Tests for NotificationEntriy."""
|
||||
"""Tests for NotificationEntry."""
|
||||
|
||||
fixtures = [
|
||||
'users',
|
||||
@ -785,7 +785,7 @@ class NotificationTest(InvenTreeAPITestCase):
|
||||
messages = NotificationMessage.objects.all()
|
||||
|
||||
# As there are three staff users (including the 'test' user) we expect 30 notifications
|
||||
# However, one user is marked as i nactive
|
||||
# However, one user is marked as inactive
|
||||
self.assertEqual(messages.count(), 20)
|
||||
|
||||
# Only 10 messages related to *this* user
|
||||
|
Reference in New Issue
Block a user