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(Structures): historique de modification grâce à django-simple-history #1255

Merged
merged 6 commits into from
Jun 12, 2024

Conversation

raphodn
Copy link
Contributor

@raphodn raphodn commented Jun 9, 2024

Quoi ?

Ajout du packet django-simple-history

Script

// pour initialiser l'historique de chaque structure
poetry run python manage.py populate_history --auto
// pour corriger la date du premier log historique (matcher avec la date de création des structures)
from lemarche.siaes.models import Siae

for history_log in Siae.history.all():
    siae = Siae.objects.get(id=history_log.id)
    if not history_log.history_user_id:
        history_log.history_date = siae.created_at
        history_log.save()

Reste à faire

  • sauvegarde du formulaire coté utilisateur : éviter la double ligne d'historique ?
  • gérer les relations ?

@raphodn raphodn force-pushed the raphodn/siae-model-history branch from 8dea59e to c14acf4 Compare June 10, 2024 14:21
@raphodn raphodn marked this pull request as ready for review June 10, 2024 14:23
Copy link
Contributor

@SebastienReuiller SebastienReuiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG !
Belle trouvaille ce module, bien joué !
Par contre, ça risque de générer beaucoup de données, à surveiller.

Copy link
Contributor

@madjid-asa madjid-asa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

def test_history_object_on_create(self):
self.assertEqual(self.siae_1.history.count(), 1)
siae_1_create_history_item = self.siae_1.history.last()
self.assertEqual(siae_1_create_history_item.history_type, "+")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peut être ajouter des variables de class pour que ça puisse être réutilisé dans les autres tests et que ça soit mieux compris que c'est "l'ajout"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes bonne idée j'ai basculé dans constants : 55f232d

Copy link
Contributor Author

@raphodn raphodn Jun 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

à terme je pense qu'on aura un utils/history.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

edit : en fait j'ai créé et basculé dans utils/history.py c'est mieux : e0caf49

@raphodn raphodn merged commit 146ade4 into master Jun 12, 2024
8 checks passed
@raphodn raphodn deleted the raphodn/siae-model-history branch June 12, 2024 09:34
raphodn added a commit that referenced this pull request Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants