nanterre: journalise les déclarations de faux doublons (fixes #20354)
This commit is contained in:
parent
c53ff1d74f
commit
d840b81018
|
@ -3,10 +3,11 @@ import copy
|
|||
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
from zoo.zoo_nanterre.models import Duplicate
|
||||
from zoo.zoo_data.models import Log
|
||||
|
||||
|
||||
def test_list_doublons(nanterre_classic_family, app):
|
||||
from zoo.zoo_nanterre.models import Duplicate
|
||||
|
||||
e = nanterre_classic_family
|
||||
|
||||
url = reverse('rsu-api-doublons')
|
||||
|
@ -51,6 +52,7 @@ def test_list_doublons(nanterre_classic_family, app):
|
|||
assert response.json['data'][0]['score'] == 100
|
||||
first_data = response.json['data'][0]
|
||||
second_data = response.json['data'][1]
|
||||
third_data = response.json['data'][2]
|
||||
|
||||
url = reverse('rsu-api-doublons') + '?limit=100'
|
||||
response = app.get(url)
|
||||
|
@ -85,6 +87,10 @@ def test_list_doublons(nanterre_classic_family, app):
|
|||
response = app.post(false_positive_url)
|
||||
assert response.json['err'] == 0
|
||||
assert Duplicate.objects.get(id=second_data['id']).state == Duplicate.STATE_FALSE_POSITIVE
|
||||
log = Log.objects.filter(entity_id=second_data['individu_1']['id']).latest('id')
|
||||
assert 'non doublon de' in log.content['text']
|
||||
log = Log.objects.filter(entity_id=second_data['individu_2']['id']).latest('id')
|
||||
assert 'non doublon de' in log.content['text']
|
||||
|
||||
url = reverse('rsu-api-doublons') + '?false_positive=1'
|
||||
response = app.get(url)
|
||||
|
@ -121,3 +127,19 @@ def test_list_doublons(nanterre_classic_family, app):
|
|||
assert 'more' not in response.json
|
||||
assert 'cookie' not in response.json
|
||||
assert len(response.json['data']) == 89
|
||||
|
||||
false_positive_url = reverse('rsu-api-doublon-false-positive', kwargs={
|
||||
'doublon_id': '%s %s' % (
|
||||
third_data['individu_1']['id'],
|
||||
third_data['individu_2']['id'],
|
||||
)
|
||||
})
|
||||
response = app.post_json(false_positive_url, params={'journal_form_id': 103})
|
||||
assert response.json['err'] == 0
|
||||
assert Duplicate.objects.get(id=third_data['id']).state == Duplicate.STATE_FALSE_POSITIVE
|
||||
log = Log.objects.filter(entity_id=third_data['individu_1']['id']).latest('id')
|
||||
assert 'non doublon de' in log.content['text']
|
||||
assert log.content['meta']['form_id'] == 103
|
||||
log = Log.objects.filter(entity_id=third_data['individu_2']['id']).latest('id')
|
||||
assert 'non doublon de' in log.content['text']
|
||||
assert log.content['meta']['form_id'] == 103
|
||||
|
|
|
@ -1989,8 +1989,21 @@ class DoublonActionView(DoublonMixin, TransactionalView):
|
|||
|
||||
class FalsePositiveView(DoublonActionView):
|
||||
def action(self, request, duplicate):
|
||||
serializer = JournalSerializerMixin(data=request.data)
|
||||
try:
|
||||
duplicate.false_positive()
|
||||
utils.journalize(
|
||||
duplicate.first,
|
||||
transaction=self.transaction,
|
||||
meta=serializer.journal_meta,
|
||||
faux_positif=duplicate.second.id,
|
||||
text=u'Déclaré comme non doublon de #%d' % duplicate.second.id)
|
||||
utils.journalize(
|
||||
duplicate.second,
|
||||
transaction=self.transaction,
|
||||
meta=serializer.journal_meta,
|
||||
faux_positif=duplicate.first.id,
|
||||
text=u'Déclaré comme non doublon de #%d' % duplicate.first.id)
|
||||
return Response({
|
||||
'err': 0,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue