コード例 #1
0
    def test_url_resolve(self):
        self.sitetree.menu('tree1', 'trunk',
                           get_mock_context(path='/', put_var='abrakadabra'))

        url = self.sitetree.url(self.t2_root4,
                                get_mock_context(path='/articles/2_slugged/'))
        self.assertTrue(url.find('abrakadabra') > -1)

        self.sitetree.menu('tree1', 'trunk',
                           get_mock_context(path='/', put_var='booo'))
        url = self.sitetree.url(
            self.t2_root4,
            get_mock_context(path='/articles/2_slugged-mugged/'))
        self.assertTrue(url.find('booo') > -1)

        self.sitetree.menu('tree1', 'trunk',
                           get_mock_context(path='/', put_var='rolling'))
        url = self.sitetree.url(self.t2_root5,
                                get_mock_context(path='/articles/2_quoted/'))
        self.assertTrue(url.find('rolling') > -1)

        self.sitetree.menu('tree1', 'trunk',
                           get_mock_context(path='/', put_var='spoon'))
        url = self.sitetree.url(self.t2_root6,
                                get_mock_context(path='/articles/2_quoted/'))
        self.assertTrue(url.find('spoon') > -1)
コード例 #2
0
ファイル: tests.py プロジェクト: Guest007/django-sitetree
    def test_url_resolve(self):
        self.sitetree.menu('tree1', 'trunk', get_mock_context(path='/', put_var='abrakadabra'))

        url = self.sitetree.url(self.t2_root4, get_mock_context(path='/articles/2_slugged/'))
        self.assertTrue(url.find('abrakadabra') > -1)

        self.sitetree.menu('tree1', 'trunk', get_mock_context(path='/', put_var='booo'))
        url = self.sitetree.url(self.t2_root4, get_mock_context(path='/articles/2_slugged-mugged/'))
        self.assertTrue(url.find('booo') > -1)

        self.sitetree.menu('tree1', 'trunk', get_mock_context(path='/', put_var='rolling'))
        url = self.sitetree.url(self.t2_root5, get_mock_context(path='/articles/2_quoted/'))
        self.assertTrue(url.find('rolling') > -1)

        self.sitetree.menu('tree1', 'trunk', get_mock_context(path='/', put_var='spoon'))
        url = self.sitetree.url(self.t2_root6, get_mock_context(path='/articles/2_quoted/'))
        self.assertTrue(url.find('spoon') > -1)
コード例 #3
0
ファイル: tests.py プロジェクト: robcharlwood/django-sitetree
    def test_url_resolve(self):
        self.sitetree.menu("tree1", "trunk", get_mock_context(path="/", put_var="abrakadabra"))

        url = self.sitetree.url(self.t2_root4, None, get_mock_context(path="/articles/2_slugged/"))
        self.assertTrue(url.find("abrakadabra") > -1)

        self.sitetree.menu("tree1", "trunk", get_mock_context(path="/", put_var="booo"))
        url = self.sitetree.url(self.t2_root4, None, get_mock_context(path="/articles/2_slugged-mugged/"))
        self.assertTrue(url.find("booo") > -1)

        self.sitetree.menu("tree1", "trunk", get_mock_context(path="/", put_var="rolling"))
        url = self.sitetree.url(self.t2_root5, None, get_mock_context(path="/articles/2_quoted/"))
        self.assertTrue(url.find("rolling") > -1)

        self.sitetree.menu("tree1", "trunk", get_mock_context(path="/", put_var="spoon"))
        url = self.sitetree.url(self.t2_root6, None, get_mock_context(path="/articles/2_quoted/"))
        self.assertTrue(url.find("spoon") > -1)
コード例 #4
0
def index_onlineMag(request):
    context = {}
    context["USER_NAME"] = "" + request.GET.get("USER")
    url = request.GET.get("PIC_SRC")
    context["PIC_SRC"] = url
    from setu.sqlFunc import getUserTimes, getPictureName

    context["RENEW"] = getUserTimes(request.GET.get("USER"))
    context["PIC_NAME"] = getPictureName(url[url.find("/static"):])
    return render(request, "index_onlineMag.html", context)
コード例 #5
0
ファイル: views.py プロジェクト: yvess/smartmin
def smart_url(url, id=None):
    """
    URLs that start with @ are reversed, using the passed in arguments.

    Otherwise a straight % substitution is applied.
    """
    if url.find("@") >= 0:
        (args, value) = url.split('@')

        if args:
            return reverse(value, args=[id])
        else:
            return reverse(value)
    else:
        if id is None:
            return url
        else:
            return url % id
コード例 #6
0
ファイル: views.py プロジェクト: savioabuga/smartmin
def smart_url(url, obj=None):
    """
    URLs that start with @ are reversed, using the passed in arguments.

    Otherwise a straight % substitution is applied.
    """
    if url.find("@") >= 0:
        (args, value) = url.split('@')

        if args:
            val = getattr(obj, args, None)
            return reverse(value, args=[val])
        else:
            return reverse(value)
    else:
        if obj is None:
            return url
        else:
            return url % obj.id