-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove transaction identifier, attribution type and attribution reason
- Loading branch information
Showing
9 changed files
with
110 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Generated by Django 5.0.6 on 2024-08-01 08:39 | ||
|
||
from django.db import migrations, models | ||
from django.db.models import Q | ||
|
||
|
||
def move_data_to_notes(apps, schema_editor): | ||
ADS = apps.get_model("app", "ADS") | ||
|
||
for ads in ADS.objects.filter( | ||
~Q(attribution_type="") | ||
| ~Q(transaction_identifier="") | ||
| ~Q(attribution_reason="") | ||
): | ||
notes = [] | ||
if ads.attribution_type != "": | ||
notes.append( | ||
{ | ||
"paid": "* L'ADS a été cédée au titulaire actuel à titre onéreux", | ||
"free": "* L'ADS a été délivrée au titulaire actuel par l'autorité compétente", | ||
"other": "", | ||
}[ads.attribution_type] | ||
) | ||
if ads.transaction_identifier: | ||
notes.append( | ||
f"* Numéro d'identification lié au registre des transactions : {ads.transaction_identifier}" | ||
) | ||
if ads.attribution_reason: | ||
notes.append( | ||
f"* Raison de l'attribution de l'ADS au titulaire actuel : {ads.attribution_reason}" | ||
) | ||
ads.notes = "\n".join(notes) | ||
ads.save() | ||
|
||
|
||
def do_nothing(apps, schema_editor): | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("app", "0084_alter_adsmanager_administrator"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="ads", | ||
name="notes", | ||
field=models.TextField( | ||
blank=True, | ||
help_text="Champ libre pour les informations complémentaires utiles (numéro d'enregistrement dans le registre des transactions, informations importantes concernant la délivrance ou la cession de l'ADS, etc…)", | ||
verbose_name="Notes sur l'ADS", | ||
), | ||
), | ||
migrations.RunPython(move_data_to_notes, do_nothing), | ||
] |
36 changes: 36 additions & 0 deletions
36
mesads/app/migrations/0086_remove_ads_attribution_type_empty_for_new_ads_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 5.0.6 on 2024-08-01 17:29 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("app", "0085_ads_notes"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveConstraint( | ||
model_name="ads", | ||
name="attribution_type_empty_for_new_ads", | ||
), | ||
migrations.RemoveConstraint( | ||
model_name="ads", | ||
name="transaction_identifier_empty_for_non_paid_ads", | ||
), | ||
migrations.RemoveConstraint( | ||
model_name="ads", | ||
name="attribution_reason_empty_for_new_ads", | ||
), | ||
migrations.RemoveField( | ||
model_name="ads", | ||
name="attribution_reason", | ||
), | ||
migrations.RemoveField( | ||
model_name="ads", | ||
name="attribution_type", | ||
), | ||
migrations.RemoveField( | ||
model_name="ads", | ||
name="transaction_identifier", | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters