summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-11-12 10:16:22 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-02-28 12:15:21 +0100
commit7eff9126774f83272fcfefa3d91ab59018d1c018 (patch)
tree3fbdbb6b40497de72f8168f6863359f11bf23d29 /scripts
parent609a19d9e8a4210d96aab928bac9bcbd3fff5613 (diff)
downloadIshtar-7eff9126774f83272fcfefa3d91ab59018d1c018.tar.bz2
Ishtar-7eff9126774f83272fcfefa3d91ab59018d1c018.zip
Clean some old scripts
Diffstat (limited to 'scripts')
-rw-r--r--scripts/2016-09-29-clean-dup-towns-pdl.py51
-rw-r--r--scripts/2017-03-08-importer-basefind-to-find.py35
-rw-r--r--scripts/2017-03-29-missing-rights.py24
3 files changed, 0 insertions, 110 deletions
diff --git a/scripts/2016-09-29-clean-dup-towns-pdl.py b/scripts/2016-09-29-clean-dup-towns-pdl.py
deleted file mode 100644
index ebacb2fdf..000000000
--- a/scripts/2016-09-29-clean-dup-towns-pdl.py
+++ /dev/null
@@ -1,51 +0,0 @@
-from ishtar_common.models import Town
-
-
-dup_nb = 0
-pdl = []
-DPTS = ('44', '49', '53', '72', '85')
-
-for dpt in DPTS:
- for town in Town.objects.filter(numero_insee__startswith=dpt):
- pdl.append(town.pk)
- for dup in Town.objects.filter(name=town.name).exclude(pk=town.pk):
- not_dup = False
- for d in DPTS:
- if dup.numero_insee.startswith(d):
- not_dup = True
- if not_dup:
- continue
- for item in dup.file_main.all():
- item.main_town = town
- p = item.save()
- for item in dup.parcels.all():
- item.main_town = town
- p = item.save()
- for item in dup.file.all():
- item.towns.remove(dup)
- item.towns.add(town)
- for item in dup.operations.all():
- item.towns.remove(dup)
- item.towns.add(town)
- dup_nb += 1
- dup.delete()
-
-
-print("{} items cleaned".format(dup_nb))
-
-strange = []
-for town in Town.objects.exclude(pk__in=pdl):
- if (town.file_main.count() or town.parcels.count() or town.file.count() or
- town.operations.count()):
- strange.append((town, town.file_main.count(), town.parcels.count(),
- town.file.count(), town.operations.count()))
- continue
- town.delete()
-
-
-print('* Problems with:')
-for t in strange:
- print("{}: \n\t* {} ville principale dossier\n\t* {} parcelles\n\t* {} "
- "villes pour"
- " dossier\n\t* {} ville pour operation".format(t[0], t[1], t[2],
- t[3], t[4]))
diff --git a/scripts/2017-03-08-importer-basefind-to-find.py b/scripts/2017-03-08-importer-basefind-to-find.py
deleted file mode 100644
index fa5da9855..000000000
--- a/scripts/2017-03-08-importer-basefind-to-find.py
+++ /dev/null
@@ -1,35 +0,0 @@
-from ishtar_common import models
-
-
-def convert_field(field_name):
- if field_name.startswith('find__'):
- field_name = field_name[len('find__'):]
- else:
- field_name = "base_finds__" + field_name
- return field_name
-
-
-def refac_types(types):
- find_model, created = models.ImporterModel.objects.get_or_create(
- klass='archaeological_finds.models_finds.Find',
- defaults={'name': 'Find'}
- )
- for tpe in types:
- for col in tpe.columns.all():
- for field in col.duplicate_fields.all():
- new_field_name = convert_field(field.field_name)
- field.field_name = new_field_name
- field.save()
- for field in col.targets.all():
- new_field_name = convert_field(field.target)
- field.target = new_field_name
- field.save()
- tpe.associated_models = find_model
- tpe.save()
-
-
-types = list(models.ImporterType.objects.filter(
- associated_models=models.ImporterModel.objects.get(
- klass='archaeological_finds.models.BaseFind')).all())
-
-refac_types(types)
diff --git a/scripts/2017-03-29-missing-rights.py b/scripts/2017-03-29-missing-rights.py
deleted file mode 100644
index 81a9b86ee..000000000
--- a/scripts/2017-03-29-missing-rights.py
+++ /dev/null
@@ -1,24 +0,0 @@
-from django.contrib.auth.models import Group, Permission
-
-for group in Group.objects.all():
- if ':' not in group.name or u"rattaché" in group.name:
- continue
- permissions = []
- for perm in group.permissions.all():
- codenames = perm.codename.split('_')
- own_codename = codenames[0] + "_own_" + '_'.join(codenames[1:])
- if Permission.objects.filter(codename=own_codename).count():
- permissions.append(Permission.objects.get(codename=own_codename))
- if not permissions:
- print(u'No permission: ' + group.name)
- continue
- names = group.name.split(':')
- if Group.objects.filter(name__startswith=names[0] + u"rattaché",
- name__endswith=names[1]).count():
- print(u'Already here: ' + group.name)
- continue
- name = names[0] + u"rattachés " + u":" + names[1]
- new_group = Group.objects.create(name=name)
- for perm in permissions:
- new_group.permissions.add(perm)
- print(u'New: ' + group.name)