Skip to content

Commit

Permalink
add admin for tender steps data
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Oct 10, 2023
1 parent f24a8b2 commit e65f30d
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
22 changes: 21 additions & 1 deletion lemarche/tenders/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from lemarche.perimeters.admin import PerimeterRegionFilter
from lemarche.tenders import constants
from lemarche.tenders.forms import TenderAdminForm
from lemarche.tenders.models import PartnerShareTender, Tender, TenderQuestion
from lemarche.tenders.models import PartnerShareTender, Tender, TenderQuestion, TenderStepsData
from lemarche.utils.admin.admin_site import admin_site
from lemarche.utils.apis import api_hubspot
from lemarche.utils.fields import ChoiceArrayField, pretty_print_readonly_jsonfield
Expand Down Expand Up @@ -591,3 +591,23 @@ def logs_display(self, partnersharetender=None):
return "-"

logs_display.short_description = PartnerShareTender._meta.get_field("logs").verbose_name


@admin.register(TenderStepsData, site=admin_site)
class TenderStepsDataAdmin(admin.ModelAdmin):
list_display = ["created_at", "updated_at", "uuid"]

readonly_fields = [
"id",
"created_at",
"updated_at",
"uuid",
"steps_data_display",
]

def steps_data_display(self, tender_steps_data: TenderStepsData = None):
if tender_steps_data:
return pretty_print_readonly_jsonfield(tender_steps_data.steps_data)
return "-"

steps_data_display.short_description = "Données saisies dans les étapes"
6 changes: 5 additions & 1 deletion lemarche/tenders/migrations/0058_tenderstepsdata.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.2 on 2023-10-05 14:15
# Generated by Django 4.2.2 on 2023-10-09 12:32

from django.db import migrations, models
import django.utils.timezone
Expand Down Expand Up @@ -36,5 +36,9 @@ class Migration(migrations.Migration):
("updated_at", models.DateTimeField(auto_now=True, verbose_name="Date de modification")),
("steps_data", models.JSONField(default=list, editable=False, verbose_name="Données des étapes")),
],
options={
"verbose_name": "Besoin d'achat - Données des étapes",
"verbose_name_plural": "Besoins d'achat - Données des étapes",
},
),
]
7 changes: 7 additions & 0 deletions lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,3 +777,10 @@ class TenderStepsData(models.Model):
auto_created=True,
)
steps_data = models.JSONField(verbose_name="Données des étapes", editable=False, default=list)

class Meta:
verbose_name = "Besoin d'achat - Données des étapes"
verbose_name_plural = "Besoins d'achat - Données des étapes"

def __str__(self):
return f"{self.uuid} - {self.created_at}"

0 comments on commit e65f30d

Please sign in to comment.