Skip to content

Instantly share code, notes, and snippets.

@firm1
Last active August 22, 2016 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save firm1/7c1e63e51da6a8c8c37501b95a3acd74 to your computer and use it in GitHub Desktop.
Save firm1/7c1e63e51da6a8c8c37501b95a3acd74 to your computer and use it in GitHub Desktop.
python manage.py shell < update-tags.py
from zds.utils.models import Tag
from zds.forum.models import Topic
mapping = {}
mapping["458"] = "368" # accepté → acceptée
mapping["838"] = "87" # adroid → android
mapping["1101"] = "437" # aglo → algorithme
mapping["703"] = "646" # algorithmie → algorithmique
mapping["1587"] = "437" # algorythme → algorithme
mapping["2109"] = "1505" # architechture → architecture
mapping["1493"] = "1871" # bonne pratiques → bonnes pratiques
mapping["1728"] = "1141" # code::block → code::blocks
mapping["1292"] = "694" # convertion → conversion
mapping["1615"] = "541" # gtk → gtk+
mapping["1857"] = "377" # idea → ide
mapping["1621"] = "1663" # javae → java ee
mapping["1748"] = "81" # javascrip → javascript
mapping["970"] = "1663" # jee → java ee
mapping["1475"] = "100" # linx → linux
mapping["570"] = "1363" # machine virtuel → machine vituelle
mapping["781"] = "789" # mails → mail
mapping["284"] = "24" # math → maths
mapping["207"] = "24" # mathematique → maths
mapping["1371"] = "608" # matploplib → matplotlib
mapping["806"] = "429" # mysq → mysql
mapping["334"] = "1291" # nodejs → node.js
mapping["1286"] = "1092" # open-source → open source
mapping["281"] = "1852" # oxs → os x
mapping["1396"] = "1440" # parcour → parcours
mapping["590"] = "79" # résaux → réseau
mapping["1044"] = "6" # sugestion → suggestion
mapping["2084"] = "199" # ubunru → ubuntu
mapping["601"] = "1779" # versionning → versioning
mapping["1605"] = "1735" # workfow → workflow
topics = Topic.objects.all().order_by('-pubdate') # du plus vieux au plus jeune
cpt = 0
for topic in topics:
topic_tags = topic.tags.all()
for tag in topic_tags:
if str(tag.pk) in mapping :
target = mapping[str(tag.pk)]
if target:
target_tag = Tag.objects.get(pk=target)
#topic.tags.add(target_tag)
print(u"\n'{}' --> '{}'\n".format(tag.title, target_tag.title))
#topic.tags.remove(tag)
#topic.save()
cpt += 1
print(u"\nNombre de sujets modifiés : {}\n".format(cpt))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment