Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new statuses for assets #3744

Merged
merged 3 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/ralph/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from ralph.admin.helpers import getattr_dunder
from ralph.admin.mixins import RalphAdminFormMixin
from ralph.admin.views.extra import RalphDetailView
from ralph.back_office.models import BackOfficeAsset
from ralph.back_office.models import BackOfficeAsset, BackOfficeAssetStatus
from ralph.lib.table import Table
from ralph.lib.transitions.models import TransitionsHistory
from ralph.licences.models import Licence
Expand Down Expand Up @@ -95,6 +95,11 @@ def clean_password(self):
class AssetList(Table):

def buyout_date(self, item):
if item.status in [
BackOfficeAssetStatus.in_use_team.id,
BackOfficeAssetStatus.in_use_test.id
]:
return ''
if item.model.category.show_buyout_date:
return item.buyout_date
return '—'
Expand All @@ -119,6 +124,11 @@ def user_licence(self, item):
def buyout_ticket(self, item):
if not item.model.category.show_buyout_date:
return ''
if item.status in [
BackOfficeAssetStatus.in_use_team.id,
BackOfficeAssetStatus.in_use_test.id
]:
return ''
else:
get_params = {
"inventory_number": item.barcode,
Expand Down
20 changes: 20 additions & 0 deletions src/ralph/back_office/migrations/0015_auto_20221207_1445.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
import ralph.lib.transitions.fields


class Migration(migrations.Migration):

dependencies = [
('back_office', '0014_auto_20221108_1007'),
]

operations = [
migrations.AlterField(
model_name='backofficeasset',
name='status',
field=ralph.lib.transitions.fields.TransitionField(default=1, choices=[(1, 'new'), (2, 'in progress'), (3, 'waiting for release'), (4, 'in use'), (5, 'loan'), (6, 'damaged'), (7, 'liquidated'), (8, 'in service'), (9, 'installed'), (10, 'free'), (11, 'reserved'), (12, 'sale'), (13, 'loan in progress'), (14, 'return in progress'), (15, 'to find'), (16, 'sent'), (17, 'buyout'), (18, 'in use team'), (19, 'in use test')]),
),
]
2 changes: 2 additions & 0 deletions src/ralph/back_office/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class BackOfficeAssetStatus(Choices):
to_find = _("to find")
sent = _("sent")
buyout = _("buyout")
in_use_team = _("in use team")
in_use_test = _("in use test")


class OfficeInfrastructure(
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/data_importer/tests/test_demo_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ class DemoDataTestCase(TestCase):
def test_demo_data_command(self):
management.call_command('demodata')
self.assertEqual(DataCenterAsset.objects.count(), 422)
self.assertEqual(BackOfficeAsset.objects.count(), 248)
self.assertEqual(BackOfficeAsset.objects.count(), 256)
self.assertEqual(get_user_model().objects.count(), 33)