Add front django app for resolve front urls.

remotes/origin/enhancement/email-actions
Andrey Antukh 2013-10-24 17:41:21 +02:00
parent b01ed2f451
commit ac7889ff18
3 changed files with 36 additions and 0 deletions

View File

@ -0,0 +1,30 @@
# -*- coding: utf-8 -*-
from django.conf import settings
import django_sites as sites
from django_jinja import library
URLS = {
"userstory": "/#/project/{0}/user-story/{1}",
"task": "/#/project/{0}/tasks/{1}",
"issue": "/#/project/{0}/issues/{1}",
}
lib = library.Library()
def get_current_site():
current_site_id = getattr(settings, "SITE_ID")
front_sites = getattr(settings, "SITES_FRONT")
return sites.Site(front_sites[current_site_id])
@lib.global_function(name="resolve_front_url")
def resolve(type, projectId, itemId):
site = get_current_site()
url_tmpl = "{scheme}//{domain}{url}"
scheme = site.scheme and "{0}:".format(site.scheme) or ""
url = URLS[type].format(projectId, itemId)
return url_tmpl.format(scheme=scheme, domain=site.domain, url=url)

View File

View File

@ -64,6 +64,11 @@ SITES = {
1: {"domain": "localhost:8000", "scheme": "http"},
}
SITES_FRONT = {
1: {"domain": "localhost:9001", "scheme": "http"},
}
SITE_ID = 1
#SESSION BACKEND
@ -198,6 +203,7 @@ INSTALLED_APPS = [
'greenmine.projects.userstories',
'greenmine.projects.tasks',
'greenmine.projects.issues',
'greenmine.front',
#'greenmine.projects.questions',
#'greenmine.projects.documents',
'greenmine.projects.wiki',