Exemple #1
0
 def url(self, name):
     if self.base_url is None:
         raise ValueError("This file is not accessible via a URL.")
     url = filepath_to_uri(name)
     if url is not None:
         url = url.lstrip('/')
     return urljoin(self.base_url, "{0}/static/{1}".format(get_theme(), url))
Exemple #2
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     CURRENT_THEME = get_theme()
     context['form'] = ConfigUpdateForm(initial={'theme': CURRENT_THEME})
     context['themes'] = get_themes()
     context['title'] = get_key("ctf_name")
     context['start_time'] = get_key('start_time')
     context['end_time'] = get_key('end_time')
     return context
Exemple #3
0
    def find(self, path, all=False):
        """
        Look for files in the extra locations as defined in STATICFILES_DIRS.
        NOTE: Modified to include theme in path, with get_theme()
        """
        theme = get_theme()

        matches = []
        for prefix, root in self.locations:
            if root not in searched_locations:
                searched_locations.append(root)
            matched_path = self.find_location(
                root, "{0}/static/{1}".format(theme, path), prefix)
            if matched_path:
                if not all:
                    return matched_path
                matches.append(matched_path)
        return matches
Exemple #4
0
    def get_template_sources(self, template_name):
        """
        Return an Origin object pointing to an absolute path in each directory
        in template_dirs. For security reasons, if a path doesn't lie inside
        one of the template_dirs it is excluded from the result set.
        """
        template_name = "admin/{1}".format(get_theme(), template_name)

        for template_dir in self.get_dirs():
            try:
                name = safe_join(template_dir, template_name)
            except SuspiciousFileOperation:
                # The joined path was located outside of this template_dir
                # (it might be inside another one, so this isn't fatal).
                continue

            yield Origin(
                name=name,
                template_name=template_name,
                loader=self,
            )
Exemple #5
0
def theme_context(request):
    theme = get_theme()

    return {"theme_static": "{0}{1}/static".format(settings.STATIC_URL, theme)}