-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fix le bug sur les plantes dans le CompositionStep et les preparations viennent du backend #897
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
758c0e3
add Preparation model, serializer, specific importer
87155cf
use backend preparation in front
5b62726
change in DeclarationSummary
350acfb
add missing file
abe89cc
add csv file
e5c2770
Merge branch 'staging' into 895
alemangui f011baa
Adds merge migration
alemangui 4512389
add csv file
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from rest_framework import serializers | ||
|
||
from data.models import Preparation | ||
|
||
|
||
class PreparationSerializer(serializers.ModelSerializer): | ||
# TODO make a unique abstract class for all simple models (Condition, Effect, Preparation, Population...) | ||
class Meta: | ||
model = Preparation | ||
fields = [ | ||
"id", | ||
"name", | ||
"name_en", | ||
] | ||
read_only_fields = fields |
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,10 @@ | ||
from rest_framework.generics import ListAPIView | ||
|
||
from api.serializers import PreparationSerializer | ||
from data.models import Preparation | ||
|
||
|
||
class PreparationListView(ListAPIView): | ||
model = Preparation | ||
serializer_class = PreparationSerializer | ||
queryset = Preparation.objects.filter(missing_import_data=False, siccrf_is_obsolete=False) |
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
182 changes: 182 additions & 0 deletions
182
data/migrations/0086_preparation_historicalpreparation.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,182 @@ | ||
# Generated by Django 5.1 on 2024-08-26 14:26 | ||
|
||
import django.db.models.deletion | ||
import django.db.models.functions.comparison | ||
import simple_history.models | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("data", "0085_companyaccessclaim_declarant_role_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Preparation", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("creation_date", models.DateTimeField(auto_now_add=True)), | ||
("modification_date", models.DateTimeField(auto_now=True)), | ||
( | ||
"missing_import_data", | ||
models.BooleanField( | ||
blank=True, default=False, editable=False, null=True | ||
), | ||
), | ||
( | ||
"siccrf_id", | ||
models.IntegerField( | ||
blank=True, | ||
db_index=True, | ||
editable=False, | ||
null=True, | ||
unique=True, | ||
verbose_name="id dans les tables et tables relationnelles SICCRF", | ||
), | ||
), | ||
( | ||
"siccrf_name", | ||
models.TextField(editable=False, verbose_name="nom SICCRF"), | ||
), | ||
("ca_name", models.TextField(blank=True, verbose_name="nom CA")), | ||
( | ||
"name", | ||
models.GeneratedField( | ||
db_persist=True, | ||
expression=django.db.models.functions.comparison.Coalesce( | ||
django.db.models.functions.comparison.NullIf( | ||
models.F("ca_name"), models.Value("") | ||
), | ||
models.F("siccrf_name"), | ||
), | ||
output_field=models.TextField(verbose_name="nom"), | ||
), | ||
), | ||
( | ||
"siccrf_is_obsolete", | ||
models.BooleanField( | ||
default=False, | ||
editable=False, | ||
verbose_name="objet obsolète selon SICCRF", | ||
), | ||
), | ||
( | ||
"ca_is_obsolete", | ||
models.BooleanField( | ||
default=None, null=True, verbose_name="objet obsolète selon CA" | ||
), | ||
), | ||
( | ||
"is_obsolete", | ||
models.GeneratedField( | ||
db_persist=True, | ||
expression=django.db.models.functions.comparison.Coalesce( | ||
models.F("ca_is_obsolete"), models.F("siccrf_is_obsolete") | ||
), | ||
output_field=models.BooleanField(verbose_name="objet obsolète"), | ||
), | ||
), | ||
( | ||
"siccrf_name_en", | ||
models.TextField( | ||
blank=True, verbose_name="nom en anglais selon la base SICCRF" | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "préparation de plantes", | ||
"verbose_name_plural": "préparations de plantes", | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="HistoricalPreparation", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigIntegerField( | ||
auto_created=True, blank=True, db_index=True, verbose_name="ID" | ||
), | ||
), | ||
("creation_date", models.DateTimeField(blank=True, editable=False)), | ||
("modification_date", models.DateTimeField(blank=True, editable=False)), | ||
( | ||
"missing_import_data", | ||
models.BooleanField( | ||
blank=True, default=False, editable=False, null=True | ||
), | ||
), | ||
( | ||
"siccrf_id", | ||
models.IntegerField( | ||
blank=True, | ||
db_index=True, | ||
editable=False, | ||
null=True, | ||
verbose_name="id dans les tables et tables relationnelles SICCRF", | ||
), | ||
), | ||
( | ||
"siccrf_name", | ||
models.TextField(editable=False, verbose_name="nom SICCRF"), | ||
), | ||
("ca_name", models.TextField(blank=True, verbose_name="nom CA")), | ||
( | ||
"siccrf_is_obsolete", | ||
models.BooleanField( | ||
default=False, | ||
editable=False, | ||
verbose_name="objet obsolète selon SICCRF", | ||
), | ||
), | ||
( | ||
"ca_is_obsolete", | ||
models.BooleanField( | ||
default=None, null=True, verbose_name="objet obsolète selon CA" | ||
), | ||
), | ||
( | ||
"siccrf_name_en", | ||
models.TextField( | ||
blank=True, verbose_name="nom en anglais selon la base SICCRF" | ||
), | ||
), | ||
("history_id", models.AutoField(primary_key=True, serialize=False)), | ||
("history_date", models.DateTimeField(db_index=True)), | ||
("history_change_reason", models.CharField(max_length=100, null=True)), | ||
( | ||
"history_type", | ||
models.CharField( | ||
choices=[("+", "Created"), ("~", "Changed"), ("-", "Deleted")], | ||
max_length=1, | ||
), | ||
), | ||
( | ||
"history_user", | ||
models.ForeignKey( | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="+", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
options={ | ||
"verbose_name": "historical préparation de plantes", | ||
"verbose_name_plural": "historical préparations de plantes", | ||
"ordering": ("-history_date", "-history_id"), | ||
"get_latest_by": ("history_date", "history_id"), | ||
}, | ||
bases=(simple_history.models.HistoricalChanges, models.Model), | ||
), | ||
] |
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,12 @@ | ||
# Generated by Django 5.1 on 2024-08-27 08:20 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("data", "0086_preparation_historicalpreparation"), | ||
("data", "0087_declaration_other_conditions_and_more"), | ||
] | ||
|
||
operations = [] |
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,18 @@ | ||
from django.db import models | ||
|
||
from simple_history.models import HistoricalRecords | ||
|
||
from .abstract_models import CommonModel | ||
|
||
|
||
class Preparation(CommonModel): | ||
class Meta: | ||
verbose_name = "préparation de plantes" | ||
verbose_name_plural = "préparations de plantes" | ||
|
||
siccrf_name_en = models.TextField(blank=True, verbose_name="nom en anglais selon la base SICCRF") | ||
history = HistoricalRecords(inherit=True, excluded_fields=["name", "is_obsolete"]) | ||
|
||
@property | ||
def name_en(self): | ||
return self.siccrf_name_en |
Binary file not shown.
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,29 @@ | ||
"TYPPREP_IDENT","TYPPREP_LIBELLE","TYPPREP_LIBELLE_EN","TYPPREP_ORDRE","TYPPREP_OBSOLET","TYPPREP_EST_SOLVANT" | ||
1,"Alcoolat","Alcoholate",,"False","False" | ||
2,"Alcoolature","Alcoholature",,"False","False" | ||
3,"Autre extrait fluide","Other liquid extract",,"False","False" | ||
4,"Autre extrait sec","Other dry extract",,"False","False" | ||
5,"Autre macérât","Other macerate",,"False","False" | ||
6,"Baume","Balm",,"False","False" | ||
7,"Extrait au CO2 supercritique","Supercritical CO2 extract",,"False","False" | ||
8,"Extrait fluide alcoolique","Alcohol liquid extract",,"False","False" | ||
9,"Extrait fluide aqueux","Water liquid extract",,"False","False" | ||
10,"Extrait fluide hydroalcoolique","Water & alcohol liquid extract",,"False","False" | ||
11,"Extrait fluide hydroglycériné","Water & glycerine liquid extract",,"False","False" | ||
12,"Extrait mou","Soft extract",,"False","False" | ||
13,"Extrait sec alcoolique","Alcohol dry extract",,"False","False" | ||
14,"Extrait sec aqueux","Water dry extract",,"False","False" | ||
15,"Extrait sec hydroalcoolique","Water & alcohol dry extract",,"False","False" | ||
16,"Extrait sec hydroglycériné","Water & glycerine dry extract",,"False","False" | ||
17,"Huile essentielle","Essential oil",,"True","False" | ||
18,"Hydrolât (eau florale)","Hydrolat (plant water essence)",,"False","False" | ||
19,"Macérât alcoolique","Alcohol macerate",,"False","False" | ||
20,"Macérât aqueux","Water macerate",,"False","False" | ||
21,"Macérât huileux","Oil macerate",,"False","False" | ||
22,"Macérât hydroalcoolique","Water & alcohol macerate",,"False","False" | ||
23,"Macérât hydroglycériné","Water & glycerine macerate",,"False","False" | ||
24,"Oléorésine et gomme-oléorésine","Oleoresin and gum-oleoresin",,"False","False" | ||
25,"Poudre (de plantes séchées ou broyées)","Powder (Communited or dried herbs)",,"False","False" | ||
26,"Teinture","Tincture",,"False","False" | ||
27,"Pression à froid","Cold pressing",,"False","False" | ||
28,"Distillation","Distillation",,"False","False" |
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ici, je n'ai pas compris pourquoi l'id (IntegerField) est sérialisé en tant que string.
C'est le cas aussi pour le modèle GalenicFormulation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
La sérialisation backend est bien un integer, mais le input
select
du html renvoi toujours un string. Sur cette question SO ça parle du pourquoi on ne peut pas retourner un int d'un select.