0002-base-export-only-editable-fields-51724.patch
passerelle/base/models.py | ||
---|---|---|
358 | 358 |
concrete_fields = [ |
359 | 359 |
f |
360 | 360 |
for f in self.__class__._meta.get_fields() |
361 |
if f.concrete and (not f.is_relation or f.one_to_one or (f.many_to_one and f.related_model)) |
|
361 |
if f.concrete |
|
362 |
and f.editable |
|
363 |
and (not f.is_relation or f.one_to_one or (f.many_to_one and f.related_model)) |
|
362 | 364 |
] |
363 | 365 |
for field in concrete_fields: |
364 | 366 |
if field.name == 'id': |
... | ... | |
429 | 431 |
concrete_fields = [ |
430 | 432 |
f |
431 | 433 |
for f in cls._meta.get_fields() |
432 |
if f.concrete and (not f.is_relation or f.one_to_one or (f.many_to_one and f.related_model)) |
|
434 |
if f.concrete |
|
435 |
and f.editable |
|
436 |
and (not f.is_relation or f.one_to_one or (f.many_to_one and f.related_model)) |
|
433 | 437 |
] |
434 | 438 |
for field in concrete_fields: |
435 | 439 |
if field.name == 'id': |
tests/test_import_export.py | ||
---|---|---|
10 | 10 |
from django.core.management import call_command |
11 | 11 |
from django.contrib.contenttypes.models import ContentType |
12 | 12 |
from django.test import Client |
13 |
from django.utils import timezone |
|
13 | 14 |
from django.utils.encoding import force_bytes, force_text |
14 | 15 |
from django.utils.six import BytesIO, StringIO |
15 | 16 | |
16 | 17 |
from passerelle.apps.base_adresse.models import BaseAdresse |
18 |
from passerelle.apps.ovh.models import OVHSMSGateway |
|
17 | 19 |
from passerelle.base.models import ApiUser, AccessRight |
18 | 20 |
from passerelle.compat import json_loads |
19 | 21 |
from passerelle.utils import import_site, export_site |
... | ... | |
245 | 247 |
ba_export = ba.export_json() |
246 | 248 |
new_ba = BaseAdresse.import_json(ba_export, overwrite=True) |
247 | 249 |
assert ba == new_ba |
250 | ||
251 | ||
252 |
def test_export_ovh(): |
|
253 |
ovh = OVHSMSGateway.objects.create( |
|
254 |
slug='test-ovh', |
|
255 |
title='Test OVH', |
|
256 |
account='sms-test42', |
|
257 |
application_key='RHrTdU2oTsrVC0pu', |
|
258 |
application_secret='CLjtS69tTcPgCKxedeoZlgMSoQGSiXMa', |
|
259 |
consumer_key='iF0zi0MJrbjNcI3hvuvwkhNk8skrigxz', |
|
260 |
credit_threshold_alert=100, |
|
261 |
credit_left=102, |
|
262 |
credit_alert_timestamp=timezone.now(), |
|
263 |
alert_emails=['test@entrouvert.org'], |
|
264 |
) |
|
265 | ||
266 |
ovh_export = ovh.export_json() |
|
267 |
ovh.delete() |
|
268 |
new_ovh = OVHSMSGateway.import_json(ovh_export) |
|
269 |
assert new_ovh.alert_emails == ovh.alert_emails |
|
270 |
assert new_ovh.credit_alert_timestamp is None |
|
271 |
assert new_ovh.credit_left == 0 |
|
248 |
- |