migrationutils.py 776 B

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