def get(self, request, presentation, module_id):
        module_presentation = presentation.bind_module_or_404(module_id)
        womi = module_presentation.module_occurrence.single_referred_womi_or_none(models.WomiReference.PLAY_AND_LEARN_UNBOUND_KIND)

        womi_id = womi.womi_id
        womi_version = womi.version

        params = self._fetch_womi_params(request, womi_id, womi_version)
        module_name = module_presentation.module_occurrence.module.md_title

        # TODO: determine collection and module peculiarities

        back_url = module_presentation.url

        params.update({
            "back_url": back_url,
            "module_name": module_name,
            "module": module_presentation.module_occurrence.module,

            "config": self.config,
            "presentation": presentation,
            'results_url_base': absolute_url(request, '')
        })

        return render_with_esi(request, self.template, params)
示例#2
0
    def get(self, request, presentation, module_id):

        module_presentation = presentation.bind_module_or_404(module_id)

        return render_with_esi(request, self.template_name, {
            'presentation': presentation,
            'collection': presentation.collection,
            'module': module_presentation.module_occurrence.module,
            'module_occurrence': module_presentation.module_occurrence,
            'use_test': self.use_test,
            'endpoints': self.endpoints,
            'results_url_base': absolute_url(request, '')
        })
示例#3
0
def process_esi(request, response):

    parts = []
    remaining_index = 0
    original = response.content

    for esi_match in ESI_INCLUDE_PATTERN.finditer(original):

        url = absolute_url(request, esi_match.group(1))
        if not url.startswith('http'):
            url = ('https:' if request.is_secure() else 'http:') + url

        r = requests.get(url)
        r.encoding = 'utf-8'
        parts.append(encoding.smart_text(original[remaining_index:esi_match.start()]))
        parts.append(encoding.smart_text(r.text))
        remaining_index = esi_match.end()

    parts.append(encoding.smart_text(original[remaining_index:]))

    response.content = ''.join(parts)
def absolute_path(context, path):
    request = context['request']
    return absolute_url(request, path)
示例#5
0
def url_absolute_with_scheme(context, view):
    request = context['request']
    return absolute_url(request, reverse(view), with_scheme=True)
示例#6
0
def url_absolute(context, view, *args):
    request = context['request']
    return absolute_url(request, reverse(view, args=args))