Generalize URLs.

ILYA PORTNOV [2008-06-19 15:14:23]
Generalize URLs.
Filename
mgmt/context.py
mgmt/decorators.py
mgmt/templatetags/prj_filters.py
settings.py
diff --git a/mgmt/context.py b/mgmt/context.py
index 8a60573..87e1e36 100644
--- a/mgmt/context.py
+++ b/mgmt/context.py
@@ -16,7 +16,7 @@ hms.modules.exports.append('settings')
 hms.modules.init()

 def make_chart(path):
-  p1 = re.compile('/projects/(\d+)/$')
+  p1 = re.compile(settings.BASE_URL+'/projects/(\d+)/$')
   m = p1.match(path)
   if m:
     pid = int(m.group(1))
diff --git a/mgmt/decorators.py b/mgmt/decorators.py
index 90dc9ff..1d1f289 100644
--- a/mgmt/decorators.py
+++ b/mgmt/decorators.py
@@ -1,3 +1,4 @@
+from django.conf import settings
 from django.http import HttpResponseForbidden,HttpResponseRedirect
 from rights import can
 from utils import render_it,render_rss
@@ -7,7 +8,7 @@ def login_required(func):
     if request.user.is_authenticated():
       return func(request,*args,**kwargs)
     else:
-      return HttpResponseRedirect('/login/')
+      return HttpResponseRedirect(settings.LOGIN_URL)
   wrapper.__name__ = func.__name__
   return wrapper

diff --git a/mgmt/templatetags/prj_filters.py b/mgmt/templatetags/prj_filters.py
index 3f1ad0e..2a93692 100644
--- a/mgmt/templatetags/prj_filters.py
+++ b/mgmt/templatetags/prj_filters.py
@@ -2,6 +2,8 @@
 import re
 import markdown as MD

+from django.conf import settings
+from django.core.urlresolvers import reverse
 from django import template
 register = template.Library()

@@ -11,10 +13,10 @@ sys.path.append(dirname(__file__))

 @register.filter('link')
 def link(obj,type='projects'):
-  return "<a href='/%s/%s/'>%s</a>" % (type,obj.id,obj.name)
+  return "<a href='%s/%s/%s/'>%s</a>" % (settings.BASE_URL,type,obj.id,obj.name)

 def change_kb_links(text):
-  return re.sub(r'KB#(\d+)',r"<a href='/kb/article/\1'>KB#\1</a>", text)
+  return re.sub(r'KB#(\d+)',r"<a href='%s/kb/article/\1'>KB#\1</a>" % settings.BASE_URL, text)

 @register.filter
 def markdown(value):
diff --git a/settings.py b/settings.py
index e8a39c6..e5c5c64 100644
--- a/settings.py
+++ b/settings.py
@@ -115,6 +115,7 @@ BUGS_PER_PAGE = COMMENTS_PER_PAGE
 RSS_MAX_ITEMS = 10

 MENU_ANONYMOUS = [(u'Главная',BASE_URL+'/'),
+                  (u'Git', BASE_URL+'/git/'),
                   (u'Вход',BASE_URL+'/login/')]

 MENU_USER = [(u'Главная',BASE_URL+'/'),
ViewGit