migrationutils.py 850 B

123456789101112131415161718192021222324252627282930
  1. from django.utils import translation
  2. from misago.core.cache import cache as default_cache
  3. from misago.core.cachebuster import CACHE_KEY
  4. def ugettext_lazy(string):
  5. """
  6. Custom wrapper that preserves untranslated message on lazy translation
  7. string object, useful for db entries that should be found by makemessages
  8. and stored untranslated
  9. """
  10. t = translation.ugettext_lazy(string)
  11. t.message = string
  12. return t
  13. def cachebuster_register_cache(orm, cache):
  14. orm.CacheVersion.objects.create(cache=cache)
  15. def cachebuster_unregister_cache(orm, cache):
  16. try:
  17. cache = orm.CacheVersion.objects.get(cache=cache)
  18. cache.delete()
  19. except orm.CacheVersion.DoesNotExist:
  20. raise ValueError('Cache "%s" is not registered' % cache)
  21. def delete_cachebuster_cache():
  22. default_cache.delete(CACHE_KEY)