mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-12-03 12:14:12 +01:00
wip: replacing "/static/" occurences with something more flexible.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from django.conf import settings
|
||||
from django.template import RequestContext
|
||||
from django.shortcuts import render_to_response
|
||||
from django.template.loader import render_to_string
|
||||
@@ -37,6 +38,15 @@ def _ctx_ok(url):
|
||||
def _ctx_ko(tpl, ctx):
|
||||
return {"status" : "ko", "content" : render_to_string(tpl, ctx)}
|
||||
|
||||
def static_url(path):
|
||||
"""Returns the correct static url for a given file
|
||||
|
||||
:param path: the targeted static media
|
||||
"""
|
||||
if path.startswith("/"):
|
||||
path = path[1:]
|
||||
return "%s%s" % (settings.MEDIA_URL, path)
|
||||
|
||||
def getctx(status, level=1, callback=None, **kwargs):
|
||||
if not callback:
|
||||
callername = sys._getframe(level).f_code.co_name
|
||||
|
||||
@@ -4,9 +4,9 @@ import re
|
||||
import os
|
||||
import time, random, hashlib
|
||||
from email.header import decode_header
|
||||
import lxml
|
||||
import lxml.html
|
||||
from lxml import etree
|
||||
from django.conf import settings
|
||||
from django.template.loader import render_to_string
|
||||
from django.template import Template, Context
|
||||
from django.utils.translation import ugettext as _
|
||||
@@ -103,7 +103,7 @@ class EmailListing:
|
||||
def render_navbar(self, page):
|
||||
if page is None:
|
||||
return ""
|
||||
context = {"page" : page}
|
||||
context = {"page" : page, "MEDIA_URL" : settings.MEDIA_URL}
|
||||
return render_to_string("common/navbar.html", context)
|
||||
|
||||
def fetch(self, request, id_start, id_stop):
|
||||
@@ -213,8 +213,6 @@ class Email(object):
|
||||
:param fname: the image associated filename
|
||||
:param part: the email part that contains the image payload
|
||||
"""
|
||||
from django.conf import settings
|
||||
|
||||
if re.search("\.\.", fname):
|
||||
return None
|
||||
path = "/static/tmp/" + fname
|
||||
|
||||
Reference in New Issue
Block a user