remakemisagochecksums.py 854 B

123456789101112131415161718192021
  1. from django.core.management.base import BaseCommand
  2. from django.utils.encoding import force_str
  3. from django.utils.six.moves import input
  4. from misago.core.signals import secret_key_changed
  5. class Command(BaseCommand):
  6. help = 'Regenerates Misago checksums after SECRET_KEY changed.'
  7. def handle(self, *args, **options):
  8. message = force_str("This will replace all checksums "
  9. "in database with new ones, marking "
  10. "all data as trusted. Are you sure "
  11. "you wish to continue? [Y/n]")
  12. if '--force' in args or input(message).strip().lower() == "y":
  13. self.stdout.write("\nRegenerating checksums...")
  14. secret_key_changed.send(self)
  15. self.stdout.write("\nDone!")
  16. else:
  17. self.stdout.write("\nAborted!")