Пример #1
0
 def get_manifest(self, update=False):
     """
     Either get the manifest file out of the cache or render it and save in
     the cache.
     """
     if not is_manifest_clean() and update:
         self.context = {
             'version':
             self.get_version_timestamp(),
             'date':
             datetime.fromtimestamp(self.get_version_timestamp() /
                                    1000000).isoformat(),
             'cached_urls':
             sorted(self.get_cached_urls()),
             'network_urls':
             sorted(self.get_network_urls()),
             'fallback_urls':
             self.get_fallback_urls(),
         }
         context = RequestContext(self.request, self.context)
         manifest = render_to_string(self._template,
                                     context_instance=context)
         set_cached_manifest(manifest)
         return manifest
     else:
         return get_cached_manifest()
Пример #2
0
 def get(self, request, *args, **kwargs):
     if (request.user.is_authenticated() and
             request.user.has_perm('html5_appcache.can_view_cache_status')):
         filepath = os.path.join(settings.STATIC_ROOT, "img", "%s.png" % (
             self.icons[int(is_manifest_clean())]
         ) )
         with open(filepath, "rb") as wrapper:
             response = HttpResponse(list(wrapper), content_type='text/plain')
             response['Content-Length'] = os.path.getsize(filepath)
             return response
     else:
         return HttpResponseForbidden(
             _("Current user is not authorized for this action"))
Пример #3
0
 def get(self, request, *args, **kwargs):
     if (request.user.is_authenticated() and
             request.user.has_perm('html5_appcache.can_view_cache_status')):
         filepath = os.path.join(
             settings.STATIC_ROOT, "img",
             "%s.png" % (self.icons[int(is_manifest_clean())]))
         with open(filepath, "rb") as wrapper:
             response = HttpResponse(list(wrapper),
                                     content_type='text/plain')
             response['Content-Length'] = os.path.getsize(filepath)
             return response
     else:
         return HttpResponseForbidden(
             _("Current user is not authorized for this action"))
 def get_manifest(self, update=False):
     """
     Either get the manifest file out of the cache or render it and save in
     the cache.
     """
     if not is_manifest_clean() and update:
         self.context = {
             'version': self.get_version_timestamp(),
             'date': datetime.fromtimestamp(self.get_version_timestamp()/1000000).isoformat(),
             'cached_urls': sorted(self.get_cached_urls()),
             'network_urls': sorted(self.get_network_urls()),
             'fallback_urls': self.get_fallback_urls(),
         }
         context = RequestContext(self.request, self.context)
         manifest = render_to_string(self._template, context_instance=context)
         set_cached_manifest(manifest)
         return manifest
     else:
         return get_cached_manifest()
 def reset_manifest(self):
     """
     Clear the cache (if clean)
     """
     if is_manifest_clean():
         reset_cache_manifest()
Пример #6
0
 def reset_manifest(self):
     """
     Clear the cache (if clean)
     """
     if is_manifest_clean():
         reset_cache_manifest()