fix_refpoints_name.py 733 B

123456789101112131415161718192021
  1. # -*- coding: utf-8 -*-
  2. from __future__ import unicode_literals, division, print_function
  3. from django.core.management.base import BaseCommand
  4. from panorama.models import ReferencePoint
  5. class Command(BaseCommand):
  6. help = 'Fix name of reference points, to avoid special characters'
  7. def handle(self, *args, **options):
  8. nb_fixed = 0
  9. for refpoint in ReferencePoint.objects.all():
  10. if "'" in refpoint.name:
  11. self.stdout.write("Fixing refpoint name: {}".format(refpoint.name))
  12. refpoint.name = refpoint.name.replace("'", " ")
  13. refpoint.save()
  14. nb_fixed += 1
  15. self.stdout.write("Fixed {} reference point names".format(nb_fixed))