def render_inline_program_qsd(program, name):
    #unlike the above method, we don't know the url, just a program object
    #we could attempt to construct the url in the template
    #or just do this
    url = QuasiStaticData.prog_qsd_url(program, name)
    qsd_obj = QuasiStaticData.objects.get_by_url_else_init(url)
    return {'qsdrec': qsd_obj}
Exemple #2
0
def render_inline_program_qsd(program, name):
    #unlike the above method, we don't know the url, just a program object
    #we could attempt to construct the url in the template
    #or just do this
    url = QuasiStaticData.prog_qsd_url(program, name)
    qsd_obj = QuasiStaticData.objects.get_by_url_else_init(url)
    return {'qsdrec': qsd_obj}
Exemple #3
0
    def render(self, context):
        try:
            program = self.program_variable.resolve(
                context) if self.program_variable is not None else None
        except template.VariableDoesNotExist:
            program = None
        #   Accept literal string url argument if it is quoted; otherwise expect a template variable.
        #   template.Variable resolves string literals to themselves automatically
        url_resolved = template.Variable(self.url).resolve(context)
        if program is not None:
            url = QuasiStaticData.prog_qsd_url(program, url_resolved)
        else:
            url = url_resolved
        #probably should have an error message if variable was not None and prog was

        title = self.url
        if program is not None:
            title += ' - ' + unicode(program)

        qsd_obj = QuasiStaticData.objects.get_by_url_else_init(
            url, {
                'name': '',
                'title': title,
                'content': self.nodelist.render(context)
            })
        # Note: this is django's render_to_response, not ours!
        return render_to_response("inclusion/qsd/render_qsd_inline.html", {
            'qsdrec': qsd_obj
        },
                                  context_instance=context).content
    def render(self, context):
        try:
            program = self.program_variable.resolve(context) if self.program_variable is not None else None
        except template.VariableDoesNotExist:
            program = None
        #   Accept literal string url argument if it is quoted; otherwise expect a template variable.
        #   template.Variable resolves string literals to themselves automatically
        url_resolved = template.Variable(self.url).resolve(context)
        if program is not None:
            url = QuasiStaticData.prog_qsd_url(program,url_resolved)
        else:
            url = url_resolved
        #probably should have an error message if variable was not None and prog was

        title = self.url
        if program is not None:
            title += ' - ' + unicode(program)

        qsd_obj = QuasiStaticData.objects.get_by_url_else_init(url, {'name': '', 'title': title, 'content': self.nodelist.render(context)})
        # Note: this is django's render_to_response, not ours!
        return render_to_response("inclusion/qsd/render_qsd_inline.html", {'qsdrec': qsd_obj}, context_instance=context).content
Exemple #5
0
    def render(self, context):
        try:
            user = self.user_variable.resolve(context) if self.user_variable is not None else None
        except template.VariableDoesNotExist:
            user = None
        try:
            program = self.program_variable.resolve(context) if self.program_variable is not None else None
        except template.VariableDoesNotExist:
            program = None
        #   Accept literal string url argument if it is quoted; otherwise expect a template variable.
        if not self.url.startswith('"'):
            url_resolved = template.Variable(self.url).resolve(context)
        else:
            url_resolved = self.url.strip('"')
        if program is not None:
            url = QuasiStaticData.prog_qsd_url(program,url_resolved)
        else:
            url = url_resolved
        #probably should have an error message if variable was not None and prog was

        edit_bits = Permission.user_can_edit_qsd(user, url)

        qsd_obj = QuasiStaticData.objects.get_by_url(url)
        if qsd_obj == None:
            new_qsd = QuasiStaticData()
            new_qsd.url = url
            new_qsd.title = url
            new_qsd.content = self.nodelist.render(context)
            
            if getattr(user, 'id', False):
                new_qsd.author = user
                new_qsd.save()

            qsd_obj = new_qsd

        return render_to_response("inclusion/qsd/render_qsd_inline.html", {'qsdrec': qsd_obj, 'edit_bits': edit_bits}, context_instance=context).content