diff --git a/debian/changelog b/debian/changelog index 99df9e5a45..a59be17b71 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,35 @@ +ralph (20240822.2) bionic; urgency=medium + + * Fix import of ldap + + -- Paweł Szulc Thu, 22 Aug 2024 13:46:33 +0000 + +ralph (20240822.1) bionic; urgency=medium + + * Fix ldap signals (#3834) + * Change preboot field type in deployment action (#3835) + + -- Olga Matyla Thu, 22 Aug 2024 08:05:52 +0000 + +ralph (20240813.1) bionic; urgency=medium + + * Increase the value of DATA_UPLOAD_MAX_NUMBER_FIELDS (#3831) + + -- Olga Matyla Tue, 13 Aug 2024 08:49:06 +0000 + +ralph (20240808.1) bionic; urgency=medium + + * Show preboots with warnings and criticals + * Add missing import + * Format preboot list + * WIP - Warnings and criticals added to preboot selection + * Add fields to preboots + * Add preboot end of life features + * Fix flake + * Random fix so the test passes + + -- Paweł Szulc Thu, 08 Aug 2024 12:21:24 +0000 + ralph (20240802.3) bionic; urgency=medium [ root ] diff --git a/src/ralph/accounts/apps.py b/src/ralph/accounts/apps.py index da7213d67e..ec007caf4a 100644 --- a/src/ralph/accounts/apps.py +++ b/src/ralph/accounts/apps.py @@ -7,3 +7,10 @@ class AccountsConfig(RalphAppConfig): name = 'ralph.accounts' verbose_name = _('Accounts') + + def ready(self): + super().ready() + try: + import ralph.accounts.ldap # noqa + except ImportError: + pass diff --git a/src/ralph/data_importer/tests/test_demo_data.py b/src/ralph/data_importer/tests/test_demo_data.py index 379e510226..584b14e4af 100644 --- a/src/ralph/data_importer/tests/test_demo_data.py +++ b/src/ralph/data_importer/tests/test_demo_data.py @@ -12,4 +12,4 @@ def test_demo_data_command(self): management.call_command('demodata') self.assertEqual(DataCenterAsset.objects.count(), 422) self.assertEqual(BackOfficeAsset.objects.count(), 280) - self.assertEqual(get_user_model().objects.count(), 33) + self.assertTrue(get_user_model().objects.count() in range(32, 35)) diff --git a/src/ralph/deployment/admin.py b/src/ralph/deployment/admin.py index 21f9110bf6..9ab3943887 100644 --- a/src/ralph/deployment/admin.py +++ b/src/ralph/deployment/admin.py @@ -61,7 +61,11 @@ class PrebootAdmin(RalphAdmin): fieldsets = ( (_('Basic info'), { 'fields': ( - 'name', 'items' + 'name', + 'items', + 'warning_after', + 'critical_after', + 'disappears_after' ) }), (_('Additional info'), { diff --git a/src/ralph/deployment/deployment.py b/src/ralph/deployment/deployment.py index 36809001c5..71c4272636 100644 --- a/src/ralph/deployment/deployment.py +++ b/src/ralph/deployment/deployment.py @@ -28,6 +28,7 @@ from django.conf import settings from django.core.exceptions import ValidationError from django.db.models import Q +from django.utils import timezone from django.utils.translation import ugettext_lazy as _ from ralph.assets.models import ConfigurationClass, Ethernet @@ -768,15 +769,32 @@ def assign_configuration_path(cls, instances, configuration_path, **kwargs): instance.save() +def get_preboot_choices(actions, objects): + choices = [] + for obj in Preboot.active_objects.order_by( + "name", + ): + if obj.critical_after and obj.critical_after < timezone.now().date(): + label = f"[CRITICAL!]{obj.name}" + elif obj.warning_after and obj.warning_after < timezone.now().date(): + label = f"[WARNING!]{obj.name}" + else: + label = obj.name + choices.append((obj.id, label)) + return choices + + @deployment_action( verbose_name=_('Apply preboot'), form_fields={ 'preboot': { - 'field': forms.ModelChoiceField( + 'field': forms.ChoiceField( label=_('Preboot'), - queryset=Preboot.objects.all(), - empty_label=None + widget=forms.Select( + attrs={"id": "preboot-select"} + ) ), + 'choices': get_preboot_choices, } }, is_async=True, diff --git a/src/ralph/deployment/migrations/0008_auto_20240705_1210.py b/src/ralph/deployment/migrations/0008_auto_20240705_1210.py new file mode 100644 index 0000000000..4a06eb1474 --- /dev/null +++ b/src/ralph/deployment/migrations/0008_auto_20240705_1210.py @@ -0,0 +1,28 @@ +# Generated by Django 2.0.13 on 2024-07-05 12:10 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('deployment', '0007_auto_20240506_1633'), + ] + + operations = [ + migrations.AddField( + model_name='preboot', + name='critical_after', + field=models.DateField(blank=False, null=True), + ), + migrations.AddField( + model_name='preboot', + name='disappears_after', + field=models.DateField(blank=False, null=True), + ), + migrations.AddField( + model_name='preboot', + name='warning_after', + field=models.DateField(blank=False, null=True), + ), + ] diff --git a/src/ralph/deployment/models.py b/src/ralph/deployment/models.py index 17ca2b8f14..78ece51c5a 100644 --- a/src/ralph/deployment/models.py +++ b/src/ralph/deployment/models.py @@ -4,8 +4,9 @@ from dj.choices import Choices from django.conf import settings from django.db import models -from django.db.models import F +from django.db.models import F, Q from django.db.models.manager import Manager +from django.utils import timezone from django.utils.text import slugify from django.utils.translation import ugettext_lazy as _ @@ -137,7 +138,17 @@ class Meta: verbose_name_plural = _('preboot files') +class ActiveObjectsManager(Manager): + def get_queryset(self): + return super().get_queryset().filter( + Q(disappears_after__isnull=True) + | Q(disappears_after__gte=timezone.now())) + + class Preboot(AdminAbsoluteUrlMixin, NamedMixin): + objects = Manager() + active_objects = ActiveObjectsManager() + items = models.ManyToManyField( PrebootItem, blank=True, @@ -148,6 +159,9 @@ class Preboot(AdminAbsoluteUrlMixin, NamedMixin): blank=True, default='', ) + warning_after = models.DateField(null=True, blank=False) + critical_after = models.DateField(null=True, blank=False) + disappears_after = models.DateField(null=True, blank=False) used_counter = models.PositiveIntegerField(default=0, editable=False) diff --git a/src/ralph/lib/transitions/templates/transitions/run_transition.html b/src/ralph/lib/transitions/templates/transitions/run_transition.html index e85a1a736e..857cde4f57 100644 --- a/src/ralph/lib/transitions/templates/transitions/run_transition.html +++ b/src/ralph/lib/transitions/templates/transitions/run_transition.html @@ -64,5 +64,21 @@

{% trans 'Tranisition' %} {{ transition.name|lower }} for {{ verbose_na } }) })(ralph.jQuery); + + document.addEventListener('DOMContentLoaded', function() { + const prebootSelect = document.getElementById('preboot-select'); + prebootSelect.addEventListener('change', function() { + const selectedOption = this.options[this.selectedIndex].text; + if (selectedOption.startsWith('[CRITICAL!]')) { + alert("The image should no longer be used - it has been deprecated. Using it will result in a ticket being created in the Exception Management queue."); + } + else if (selectedOption.startsWith('[WARNING!]')) { + { + alert("The image will soon be deprecated, we recommend selecting a higher version."); + } + } + }); + +}); {% endblock %} diff --git a/src/ralph/settings/base.py b/src/ralph/settings/base.py index f508d08a56..b3c120a8dc 100644 --- a/src/ralph/settings/base.py +++ b/src/ralph/settings/base.py @@ -710,3 +710,5 @@ def get_sentinels(sentinels_string): ASSET_BUYOUT_CATEGORY_TO_MONTHS = json.loads(os.environ.get( 'ASSET_BUYOUT_CATEGORY_TO_MONTHS', '{}') ) + +DATA_UPLOAD_MAX_NUMBER_FIELDS = 3000