layerindex: Add support for rrs in settings.py and urls.py

settings.py: Add APPLICATION variable to switch between layerindex
rrs also add context_processors decision layerindex or rrs.

urls.py: Add decision for load urls for layerindex or rrs.

layerindex/context_processors.py: Add application variable for use
templates.

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
This commit is contained in:
Aníbal Limón 2015-01-08 12:10:23 -06:00
parent eae7b91a11
commit 36d5746acd
3 changed files with 39 additions and 8 deletions

View File

@ -4,6 +4,7 @@
#
# Licensed under the MIT license, see COPYING.MIT for details
import settings
from layerindex.models import Branch, LayerItem
from django.contrib.sites.models import Site
@ -17,5 +18,6 @@ def layerindex_context(request):
'all_branches': Branch.objects.exclude(name='oe-classic').order_by('sort_priority'),
'unpublished_count': LayerItem.objects.filter(status='N').count(),
'oe_classic': Branch.objects.filter(name='oe-classic'),
'site_name': site_name
}
'site_name': site_name,
'application' : settings.APPLICATION
}

View File

@ -6,6 +6,8 @@
DEBUG = False
TEMPLATE_DEBUG = DEBUG
APPLICATION = 'layerindex' # rrs or layerindex
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
@ -120,10 +122,18 @@ CORS_URLS_REGEX = r'.*/api/.*';
X_FRAME_OPTIONS = 'DENY'
from django.conf.global_settings import TEMPLATE_CONTEXT_PROCESSORS as TCP
TEMPLATE_CONTEXT_PROCESSORS = TCP + (
'django.core.context_processors.request',
'layerindex.context_processors.layerindex_context',
)
if APPLICATION == 'layerindex':
TEMPLATE_CONTEXT_PROCESSORS = TCP + (
'django.core.context_processors.request',
'layerindex.context_processors.layerindex_context',
)
elif APPLICATION == 'rrs':
TEMPLATE_CONTEXT_PROCESSORS = TCP + (
'django.core.context_processors.request',
'rrs.context_processors.rrs_context',
)
else:
raise ValueError('Unknown APPLICATION should be layerindex or rrs')
ROOT_URLCONF = 'urls'
@ -146,6 +156,8 @@ INSTALLED_APPS = (
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'layerindex',
# Uncomment when APPLICATION is RRS
#'rrs',
'registration',
'reversion',
'reversion_compare',
@ -215,3 +227,10 @@ CORE_LAYER_NAME = "openembedded-core"
# Settings for layer submission feature
SUBMIT_EMAIL_FROM = 'noreply@example.com'
SUBMIT_EMAIL_SUBJECT = 'OE Layerindex layer submission'
# Settings for Recipe reporting system
POKY_REPO_URL = "git://git.yoctoproject.org/poky"
RRS_EMAIL_SUBJECT = '[Recipe reporting system] Upgradable recipe name list'
RRS_EMAIL_FROM = 'recipe-report@yoctoproject.org'
RRS_EMAIL_TO = 'list@example.com'

14
urls.py
View File

@ -5,6 +5,8 @@
# Copyright (c) Django Software Foundation and individual contributors.
# All rights reserved.
import settings
from django.conf.urls.defaults import patterns, include, url
from django.views.generic.simple import redirect_to
@ -12,10 +14,18 @@ from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^layerindex/', include('layerindex.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^captcha/', include('captcha.urls')),
url(r'.*', redirect_to, {'url' : '/layerindex/'})
)
if settings.APPLICATION == 'layerindex':
urlpatterns += patterns('',
url(r'^layerindex/', include('layerindex.urls')),
url(r'.*', redirect_to, {'url' : '/layerindex/'}),
)
elif settings.APPLICATION == 'rrs':
urlpatterns += patterns('',
url(r'^rrs/', include('rrs.urls')),
url(r'.*', redirect_to, {'url' : '/rrs/'}),
)