You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0003_mv_entries_to_password.py 1.1 KiB

12345678910111213141516171819202122232425262728293031323334353637
  1. # -*- coding: utf-8 -*-
  2. # Generated by Django 1.9.6 on 2016-09-24 08:13
  3. from __future__ import unicode_literals
  4. from django.db import migrations
  5. import json
  6. from api import models
  7. def create_password_with(entry):
  8. settings = json.dumps(entry.password.settings)
  9. lowercase = 'lowercase' in settings
  10. uppercase = 'uppercase' in settings
  11. symbols = 'symbols' in settings
  12. numbers = 'numbers' in settings
  13. user = models.LessPassUser.objects.get(id=entry.user.id)
  14. models.Password.objects.create(id=entry.id, site=entry.site, login=entry.login, user=user,
  15. lowercase=lowercase, uppercase=uppercase, symbols=symbols, numbers=numbers,
  16. counter=entry.password.counter, length=entry.password.length)
  17. def mv_entries_to_password(apps, schema_editor):
  18. Entry = apps.get_model("api", "Entry")
  19. for entry in Entry.objects.all():
  20. create_password_with(entry)
  21. class Migration(migrations.Migration):
  22. dependencies = [
  23. ('api', '0002_password'),
  24. ]
  25. operations = [
  26. migrations.RunPython(mv_entries_to_password),
  27. ]