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

feat(Besoins): Admin: pouvoir indiquer quelle structure a effectivement transactionnée #1133

Merged
merged 3 commits into from
Mar 20, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lemarche/tenders/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ class TenderSiaeInterestedInline(admin.TabularInline):
"detail_contact_click_date",
"survey_transactioned_send_date",
"survey_transactioned_answer",
"transactioned",
]
readonly_fields = [field.name for field in TenderSiae._meta.fields]
readonly_fields = [field.name for field in TenderSiae._meta.fields if field.name not in ["transactioned"]]
extra = 0
show_change_link = True
can_delete = False
Expand Down Expand Up @@ -822,18 +823,20 @@ def queryset(self, request, queryset):

@admin.register(TenderSiae, site=admin_site)
class TenderSiaeAdmin(admin.ModelAdmin):
list_display = ["created_at", "siae_with_app_link", "tender_with_link", "source", "status"]
list_display = ["created_at", "siae_with_app_link", "tender_with_link", "source", "status", "transactioned"]
list_filter = [
("source", TenderSiaeSourceFilter),
TenderSiaeStatusFilter,
"survey_transactioned_answer",
"transactioned",
]

readonly_fields = [field for field in TenderSiae.READONLY_FIELDS] + [
"siae",
"siae_with_app_link",
"tender",
"tender_with_link",
"transactioned_source",
"logs_display",
]

Expand All @@ -843,7 +846,10 @@ class TenderSiaeAdmin(admin.ModelAdmin):
{"fields": ("siae", "siae_with_app_link", "tender_with_link", "source", "found_with_ai")},
),
("Mise en relation", {"fields": (*TenderSiae.FIELDS_RELATION, "status")}),
("Transaction ?", {"fields": TenderSiae.FIELDS_SURVEY_TRANSACTIONED}),
(
"Transaction ?",
{"fields": (*TenderSiae.FIELDS_SURVEY_TRANSACTIONED, "transactioned", "transactioned_source")},
),
("Stats", {"fields": ("logs_display",)}),
("Dates", {"fields": ("created_at", "updated_at")}),
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 4.2.9 on 2024-03-20 09:45

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("tenders", "0081_merge_20240313_1141"),
]

operations = [
migrations.AddField(
model_name="tendersiae",
name="transactioned",
field=models.BooleanField(
blank=True,
help_text="Champ renseigné par un ADMIN",
null=True,
verbose_name="Abouti à une transaction avec l'acheteur",
),
),
migrations.AddField(
model_name="tendersiae",
name="transactioned_source",
field=models.CharField(
blank=True,
choices=[("ADMIN", "Admin"), ("AUTHOR", "Auteur"), ("SIAE", "Structure")],
help_text="Champ mis à jour automatiquement",
max_length=20,
null=True,
verbose_name="Abouti à une transaction avec l'acheteur : source",
),
),
]
18 changes: 17 additions & 1 deletion lemarche/tenders/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ class TenderSiae(models.Model):
detail_not_interested_click_date = models.DateTimeField("Date de clic sur Pas intéressé", blank=True, null=True)
detail_not_interested_feedback = models.TextField(verbose_name="Clic sur Pas intéréssé : explication", blank=True)

# stats: transaction
# survey
survey_transactioned_send_date = models.DateTimeField(
verbose_name="Sondage transaction : date d'envoi de l'e-mail", blank=True, null=True
)
Expand All @@ -1111,6 +1111,22 @@ class TenderSiae(models.Model):
"Sondage transaction : date de réponse", blank=True, null=True
)

# admin
transactioned = models.BooleanField(
verbose_name="Abouti à une transaction avec l'acheteur",
help_text=ADMIN_FIELD_HELP_TEXT,
blank=True,
null=True,
)
transactioned_source = models.CharField(
verbose_name="Abouti à une transaction avec l'acheteur : source",
help_text=AUTO_FIELD_HELP_TEXT,
max_length=20,
choices=tender_constants.TENDER_SIAE_TRANSACTIONED_SOURCE_CHOICES,
blank=True,
null=True,
)

logs = models.JSONField(verbose_name="Logs historiques", editable=False, default=list)

created_at = models.DateTimeField(verbose_name="Date de création", default=timezone.now)
Expand Down
Loading