Commit 1607da034dcfc8aec528c6cac0f8a16653e50a55
Committed by
Gust
1 parent
83dc32cc
Exists in
master
and in
6 other branches
Added support to install apps arbitrary apps
Now apps can be installed from settings.yml
Showing
5 changed files
with
33 additions
and
19 deletions
Show diff stats
| @@ -0,0 +1,21 @@ | @@ -0,0 +1,21 @@ | ||
| 1 | + | ||
| 2 | +from django.conf import settings | ||
| 3 | +from django.conf.urls import patterns, url, include | ||
| 4 | +from django.core.exceptions import ImproperlyConfigured | ||
| 5 | + | ||
| 6 | +undef_url_include_msg = (u'COLAB_APP with urls must define ' | ||
| 7 | + 'the `include` attribute') | ||
| 8 | + | ||
| 9 | +urlpatterns = patterns('') | ||
| 10 | + | ||
| 11 | +for app_name, app in settings.COLAB_APPS.items(): | ||
| 12 | + if not app or 'urls' not in app: | ||
| 13 | + continue | ||
| 14 | + | ||
| 15 | + urls = app.get('urls') | ||
| 16 | + if not urls.get('include'): | ||
| 17 | + raise ImproperlyConfigured(undef_url_include_msg) | ||
| 18 | + urlpatterns += patterns('', | ||
| 19 | + url(urls.get('prefix', r''), include(urls['include'], | ||
| 20 | + namespace=urls.get('namespace'))), | ||
| 21 | + ) |
colab/settings.py
| @@ -50,7 +50,6 @@ INSTALLED_APPS = ( | @@ -50,7 +50,6 @@ INSTALLED_APPS = ( | ||
| 50 | 'hitcounter', | 50 | 'hitcounter', |
| 51 | 'i18n_model', | 51 | 'i18n_model', |
| 52 | 'mptt', | 52 | 'mptt', |
| 53 | - 'dpaste', | ||
| 54 | 'taggit', | 53 | 'taggit', |
| 55 | 54 | ||
| 56 | # Own apps | 55 | # Own apps |
| @@ -292,19 +291,6 @@ CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True | @@ -292,19 +291,6 @@ CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True | ||
| 292 | # Tastypie settings | 291 | # Tastypie settings |
| 293 | TASTYPIE_DEFAULT_FORMATS = ['json', ] | 292 | TASTYPIE_DEFAULT_FORMATS = ['json', ] |
| 294 | 293 | ||
| 295 | -# Dpaste settings | ||
| 296 | -DPASTE_EXPIRE_CHOICES = ( | ||
| 297 | - ('onetime', _(u'One Time Snippet')), | ||
| 298 | - (3600, _(u'In one hour')), | ||
| 299 | - (3600 * 24 * 7, _(u'In one week')), | ||
| 300 | - (3600 * 24 * 30, _(u'In one month')), | ||
| 301 | - ('never', _(u'Never')), | ||
| 302 | -) | ||
| 303 | -DPASTE_EXPIRE_DEFAULT = DPASTE_EXPIRE_CHOICES[4][0] | ||
| 304 | -DPASTE_DEFAULT_GIST_DESCRIPTION = 'Gist created from Colab DPaste' | ||
| 305 | -DPASTE_DEFAULT_GIST_NAME = 'colab_paste' | ||
| 306 | -DPASTE_LEXER_DEFAULT = 'text' | ||
| 307 | - | ||
| 308 | from .utils.conf import load_yaml_settings | 294 | from .utils.conf import load_yaml_settings |
| 309 | locals().update(load_yaml_settings()) | 295 | locals().update(load_yaml_settings()) |
| 310 | 296 | ||
| @@ -328,3 +314,8 @@ PROXIED_APPS = locals().get('PROXIED_APPS') or {} | @@ -328,3 +314,8 @@ PROXIED_APPS = locals().get('PROXIED_APPS') or {} | ||
| 328 | 314 | ||
| 329 | for app_label in PROXIED_APPS.keys(): | 315 | for app_label in PROXIED_APPS.keys(): |
| 330 | INSTALLED_APPS += ('colab.proxy.{}'.format(app_label),) | 316 | INSTALLED_APPS += ('colab.proxy.{}'.format(app_label),) |
| 317 | + | ||
| 318 | +COLAB_APPS = locals().get('COLAB_APPS') or {} | ||
| 319 | + | ||
| 320 | +for app in COLAB_APPS: | ||
| 321 | + INSTALLED_APPS += (app,) |
colab/urls.py
| @@ -7,8 +7,7 @@ from django.views.generic import RedirectView | @@ -7,8 +7,7 @@ from django.views.generic import RedirectView | ||
| 7 | 7 | ||
| 8 | admin.autodiscover() | 8 | admin.autodiscover() |
| 9 | 9 | ||
| 10 | -urlpatterns = patterns( | ||
| 11 | - '', | 10 | +urlpatterns = patterns('', |
| 12 | url(r'^robots.txt$', 'colab.home.views.robots', name='robots'), | 11 | url(r'^robots.txt$', 'colab.home.views.robots', name='robots'), |
| 13 | url(r'^dashboard$', 'colab.home.views.dashboard', name='dashboard'), | 12 | url(r'^dashboard$', 'colab.home.views.dashboard', name='dashboard'), |
| 14 | url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'), | 13 | url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'), |
| @@ -35,8 +34,6 @@ urlpatterns = patterns( | @@ -35,8 +34,6 @@ urlpatterns = patterns( | ||
| 35 | 34 | ||
| 36 | url(r'^planet/', include('feedzilla.urls')), | 35 | url(r'^planet/', include('feedzilla.urls')), |
| 37 | 36 | ||
| 38 | - url(r'paste/', include('dpaste.urls.dpaste')), | ||
| 39 | - | ||
| 40 | # Uncomment the next line to enable the admin: | 37 | # Uncomment the next line to enable the admin: |
| 41 | url(r'^colab/admin/', include(admin.site.urls)), | 38 | url(r'^colab/admin/', include(admin.site.urls)), |
| 42 | 39 | ||
| @@ -44,6 +41,8 @@ urlpatterns = patterns( | @@ -44,6 +41,8 @@ urlpatterns = patterns( | ||
| 44 | url(r'^gitlab/', include('colab.proxy.gitlab.urls')), | 41 | url(r'^gitlab/', include('colab.proxy.gitlab.urls')), |
| 45 | url(r'^social/', include('colab.proxy.noosfero.urls')), | 42 | url(r'^social/', include('colab.proxy.noosfero.urls')), |
| 46 | url(r'^ci/', include('colab.proxy.jenkins.urls')), | 43 | url(r'^ci/', include('colab.proxy.jenkins.urls')), |
| 44 | + | ||
| 45 | + url(r'', include('colab.plugins.urls')), | ||
| 47 | ) | 46 | ) |
| 48 | 47 | ||
| 49 | if settings.DEBUG: | 48 | if settings.DEBUG: |
colab/utils/conf.py
| @@ -2,6 +2,8 @@ | @@ -2,6 +2,8 @@ | ||
| 2 | import os | 2 | import os |
| 3 | import yaml | 3 | import yaml |
| 4 | 4 | ||
| 5 | +import yamlordereddictloader | ||
| 6 | + | ||
| 5 | from django.core.exceptions import ImproperlyConfigured | 7 | from django.core.exceptions import ImproperlyConfigured |
| 6 | 8 | ||
| 7 | 9 | ||
| @@ -14,7 +16,8 @@ class InaccessibleYAMLSettings(ImproperlyConfigured): | @@ -14,7 +16,8 @@ class InaccessibleYAMLSettings(ImproperlyConfigured): | ||
| 14 | def _load_yaml_file(yaml_path): | 16 | def _load_yaml_file(yaml_path): |
| 15 | try: | 17 | try: |
| 16 | with open(yaml_path) as yaml_file: | 18 | with open(yaml_path) as yaml_file: |
| 17 | - yaml_settings = yaml.load(yaml_file.read()) | 19 | + yaml_settings = yaml.load(yaml_file.read(), |
| 20 | + yamlordereddictloader.Loader) | ||
| 18 | except IOError: | 21 | except IOError: |
| 19 | msg = ('Could not open settings file {}. Please ' | 22 | msg = ('Could not open settings file {}. Please ' |
| 20 | 'check if the file exists and if user ' | 23 | 'check if the file exists and if user ' |