Open
Conversation
So a duplicate fingerprint would fail to pass unique test. Fixes:
+ francedata_import_representatives
cTraceback (most recent call last):
File "/home/jpic/work/lqdn/lqdn_env/bin/francedata_import_representatives", line 9, in <module>
load_entry_point('django-representatives==0.0.19', 'console_scripts', 'francedata_import_representatives')()
File "/home/jpic/work/lqdn/django-representatives/representatives/contrib/francedata/import_representatives.py", line 317, in main
an_importer.manage_rep(rep)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/utils/decorators.py", line 145, in inner
return func(*args, **kwargs)
File "/home/jpic/work/lqdn/django-representatives/representatives/contrib/francedata/import_representatives.py", line 145, in manage_rep
self.add_mandates(representative, rep_json)
File "/home/jpic/work/lqdn/django-representatives/representatives/contrib/francedata/import_representatives.py", line 184, in add_mandates
name=rep_json.get('parti_ratt_financier'), country=self.france)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/query.py", line 407, in get_or_create
return self._create_object_from_params(lookup, params)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/query.py", line 447, in _create_object_from_params
six.reraise(*exc_info)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/query.py", line 439, in _create_object_from_params
obj = self.create(**params)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/query.py", line 348, in create
obj.save(force_insert=True, using=self.db)
File "/home/jpic/work/lqdn/django-representatives/representatives/models.py", line 68, in save
super(HashableModel, self).save(*args, **kwargs)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/base.py", line 734, in save
force_update=force_update, update_fields=update_fields)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/base.py", line 762, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/base.py", line 846, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/base.py", line 885, in _do_insert
using=using, raw=raw)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/query.py", line 920, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/models/sql/compiler.py", line 974, in execute_sql
cursor.execute(sql, params)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/utils.py", line 98, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/jpic/work/lqdn/lqdn_env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 318, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: UNIQUE constraint failed: representatives_constituency.fingerprint
| @@ -175,6 +175,11 @@ class Chamber(HashableModel): | |||
|
|
|||
| hashable_fields = ['name', 'country', 'abbreviation'] | |||
Member
There was a problem hiding this comment.
Couldn't we get rid of hashable_fields and use the metaclass unique_together attribute in HashableModel.compute_hash ? That would avoid duplicating code.
(also is Meta.unique_together parsed by django-admin makemigrations ? or do we have to create the migration manually ?)
| related_name='constituencies') | ||
|
|
||
| hashable_fields = ['name'] | ||
| hashable_fields = ['name', 'country'] |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.