예제 #1
0
파일: theme.py 프로젝트: pombredanne/Misago
 def get_email_templates(self, template, contex={}):
         email_type_plain = '_email/%s_plain.html' % template
         email_type_html = '_email/%s_html.html' % template
         return (
                 select_template(('%s/%s' % (self._theme, email_type_plain[1:]), email_type_plain)),
                 select_template(('%s/%s' % (self._theme, email_type_html[1:]), email_type_html)),
                 )
예제 #2
0
파일: theme.py 프로젝트: nintendos/Misago
 def get_email_templates(self, template, contex={}):
     email_type_plain = "_email/%s.txt" % template
     email_type_html = "_email/%s.html" % template
     return (
         select_template(("%s/%s" % (self._theme, email_type_plain[1:]), email_type_plain)),
         select_template(("%s/%s" % (self._theme, email_type_html[1:]), email_type_html)),
     )
예제 #3
0
파일: theme.py 프로젝트: pombredanne/Misago
 def get_email_templates(self, template, contex={}):
     email_type_plain = '_email/%s_plain.html' % template
     email_type_html = '_email/%s_html.html' % template
     return (
         select_template(('%s/%s' % (self._theme, email_type_plain[1:]),
                          email_type_plain)),
         select_template(('%s/%s' % (self._theme, email_type_html[1:]),
                          email_type_html)),
     )
예제 #4
0
def render_fatpage(request, f):
    """
    Internal interface to the fat page view.
    """
    # If registration is required for accessing this page, and the user isn't
    # logged in, redirect to the login page.
    if f.registration_required and not request.user.is_authenticated():
        from django.contrib.auth.views import redirect_to_login
        return redirect_to_login(request.path)
    if f.template_name:
        t = loader.select_template((f.template_name, DEFAULT_TEMPLATE))
    else:
        t = loader.get_template(DEFAULT_TEMPLATE)

    # To avoid having to always use the "|safe" filter in fatpage templates,
    # mark the title and content as already safe (since they are raw HTML
    # content in the first place).
    f.title = mark_safe(f.title)
    f.content = mark_safe(f.content)

    c = RequestContext(request, {
        'fatpage': f,
    })
    response = HttpResponse(t.render(c))
    populate_xheaders(request, response, FatPage, f.id)
    return response
예제 #5
0
 def resolve_template(self, template):
     if isinstance(template, (list, tuple)):
         return loader.select_template(template)
     elif isinstance(template, basestring):
         return loader.get_template(template)
     else:
         return template
예제 #6
0
파일: theme.py 프로젝트: xyzz/Misago
 def macro(self, templates, macro, dictionary={}, context_instance=None):
     templates = self.prefix_templates(templates, dictionary)
     template = select_template(templates)
     if context_instance:
         context_instance.update(dictionary)
     else:
         context_instance = dictionary
     context_instance = dict_from_django_context(context_instance)
     _macro = getattr(template.make_module(context_instance), macro)
     return unicode(_macro()).strip()
예제 #7
0
파일: theme.py 프로젝트: Misago/Misago
 def macro(self, templates, macro, dictionary={}, context_instance=None):
     templates = self.prefix_templates(templates)
     template = select_template(templates)
     if context_instance:
         context_instance.update(dictionary)
     else:
         context_instance = dictionary
     context_instance = dict_from_django_context(context_instance)
     _macro = getattr(template.make_module(context_instance), macro)
     return unicode(_macro()).strip()
예제 #8
0
 def __init__(self, request, type='base', message=None, extra={}, owner=None):
     self.type = type
     self.message = message
     self.owner = owner
     for key, value in extra.iteritems():
         setattr(self, key, value)
     self.tpl = select_template((
                                 '%s/message/%s.html' % (request.theme.get_theme(), type),
                                 '_message/%s.html' % type,
                                 '%s/message/base.html' % request.theme.get_theme(),
                                 '_message/base.html'
                                 ))
     self.tpl = self.tpl.name
     if self.tpl[9:-5] == 'base':
         self.message = type
예제 #9
0
 def __init__(self,
              request,
              type='base',
              message=None,
              extra={},
              owner=None):
     self.type = type
     self.message = message
     self.owner = owner
     for key, value in extra.iteritems():
         setattr(self, key, value)
     self.tpl = select_template(
         ('%s/message/%s.html' % (request.theme.get_theme(), type),
          '_message/%s.html' % type,
          '%s/message/base.html' % request.theme.get_theme(),
          '_message/base.html'))
     self.tpl = self.tpl.name
     if self.tpl[9:-5] == 'base':
         self.message = type
예제 #10
0
def multilingual_flatpage(request, url):
    """
    Multilingual flat page view.

    Models: `multilingual.flatpages.models`
    Templates: Uses the template defined by the ``template_name`` field,
        or `flatpages/default.html` if template_name is not defined.
    Context:
        flatpage
            `flatpages.flatpages` object
    """
    if not url.endswith('/') and settings.APPEND_SLASH:
        return HttpResponseRedirect("%s/" % request.path)
    if not url.startswith('/'):
        url = "/" + url
    f = get_object_or_404(MultilingualFlatPage, url__exact=url, sites__id__exact=settings.SITE_ID)
    # If registration is required for accessing this page, and the user isn't
    # logged in, redirect to the login page.
    if f.registration_required and not request.user.is_authenticated():
        from django.contrib.auth.views import redirect_to_login
        return redirect_to_login(request.path)
    # Serve the content in the language defined by the Django translation module
    # if possible else serve the default language.
    f._default_language = get_language()
    if f.template_name:
        t = loader.select_template((f.template_name, DEFAULT_TEMPLATE))
    else:
        t = loader.get_template(DEFAULT_TEMPLATE)

    # To avoid having to always use the "|safe" filter in flatpage templates,
    # mark the title and content as already safe (since they are raw HTML
    # content in the first place).
    f.title = mark_safe(f.title)
    f.content = mark_safe(f.content)

    c = RequestContext(request, {
        'flatpage': f,
    })
    response = HttpResponse(t.render(c))
    populate_xheaders(request, response, MultilingualFlatPage, f.id)
    return response
예제 #11
0
def flatpage(request, url):
    """
    Flat page view.

    Models: `flatpages.flatpages`
    Templates: Uses the template defined by the ``template_name`` field,
        or `flatpages/default.html` if template_name is not defined.
    Context:
        flatpage
            `flatpages.flatpages` object
    """
    if not url.endswith('/') and settings.APPEND_SLASH:
        return HttpResponseRedirect("%s/" % request.path)
    if not url.startswith('/'):
        url = "/" + url
    f = get_object_or_404(FlatPage,
                          url__exact=url,
                          sites__id__exact=settings.SITE_ID)
    # If registration is required for accessing this page, and the user isn't
    # logged in, redirect to the login page.
    if f.registration_required and not request.user.is_authenticated():
        from django.contrib.auth.views import redirect_to_login
        return redirect_to_login(request.path)
    if f.template_name:
        t = loader.select_template((f.template_name, DEFAULT_TEMPLATE))
    else:
        t = loader.get_template(DEFAULT_TEMPLATE)

    # To avoid having to always use the "|safe" filter in flatpage templates,
    # mark the title and content as already safe (since they are raw HTML
    # content in the first place).
    f.title = mark_safe(f.title)
    f.content = mark_safe(f.content)

    c = RequestContext(request, {
        'flatpage': f,
    })
    response = HttpResponse(t.render(c))
    populate_xheaders(request, response, FlatPage, f.id)
    return response