Commit 8b9261cb86e8021ace62b14e45ca87e4e651f6f6

Authored by Sergio Oliveira
1 parent 0488c377

Setting app_label in views to allow get configuration

colab/proxy/gitlab/views.py
@@ -5,5 +5,5 @@ from ..utils.views import ColabProxyView @@ -5,5 +5,5 @@ from ..utils.views import ColabProxyView
5 5
6 6
7 class GitlabProxyView(ColabProxyView): 7 class GitlabProxyView(ColabProxyView):
8 - upstream = settings.PROXIED_APPS['gitlab']['upstream'] 8 + app_label = 'gitlab'
9 diazo_theme_template = 'proxy/gitlab.html' 9 diazo_theme_template = 'proxy/gitlab.html'
colab/proxy/jenkins/views.py
@@ -5,4 +5,4 @@ from ..utils.views import ColabProxyView @@ -5,4 +5,4 @@ from ..utils.views import ColabProxyView
5 5
6 6
7 class JenkinsProxyView(ColabProxyView): 7 class JenkinsProxyView(ColabProxyView):
8 - upstream = settings.PROXIED_APPS['jenkins']['upstream'] 8 + app_label = 'jenkins'
colab/proxy/redmine/views.py
@@ -5,5 +5,5 @@ from ..utils.views import ColabProxyView @@ -5,5 +5,5 @@ from ..utils.views import ColabProxyView
5 5
6 6
7 class RedmineProxyView(ColabProxyView): 7 class RedmineProxyView(ColabProxyView):
8 - upstream = settings.PROXIED_APPS['redmine']['upstream'] 8 + app_label = 'redmine'
9 diazo_theme_template = 'proxy/redmine.html' 9 diazo_theme_template = 'proxy/redmine.html'
colab/proxy/trac/views.py
@@ -8,7 +8,7 @@ from .models import Wiki, Ticket, Revision @@ -8,7 +8,7 @@ from .models import Wiki, Ticket, Revision
8 8
9 9
10 class TracProxyView(HitCounterViewMixin, ColabProxyView): 10 class TracProxyView(HitCounterViewMixin, ColabProxyView):
11 - upstream = settings.PROXIED_APPS['trac']['upstream'] 11 + app_label = 'trac'
12 diazo_theme_template = 'proxy/trac.html' 12 diazo_theme_template = 'proxy/trac.html'
13 13
14 def get_object(self): 14 def get_object(self):
colab/proxy/utils/views.py
@@ -8,3 +8,12 @@ class ColabProxyView(ProxyView): @@ -8,3 +8,12 @@ class ColabProxyView(ProxyView):
8 add_remote_user = settings.REVPROXY_ADD_REMOTE_USER 8 add_remote_user = settings.REVPROXY_ADD_REMOTE_USER
9 diazo_theme_template = 'base.html' 9 diazo_theme_template = 'base.html'
10 html5 = True 10 html5 = True
  11 +
  12 + @property
  13 + def upstream(self):
  14 + proxy_config = settings.PROXIED_APPS.get(self.app_label, {})
  15 + return proxy_config.get('upstream')
  16 +
  17 + @property
  18 + def app_label(self):
  19 + raise NotImplementedError('app_label attribute must be set')