Commit 3d927a4a94523cbcd874dc3b452060f1133528c4
1 parent
2a7901fe
Exists in
master
and in
39 other branches
Mass rename and namespace chance
Showing
52 changed files
with
576 additions
and
564 deletions
Show diff stats
colab/accounts/__init__.py
colab/accounts/forms.py
| @@ -6,9 +6,9 @@ from django.utils.translation import ugettext_lazy as _ | @@ -6,9 +6,9 @@ from django.utils.translation import ugettext_lazy as _ | ||
| 6 | 6 | ||
| 7 | from conversejs.models import XMPPAccount | 7 | from conversejs.models import XMPPAccount |
| 8 | 8 | ||
| 9 | -from accounts.utils import mailman | ||
| 10 | -from super_archives.models import MailingList | 9 | +from ..super_archives.models import MailingList |
| 11 | from .utils.validators import validate_social_account | 10 | from .utils.validators import validate_social_account |
| 11 | +from .utils import mailman | ||
| 12 | 12 | ||
| 13 | User = get_user_model() | 13 | User = get_user_model() |
| 14 | 14 |
colab/accounts/search_indexes.py
| @@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
| 3 | from haystack import indexes | 3 | from haystack import indexes |
| 4 | from django.db.models import Count | 4 | from django.db.models import Count |
| 5 | 5 | ||
| 6 | -from badger.utils import get_users_counters | 6 | +from colab.badger.utils import get_users_counters |
| 7 | from .models import User | 7 | from .models import User |
| 8 | 8 | ||
| 9 | 9 |
colab/accounts/templatetags/gravatar.py
colab/accounts/urls.py
| @@ -4,15 +4,15 @@ from django.conf.urls import patterns, include, url | @@ -4,15 +4,15 @@ from django.conf.urls import patterns, include, url | ||
| 4 | from .views import (UserProfileDetailView, UserProfileUpdateView, | 4 | from .views import (UserProfileDetailView, UserProfileUpdateView, |
| 5 | ManageUserSubscriptionsView, ChangeXMPPPasswordView) | 5 | ManageUserSubscriptionsView, ChangeXMPPPasswordView) |
| 6 | 6 | ||
| 7 | -from accounts import views | 7 | +from . import views |
| 8 | 8 | ||
| 9 | urlpatterns = patterns('', | 9 | urlpatterns = patterns('', |
| 10 | - url(r'^register/$', 'accounts.views.signup', name='signup'), | 10 | + url(r'^register/$', 'colab.accounts.views.signup', name='signup'), |
| 11 | 11 | ||
| 12 | url(r'^change-password/$', | 12 | url(r'^change-password/$', |
| 13 | ChangeXMPPPasswordView.as_view(), name='change_password'), | 13 | ChangeXMPPPasswordView.as_view(), name='change_password'), |
| 14 | 14 | ||
| 15 | - url(r'^logout/?$', 'accounts.views.logoutColab', name='logout'), | 15 | + url(r'^logout/?$', 'colab.accounts.views.logoutColab', name='logout'), |
| 16 | 16 | ||
| 17 | url(r'^(?P<username>[\w@+.-]+)/?$', | 17 | url(r'^(?P<username>[\w@+.-]+)/?$', |
| 18 | UserProfileDetailView.as_view(), name='user_profile'), | 18 | UserProfileDetailView.as_view(), name='user_profile'), |
colab/accounts/views.py
| @@ -22,8 +22,8 @@ from conversejs import xmpp | @@ -22,8 +22,8 @@ from conversejs import xmpp | ||
| 22 | from conversejs.models import XMPPAccount | 22 | from conversejs.models import XMPPAccount |
| 23 | from haystack.query import SearchQuerySet | 23 | from haystack.query import SearchQuerySet |
| 24 | 24 | ||
| 25 | -from super_archives.models import EmailAddress, Message | ||
| 26 | -from search.utils import trans | 25 | +from colab.super_archives.models import EmailAddress, Message |
| 26 | +from colab.search.utils import trans | ||
| 27 | #from proxy.trac.models import WikiCollabCount, TicketCollabCount | 27 | #from proxy.trac.models import WikiCollabCount, TicketCollabCount |
| 28 | from .forms import (UserCreationForm, ListsForm, UserUpdateForm, | 28 | from .forms import (UserCreationForm, ListsForm, UserUpdateForm, |
| 29 | ChangeXMPPPasswordForm) | 29 | ChangeXMPPPasswordForm) |
colab/api/resources.py
| @@ -6,7 +6,7 @@ from tastypie import fields | @@ -6,7 +6,7 @@ from tastypie import fields | ||
| 6 | from tastypie.constants import ALL_WITH_RELATIONS, ALL | 6 | from tastypie.constants import ALL_WITH_RELATIONS, ALL |
| 7 | from tastypie.resources import ModelResource | 7 | from tastypie.resources import ModelResource |
| 8 | 8 | ||
| 9 | -from super_archives.models import Message, EmailAddress | 9 | +from colab.super_archives.models import Message, EmailAddress |
| 10 | #from proxy.trac.models import Revision, Ticket, Wiki | 10 | #from proxy.trac.models import Revision, Ticket, Wiki |
| 11 | 11 | ||
| 12 | User = get_user_model() | 12 | User = get_user_model() |
colab/api/views.py
| @@ -5,7 +5,7 @@ from django.views.generic import View | @@ -5,7 +5,7 @@ from django.views.generic import View | ||
| 5 | from django.core.exceptions import ObjectDoesNotExist | 5 | from django.core.exceptions import ObjectDoesNotExist |
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | -from super_archives.models import Message | 8 | +from colab.super_archives.models import Message |
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | class VoteView(View): | 11 | class VoteView(View): |
colab/badger/management/commands/rebuild_badges.py
| @@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
| 3 | from django.core.management.base import BaseCommand, CommandError | 3 | from django.core.management.base import BaseCommand, CommandError |
| 4 | from haystack.query import SearchQuerySet | 4 | from haystack.query import SearchQuerySet |
| 5 | 5 | ||
| 6 | -from accounts.models import User | ||
| 7 | -from badger.models import Badge | 6 | +from colab.accounts.models import User |
| 7 | +from colab.badger.models import Badge | ||
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | class Command(BaseCommand): | 10 | class Command(BaseCommand): |
colab/badger/management/commands/update_badges.py
| @@ -3,8 +3,8 @@ | @@ -3,8 +3,8 @@ | ||
| 3 | from django.core.management.base import BaseCommand, CommandError | 3 | from django.core.management.base import BaseCommand, CommandError |
| 4 | from haystack.query import SearchQuerySet | 4 | from haystack.query import SearchQuerySet |
| 5 | 5 | ||
| 6 | -from accounts.models import User | ||
| 7 | -from badger.models import Badge | 6 | +from colab.accounts.models import User |
| 7 | +from colab.badger.models import Badge | ||
| 8 | 8 | ||
| 9 | import logging | 9 | import logging |
| 10 | 10 |
colab/badger/utils.py
| @@ -4,7 +4,7 @@ from django.db.models import Count | @@ -4,7 +4,7 @@ from django.db.models import Count | ||
| 4 | 4 | ||
| 5 | #from proxy.trac.models import (Revision, Ticket, Wiki, | 5 | #from proxy.trac.models import (Revision, Ticket, Wiki, |
| 6 | # WikiCollabCount, TicketCollabCount) | 6 | # WikiCollabCount, TicketCollabCount) |
| 7 | -from accounts.models import User | 7 | +from colab.accounts.models import User |
| 8 | 8 | ||
| 9 | 9 | ||
| 10 | def get_wiki_counters(): | 10 | def get_wiki_counters(): |
| @@ -0,0 +1,53 @@ | @@ -0,0 +1,53 @@ | ||
| 1 | + | ||
| 2 | +DEBUG: false | ||
| 3 | +TEMPLATE_DEBUG: false | ||
| 4 | + | ||
| 5 | +ADMINS: &admin | ||
| 6 | + - | ||
| 7 | + - John Foo | ||
| 8 | + - john@example.com | ||
| 9 | + - | ||
| 10 | + - Mary Bar | ||
| 11 | + - mary@example.com | ||
| 12 | + | ||
| 13 | +MANAGERS: *admin | ||
| 14 | + | ||
| 15 | +COLAB_FROM_ADDRESS: '"Colab" <noreply@example.com>' | ||
| 16 | +SERVER_EMAIL: '"Colab" <noreply@example.com>' | ||
| 17 | + | ||
| 18 | +EMAIL_HOST: localhost | ||
| 19 | +EMAIL_PORT: 25 | ||
| 20 | +EMAIL_SUBJECT_PREFIX: '[colab]' | ||
| 21 | + | ||
| 22 | +SECRET_KEY: '{{ secret_key }}' | ||
| 23 | + | ||
| 24 | +SITE_URL: 'http://www.example.com/' | ||
| 25 | + | ||
| 26 | +ALLOWED_HOSTS: | ||
| 27 | + - example.com | ||
| 28 | + - example.org | ||
| 29 | + - example.net | ||
| 30 | + | ||
| 31 | +CONVERSEJS_ENABLED: false | ||
| 32 | + | ||
| 33 | +CONVERSEJS_AUTO_REGISTER: 'xmpp.example.com' | ||
| 34 | + | ||
| 35 | +DATABASES: | ||
| 36 | + default: | ||
| 37 | + ENGINE: django.db.backends.postgresql_psycopg2 | ||
| 38 | + HOST: localhost | ||
| 39 | + NAME: colab | ||
| 40 | + USER: colab | ||
| 41 | + PASSWORD: colab | ||
| 42 | + | ||
| 43 | +ROBOTS_NOINDEX: false | ||
| 44 | + | ||
| 45 | +# Set to false to disable | ||
| 46 | +RAVEN_DSN: 'http://public:secret@example.com/1' | ||
| 47 | + | ||
| 48 | +PROXIED_APPS: | ||
| 49 | + gitlab: | ||
| 50 | + upstream: 'http://localhost:8090/gitlab/' | ||
| 51 | + trac: | ||
| 52 | + upstream: 'http://localhost:5000/trac/' | ||
| 53 | + |
colab/colab/__init__.py
colab/colab/colab.template.yaml
| @@ -1,53 +0,0 @@ | @@ -1,53 +0,0 @@ | ||
| 1 | - | ||
| 2 | -DEBUG: false | ||
| 3 | -TEMPLATE_DEBUG: false | ||
| 4 | - | ||
| 5 | -ADMINS: &admin | ||
| 6 | - - | ||
| 7 | - - John Foo | ||
| 8 | - - john@example.com | ||
| 9 | - - | ||
| 10 | - - Mary Bar | ||
| 11 | - - mary@example.com | ||
| 12 | - | ||
| 13 | -MANAGERS: *admin | ||
| 14 | - | ||
| 15 | -COLAB_FROM_ADDRESS: '"Colab" <noreply@example.com>' | ||
| 16 | -SERVER_EMAIL: '"Colab" <noreply@example.com>' | ||
| 17 | - | ||
| 18 | -EMAIL_HOST: localhost | ||
| 19 | -EMAIL_PORT: 25 | ||
| 20 | -EMAIL_SUBJECT_PREFIX: '[colab]' | ||
| 21 | - | ||
| 22 | -SECRET_KEY: '{{ secret_key }}' | ||
| 23 | - | ||
| 24 | -SITE_URL: 'http://www.example.com/' | ||
| 25 | - | ||
| 26 | -ALLOWED_HOSTS: | ||
| 27 | - - example.com | ||
| 28 | - - example.org | ||
| 29 | - - example.net | ||
| 30 | - | ||
| 31 | -CONVERSEJS_ENABLED: false | ||
| 32 | - | ||
| 33 | -CONVERSEJS_AUTO_REGISTER: 'xmpp.example.com' | ||
| 34 | - | ||
| 35 | -DATABASES: | ||
| 36 | - default: | ||
| 37 | - ENGINE: django.db.backends.postgresql_psycopg2 | ||
| 38 | - HOST: localhost | ||
| 39 | - NAME: colab | ||
| 40 | - USER: colab | ||
| 41 | - PASSWORD: colab | ||
| 42 | - | ||
| 43 | -ROBOTS_NOINDEX: false | ||
| 44 | - | ||
| 45 | -# Set to false to disable | ||
| 46 | -RAVEN_DSN: 'http://public:secret@example.com/1' | ||
| 47 | - | ||
| 48 | -PROXIED_APPS: | ||
| 49 | - gitlab: | ||
| 50 | - upstream: 'http://localhost:8090/gitlab/' | ||
| 51 | - trac: | ||
| 52 | - upstream: 'http://localhost:5000/trac/' | ||
| 53 | - |
colab/colab/settings.py
| @@ -1,315 +0,0 @@ | @@ -1,315 +0,0 @@ | ||
| 1 | -""" | ||
| 2 | -Django settings for colab project. | ||
| 3 | - | ||
| 4 | -For more information on this file, see | ||
| 5 | -https://docs.djangoproject.com/en/1.7/topics/settings/ | ||
| 6 | - | ||
| 7 | -For the full list of settings and their values, see | ||
| 8 | -https://docs.djangoproject.com/en/1.7/ref/settings/ | ||
| 9 | -""" | ||
| 10 | - | ||
| 11 | -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
| 12 | -import os | ||
| 13 | -BASE_DIR = os.path.dirname(os.path.dirname(__file__)) | ||
| 14 | - | ||
| 15 | -# Used for settings translation | ||
| 16 | -from django.utils.translation import ugettext_lazy as _ | ||
| 17 | - | ||
| 18 | -# Quick-start development settings - unsuitable for production | ||
| 19 | -# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ | ||
| 20 | - | ||
| 21 | -# SECURITY WARNING: keep the secret key used in production secret! | ||
| 22 | -SECRET_KEY = "{{ secret_key }}" | ||
| 23 | - | ||
| 24 | -# SECURITY WARNING: don't run with debug turned on in production! | ||
| 25 | -DEBUG = True | ||
| 26 | - | ||
| 27 | -TEMPLATE_DEBUG = True | ||
| 28 | - | ||
| 29 | -ALLOWED_HOSTS = [] | ||
| 30 | - | ||
| 31 | -DATABASE_ROUTERS = [] | ||
| 32 | - | ||
| 33 | -# Application definition | ||
| 34 | - | ||
| 35 | -INSTALLED_APPS = ( | ||
| 36 | - 'django.contrib.admin', | ||
| 37 | - 'django.contrib.auth', | ||
| 38 | - 'django.contrib.contenttypes', | ||
| 39 | - 'django.contrib.sessions', | ||
| 40 | - 'django.contrib.messages', | ||
| 41 | - 'django.contrib.staticfiles', | ||
| 42 | - | ||
| 43 | - # First app to provide AUTH_USER_MODEL to others | ||
| 44 | - 'accounts', | ||
| 45 | - | ||
| 46 | - # Not standard apps | ||
| 47 | - 'raven.contrib.django.raven_compat', | ||
| 48 | - 'cliauth', | ||
| 49 | - 'django_mobile', | ||
| 50 | - 'django_browserid', | ||
| 51 | - 'conversejs', | ||
| 52 | - 'haystack', | ||
| 53 | - 'hitcounter', | ||
| 54 | - 'i18n_model', | ||
| 55 | - 'mptt', | ||
| 56 | - 'dpaste', | ||
| 57 | - | ||
| 58 | - # Own apps | ||
| 59 | - 'super_archives', | ||
| 60 | - 'api', | ||
| 61 | - 'rss', | ||
| 62 | - 'planet', | ||
| 63 | - 'search', | ||
| 64 | - 'badger', | ||
| 65 | - 'tz', | ||
| 66 | - | ||
| 67 | - # Feedzilla and deps | ||
| 68 | - 'feedzilla', | ||
| 69 | - 'taggit', | ||
| 70 | - 'common', | ||
| 71 | -) | ||
| 72 | - | ||
| 73 | -MIDDLEWARE_CLASSES = ( | ||
| 74 | - 'django.contrib.sessions.middleware.SessionMiddleware', | ||
| 75 | - 'django.middleware.common.CommonMiddleware', | ||
| 76 | - 'django.middleware.csrf.CsrfViewMiddleware', | ||
| 77 | - 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
| 78 | - 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | ||
| 79 | - 'django.contrib.messages.middleware.MessageMiddleware', | ||
| 80 | - 'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
| 81 | -) | ||
| 82 | - | ||
| 83 | -ROOT_URLCONF = 'colab.urls' | ||
| 84 | - | ||
| 85 | -WSGI_APPLICATION = 'colab.wsgi.application' | ||
| 86 | - | ||
| 87 | -# Internationalization | ||
| 88 | -# https://docs.djangoproject.com/en/1.7/topics/i18n/ | ||
| 89 | - | ||
| 90 | -LANGUAGE_CODE = 'en-us' | ||
| 91 | - | ||
| 92 | -TIME_ZONE = 'UTC' | ||
| 93 | - | ||
| 94 | -USE_I18N = True | ||
| 95 | - | ||
| 96 | -USE_L10N = True | ||
| 97 | - | ||
| 98 | -USE_TZ = True | ||
| 99 | - | ||
| 100 | - | ||
| 101 | -# Static files (CSS, JavaScript, Images) | ||
| 102 | -# https://docs.djangoproject.com/en/1.7/howto/static-files/ | ||
| 103 | - | ||
| 104 | -STATIC_ROOT = '/usr/share/nginx/colab/static/' | ||
| 105 | -MEDIA_ROOT = '/usr/share/nginx/colab/media/' | ||
| 106 | - | ||
| 107 | -STATIC_URL = '/static/' | ||
| 108 | -MEDIA_URL = '/media/' | ||
| 109 | - | ||
| 110 | - | ||
| 111 | -# Normally you should not import ANYTHING from Django directly | ||
| 112 | -# into your settings, but ImproperlyConfigured is an exception. | ||
| 113 | -from django.core.exceptions import ImproperlyConfigured | ||
| 114 | - | ||
| 115 | - | ||
| 116 | -def get_env_setting(setting): | ||
| 117 | - """ Get the environment setting or return exception """ | ||
| 118 | - try: | ||
| 119 | - return os.environ[setting] | ||
| 120 | - except KeyError: | ||
| 121 | - error_msg = "Set the %s env variable" % setting | ||
| 122 | - raise ImproperlyConfigured(error_msg) | ||
| 123 | - | ||
| 124 | - | ||
| 125 | -# Allow Django runserver to serve SVG files | ||
| 126 | -# https://code.djangoproject.com/ticket/20162 | ||
| 127 | -import mimetypes | ||
| 128 | -mimetypes.add_type('image/svg+xml', '.svg') | ||
| 129 | - | ||
| 130 | -LANGUAGES = ( | ||
| 131 | - ('en', _('English')), | ||
| 132 | - ('pt-br', _('Portuguese')), | ||
| 133 | - ('es', _('Spanish')), | ||
| 134 | -) | ||
| 135 | - | ||
| 136 | -DJANGO_DATE_FORMAT_TO_JS = { | ||
| 137 | - 'pt-br': ('pt-BR', 'dd/MM/yyyy'), | ||
| 138 | - 'es': ('es', 'dd/MM/yyyy'), | ||
| 139 | -} | ||
| 140 | - | ||
| 141 | -LANGUAGE_CODE = 'en' | ||
| 142 | - | ||
| 143 | -# The absolute path to the folder containing the attachments | ||
| 144 | -ATTACHMENTS_FOLDER_PATH = '/mnt/trac/attachments/' | ||
| 145 | - | ||
| 146 | -# ORDERING_DATA receives the options to order for as it's keys and a dict as | ||
| 147 | -# value, if you want to order for the last name, you can use something like: | ||
| 148 | -# 'last_name': {'name': 'Last Name', 'fields': 'last_name'} inside the dict, | ||
| 149 | -# you pass two major keys (name, fields) | ||
| 150 | -# The major key name is the name to appear on the template | ||
| 151 | -# the major key fields it show receive the name of the fields to order for in | ||
| 152 | -# the indexes | ||
| 153 | - | ||
| 154 | -ORDERING_DATA = { | ||
| 155 | - 'latest': { | ||
| 156 | - 'name': _(u'Recent activity'), | ||
| 157 | - 'fields': ('-modified', '-created'), | ||
| 158 | - }, | ||
| 159 | - 'hottest': { | ||
| 160 | - 'name': _(u'Relevance'), | ||
| 161 | - 'fields': None, | ||
| 162 | - }, | ||
| 163 | -} | ||
| 164 | - | ||
| 165 | - | ||
| 166 | -# File type groupings is a tuple of tuples containg what it should filter, | ||
| 167 | -# how it should be displayed, and a tuple of which mimetypes it includes | ||
| 168 | -FILE_TYPE_GROUPINGS = ( | ||
| 169 | - ('document', _(u'Document'), | ||
| 170 | - ('doc', 'docx', 'odt', 'otx', 'dotx', 'pdf', 'ott')), | ||
| 171 | - ('presentation', _(u'Presentation'), ('ppt', 'pptx', 'odp')), | ||
| 172 | - ('text', _(u'Text'), ('txt', 'po', 'conf', 'log')), | ||
| 173 | - ('code', _(u'Code'), | ||
| 174 | - ('py', 'php', 'js', 'sql', 'sh', 'patch', 'diff', 'html', '')), | ||
| 175 | - ('compressed', _(u'Compressed'), ('rar', 'zip', 'gz', 'tgz', 'bz2')), | ||
| 176 | - ('image', _(u'Image'), | ||
| 177 | - ('jpg', 'jpeg', 'png', 'tiff', 'gif', 'svg', 'psd', 'planner', 'cdr')), | ||
| 178 | - ('spreadsheet', _(u'Spreadsheet'), | ||
| 179 | - ('ods', 'xls', 'xlsx', 'xslt', 'csv')), | ||
| 180 | -) | ||
| 181 | - | ||
| 182 | -# the following variable define how many characters should be shown before | ||
| 183 | -# a highlighted word, to make sure that the highlighted word will appear | ||
| 184 | -HIGHLIGHT_NUM_CHARS_BEFORE_MATCH = 30 | ||
| 185 | -HAYSTACK_CUSTOM_HIGHLIGHTER = 'colab.utils.highlighting.ColabHighlighter' | ||
| 186 | - | ||
| 187 | -HAYSTACK_CONNECTIONS = { | ||
| 188 | - 'default': { | ||
| 189 | - 'ENGINE': 'haystack.backends.solr_backend.SolrEngine', | ||
| 190 | - 'URL': 'http://localhost:8983/solr/', | ||
| 191 | - } | ||
| 192 | -} | ||
| 193 | - | ||
| 194 | -CACHES = { | ||
| 195 | - 'default': { | ||
| 196 | - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', | ||
| 197 | - 'LOCATION': '127.0.0.1:11211', | ||
| 198 | - } | ||
| 199 | -} | ||
| 200 | - | ||
| 201 | -DATABASE_ROUTERS = [] | ||
| 202 | - | ||
| 203 | - | ||
| 204 | -TEMPLATE_CONTEXT_PROCESSORS = ( | ||
| 205 | - 'django.contrib.auth.context_processors.auth', | ||
| 206 | - 'django.core.context_processors.debug', | ||
| 207 | - 'django.core.context_processors.i18n', | ||
| 208 | - 'django.core.context_processors.media', | ||
| 209 | - 'django.core.context_processors.static', | ||
| 210 | - 'django.core.context_processors.tz', | ||
| 211 | - 'django.contrib.messages.context_processors.messages', | ||
| 212 | - 'django.core.context_processors.request', | ||
| 213 | - 'django_mobile.context_processors.is_mobile', | ||
| 214 | - 'super_archives.context_processors.mailarchive', | ||
| 215 | - 'proxy.context_processors.proxied_apps', | ||
| 216 | - 'home.context_processors.robots', | ||
| 217 | -) | ||
| 218 | - | ||
| 219 | -MIDDLEWARE_CLASSES = ( | ||
| 220 | - 'django.contrib.sessions.middleware.SessionMiddleware', | ||
| 221 | - 'django.middleware.locale.LocaleMiddleware', | ||
| 222 | - 'django.middleware.common.CommonMiddleware', | ||
| 223 | - 'django.middleware.csrf.CsrfViewMiddleware', | ||
| 224 | - 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
| 225 | - 'django.contrib.messages.middleware.MessageMiddleware', | ||
| 226 | - 'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
| 227 | - 'django_mobile.middleware.MobileDetectionMiddleware', | ||
| 228 | - 'django_mobile.middleware.SetFlavourMiddleware', | ||
| 229 | - 'tz.middleware.TimezoneMiddleware', | ||
| 230 | -) | ||
| 231 | - | ||
| 232 | -# Add the django_browserid authentication backend. | ||
| 233 | -AUTHENTICATION_BACKENDS = ( | ||
| 234 | - 'django.contrib.auth.backends.ModelBackend', | ||
| 235 | - 'accounts.auth.ColabBrowserIDBackend', | ||
| 236 | -) | ||
| 237 | - | ||
| 238 | -STATICFILES_DIRS = ( | ||
| 239 | - os.path.join(BASE_DIR, 'static'), | ||
| 240 | -) | ||
| 241 | - | ||
| 242 | -TEMPLATE_DIRS = ( | ||
| 243 | - os.path.join(BASE_DIR, 'templates'), | ||
| 244 | -) | ||
| 245 | - | ||
| 246 | -LOCALE_PATHS = ( | ||
| 247 | - os.path.join(BASE_DIR, 'locale'), | ||
| 248 | -) | ||
| 249 | - | ||
| 250 | -AUTH_USER_MODEL = 'accounts.User' | ||
| 251 | - | ||
| 252 | -from django.contrib.messages import constants as messages | ||
| 253 | -MESSAGE_TAGS = { | ||
| 254 | - messages.INFO: 'alert-info', | ||
| 255 | - messages.SUCCESS: 'alert-success', | ||
| 256 | - messages.WARNING: 'alert-warning', | ||
| 257 | - messages.ERROR: 'alert-danger', | ||
| 258 | -} | ||
| 259 | - | ||
| 260 | -### Feedzilla (planet) | ||
| 261 | -from feedzilla.settings import * | ||
| 262 | -FEEDZILLA_PAGE_SIZE = 5 | ||
| 263 | -FEEDZILLA_SITE_TITLE = _(u'Planet Colab') | ||
| 264 | -FEEDZILLA_SITE_DESCRIPTION = _(u'Colab blog aggregator') | ||
| 265 | - | ||
| 266 | -### Mailman API settings | ||
| 267 | -MAILMAN_API_URL = 'http://localhost:9000' | ||
| 268 | - | ||
| 269 | -### BrowserID / Persona | ||
| 270 | -SITE_URL = 'localhost:8000' | ||
| 271 | -BROWSERID_AUDIENCES = [SITE_URL, SITE_URL.replace('https', 'http')] | ||
| 272 | - | ||
| 273 | - | ||
| 274 | -LOGIN_URL = '/' | ||
| 275 | -LOGIN_REDIRECT_URL = '/' | ||
| 276 | -LOGIN_REDIRECT_URL_FAILURE = '/' | ||
| 277 | -LOGOUT_REDIRECT_URL = '/user/logout' | ||
| 278 | -BROWSERID_CREATE_USER = False | ||
| 279 | - | ||
| 280 | -REVPROXY_ADD_REMOTE_USER = True | ||
| 281 | - | ||
| 282 | -## Converse.js settings | ||
| 283 | -# This URL must use SSL in order to keep chat sessions secure | ||
| 284 | -CONVERSEJS_BOSH_SERVICE_URL = SITE_URL + '/http-bind' | ||
| 285 | - | ||
| 286 | -CONVERSEJS_ALLOW_CONTACT_REQUESTS = False | ||
| 287 | -CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True | ||
| 288 | - | ||
| 289 | - | ||
| 290 | -# Tastypie settings | ||
| 291 | -TASTYPIE_DEFAULT_FORMATS = ['json', ] | ||
| 292 | - | ||
| 293 | -# Dpaste settings | ||
| 294 | -DPASTE_EXPIRE_CHOICES = ( | ||
| 295 | - ('onetime', _(u'One Time Snippet')), | ||
| 296 | - (3600, _(u'In one hour')), | ||
| 297 | - (3600 * 24 * 7, _(u'In one week')), | ||
| 298 | - (3600 * 24 * 30, _(u'In one month')), | ||
| 299 | - ('never', _(u'Never')), | ||
| 300 | -) | ||
| 301 | -DPASTE_EXPIRE_DEFAULT = DPASTE_EXPIRE_CHOICES[4][0] | ||
| 302 | -DPASTE_DEFAULT_GIST_DESCRIPTION = 'Gist created from Colab DPaste' | ||
| 303 | -DPASTE_DEFAULT_GIST_NAME = 'colab_paste' | ||
| 304 | -DPASTE_LEXER_DEFAULT = 'text' | ||
| 305 | - | ||
| 306 | -from .utils.conf import load_yaml_settings | ||
| 307 | -locals().update(load_yaml_settings()) | ||
| 308 | - | ||
| 309 | -if locals().get('RAVEN_DSN', False): | ||
| 310 | - RAVEN_CONFIG = { | ||
| 311 | - 'dsn': RAVEN_DSN + '?timeout=30', | ||
| 312 | - } | ||
| 313 | - | ||
| 314 | -for app_label in locals().get('PROXIED_APPS', {}).keys(): | ||
| 315 | - INSTALLED_APPS += ('proxy.{}'.format(app_label),) |
colab/colab/urls.py
| @@ -1,45 +0,0 @@ | @@ -1,45 +0,0 @@ | ||
| 1 | -from django.conf.urls import patterns, include, url, static | ||
| 2 | -from django.conf import settings | ||
| 3 | -from django.views.generic import TemplateView | ||
| 4 | -from django.contrib import admin | ||
| 5 | - | ||
| 6 | -from accounts.models import User | ||
| 7 | -from search.forms import ColabSearchForm | ||
| 8 | -from super_archives.models import Message | ||
| 9 | - | ||
| 10 | - | ||
| 11 | -admin.autodiscover() | ||
| 12 | - | ||
| 13 | -urlpatterns = patterns('', | ||
| 14 | - url(r'^$', 'home.views.index', name='home'), | ||
| 15 | - url(r'^robots.txt$', 'home.views.robots', name='robots'), | ||
| 16 | - | ||
| 17 | - url(r'^open-data/$', TemplateView.as_view(template_name='open-data.html'), | ||
| 18 | - name='opendata'), | ||
| 19 | - | ||
| 20 | - url(r'^search/', include('search.urls')), | ||
| 21 | - url(r'^archives/', include('super_archives.urls')), | ||
| 22 | - url(r'^api/', include('api.urls')), | ||
| 23 | - url(r'^rss/', include('rss.urls')), | ||
| 24 | - | ||
| 25 | - url(r'^user/', include('accounts.urls')), # Kept for backwards compatibility | ||
| 26 | - url(r'^signup/', include('accounts.urls')), # (same here) TODO: move to nginx | ||
| 27 | - url(r'^account/', include('accounts.urls')), | ||
| 28 | - | ||
| 29 | - url(r'', include('django_browserid.urls')), | ||
| 30 | - | ||
| 31 | - url(r'^planet/', include('feedzilla.urls')), | ||
| 32 | - | ||
| 33 | - url(r'paste/', include('dpaste.urls.dpaste')), | ||
| 34 | - | ||
| 35 | - # Uncomment the next line to enable the admin: | ||
| 36 | - url(r'^colab/admin/', include(admin.site.urls)), | ||
| 37 | - | ||
| 38 | - url(r'^trac/', include('proxy.trac.urls')), | ||
| 39 | -) | ||
| 40 | - | ||
| 41 | -if settings.DEBUG: | ||
| 42 | - urlpatterns += static.static( | ||
| 43 | - settings.MEDIA_URL, | ||
| 44 | - document_root=settings.MEDIA_ROOT | ||
| 45 | - ) |
colab/colab/utils/__init__.py
colab/colab/utils/conf.py
| @@ -1,32 +0,0 @@ | @@ -1,32 +0,0 @@ | ||
| 1 | - | ||
| 2 | -import os | ||
| 3 | -import yaml | ||
| 4 | - | ||
| 5 | -from django.core.exceptions import ImproperlyConfigured | ||
| 6 | - | ||
| 7 | - | ||
| 8 | -class InaccessibleYAMLSettings(ImproperlyConfigured): | ||
| 9 | - """Settings YAML is Inaccessible. | ||
| 10 | - | ||
| 11 | - Check if the file exists and if you have read permissions.""" | ||
| 12 | - | ||
| 13 | - | ||
| 14 | -def load_yaml_settings(): | ||
| 15 | - yaml_path = os.getenv('COLAB_SETTINGS', '/etc/colab.yaml') | ||
| 16 | - | ||
| 17 | - if not os.path.exists(yaml_path): | ||
| 18 | - msg = "The yaml file {} does not exist".format(yaml_path) | ||
| 19 | - raise InaccessibleYAMLSettings(msg) | ||
| 20 | - | ||
| 21 | - try: | ||
| 22 | - with open(yaml_path) as yaml_file: | ||
| 23 | - yaml_settings = yaml.load(yaml_file.read()) | ||
| 24 | - except IOError: | ||
| 25 | - msg = ('Could not open settings file {}. Please ' | ||
| 26 | - 'check if the file exists and if user ' | ||
| 27 | - 'has read rights.').format(yaml_path) | ||
| 28 | - raise InaccessibleYAMLSettings(msg) | ||
| 29 | - | ||
| 30 | - return yaml_settings | ||
| 31 | - | ||
| 32 | -yaml_settings = load_yaml_settings() |
colab/colab/utils/highlighting.py
| @@ -1,38 +0,0 @@ | @@ -1,38 +0,0 @@ | ||
| 1 | -from haystack.utils import Highlighter | ||
| 2 | -from django.conf import settings | ||
| 3 | -from django.utils.html import escape, strip_tags | ||
| 4 | - | ||
| 5 | - | ||
| 6 | -class ColabHighlighter(Highlighter): | ||
| 7 | - def highlight(self, text_block): | ||
| 8 | - self.text_block = escape(strip_tags(text_block)) | ||
| 9 | - highlight_locations = self.find_highlightable_words() | ||
| 10 | - start_offset, end_offset = self.find_window(highlight_locations) | ||
| 11 | - return self.render_html(highlight_locations, start_offset, end_offset) | ||
| 12 | - | ||
| 13 | - def find_window(self, highlight_locations): | ||
| 14 | - """Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting | ||
| 15 | - to find how many characters before the first word found should | ||
| 16 | - be removed from the window | ||
| 17 | - """ | ||
| 18 | - | ||
| 19 | - if len(self.text_block) <= self.max_length: | ||
| 20 | - return (0, self.max_length) | ||
| 21 | - | ||
| 22 | - num_chars_before = getattr( | ||
| 23 | - settings, | ||
| 24 | - 'HIGHLIGHT_NUM_CHARS_BEFORE_MATCH', | ||
| 25 | - 0 | ||
| 26 | - ) | ||
| 27 | - | ||
| 28 | - best_start, best_end = super(ColabHighlighter, self).find_window( | ||
| 29 | - highlight_locations | ||
| 30 | - ) | ||
| 31 | - if best_start <= num_chars_before: | ||
| 32 | - best_end -= best_start | ||
| 33 | - best_start = 0 | ||
| 34 | - else: | ||
| 35 | - best_start -= num_chars_before | ||
| 36 | - best_end -= num_chars_before | ||
| 37 | - | ||
| 38 | - return (best_start, best_end) |
colab/colab/wsgi.py
| @@ -1,14 +0,0 @@ | @@ -1,14 +0,0 @@ | ||
| 1 | -""" | ||
| 2 | -WSGI config for colab project. | ||
| 3 | - | ||
| 4 | -It exposes the WSGI callable as a module-level variable named ``application``. | ||
| 5 | - | ||
| 6 | -For more information on this file, see | ||
| 7 | -https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/ | ||
| 8 | -""" | ||
| 9 | - | ||
| 10 | -import os | ||
| 11 | -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "colab.settings") | ||
| 12 | - | ||
| 13 | -from django.core.wsgi import get_wsgi_application | ||
| 14 | -application = get_wsgi_application() |
colab/home/views.py
| @@ -6,11 +6,11 @@ from django.core.cache import cache | @@ -6,11 +6,11 @@ from django.core.cache import cache | ||
| 6 | from django.shortcuts import render | 6 | from django.shortcuts import render |
| 7 | from django.http import HttpResponse, Http404 | 7 | from django.http import HttpResponse, Http404 |
| 8 | 8 | ||
| 9 | -from search.utils import trans | ||
| 10 | from haystack.query import SearchQuerySet | 9 | from haystack.query import SearchQuerySet |
| 11 | 10 | ||
| 12 | #from proxy.trac.models import WikiCollabCount, TicketCollabCount | 11 | #from proxy.trac.models import WikiCollabCount, TicketCollabCount |
| 13 | -from super_archives.models import Thread | 12 | +from colab.search.utils import trans |
| 13 | +from colab.super_archives.models import Thread | ||
| 14 | 14 | ||
| 15 | 15 | ||
| 16 | def index(request): | 16 | def index(request): |
colab/manage.py
| @@ -1,10 +0,0 @@ | @@ -1,10 +0,0 @@ | ||
| 1 | -#!/usr/bin/env python | ||
| 2 | -import os | ||
| 3 | -import sys | ||
| 4 | - | ||
| 5 | -if __name__ == "__main__": | ||
| 6 | - os.environ.setdefault("DJANGO_SETTINGS_MODULE", "colab.settings") | ||
| 7 | - | ||
| 8 | - from django.core.management import execute_from_command_line | ||
| 9 | - | ||
| 10 | - execute_from_command_line(sys.argv) |
colab/proxy/gitlab/__init__.py
colab/proxy/gitlab/apps.py
| @@ -3,5 +3,5 @@ from ..utils.apps import ColabProxiedAppConfig | @@ -3,5 +3,5 @@ from ..utils.apps import ColabProxiedAppConfig | ||
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | class ProxyGitlabAppConfig(ColabProxiedAppConfig): | 5 | class ProxyGitlabAppConfig(ColabProxiedAppConfig): |
| 6 | - name = 'proxy.gitlab' | 6 | + name = 'colab.proxy.gitlab' |
| 7 | verbose_name = 'Gitlab Proxy' | 7 | verbose_name = 'Gitlab Proxy' |
colab/proxy/jenkins/__init__.py
colab/proxy/jenkins/apps.py
| @@ -3,5 +3,5 @@ from ..utils.apps import ColabProxiedAppConfig | @@ -3,5 +3,5 @@ from ..utils.apps import ColabProxiedAppConfig | ||
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | class ProxyJenkinsAppConfig(ColabProxiedAppConfig): | 5 | class ProxyJenkinsAppConfig(ColabProxiedAppConfig): |
| 6 | - name = 'proxy.jenkins' | 6 | + name = 'colab.proxy.jenkins' |
| 7 | verbose_name = 'Jenkins Proxy' | 7 | verbose_name = 'Jenkins Proxy' |
colab/proxy/redmine/__init__.py
colab/proxy/redmine/apps.py
| @@ -3,5 +3,5 @@ from ..utils.apps import ColabProxiedAppConfig | @@ -3,5 +3,5 @@ from ..utils.apps import ColabProxiedAppConfig | ||
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | class ProxyRedmineAppConfig(ColabProxiedAppConfig): | 5 | class ProxyRedmineAppConfig(ColabProxiedAppConfig): |
| 6 | - name = 'proxy.redmine' | 6 | + name = 'colab.proxy.redmine' |
| 7 | verbose_name = 'Redmine Proxy' | 7 | verbose_name = 'Redmine Proxy' |
colab/proxy/trac/__init__.py
colab/proxy/trac/apps.py
| @@ -3,5 +3,5 @@ from ..utils.apps import ColabProxiedAppConfig | @@ -3,5 +3,5 @@ from ..utils.apps import ColabProxiedAppConfig | ||
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | class ProxyTracAppConfig(ColabProxiedAppConfig): | 5 | class ProxyTracAppConfig(ColabProxiedAppConfig): |
| 6 | - name = 'proxy.trac' | 6 | + name = 'colab.proxy.trac' |
| 7 | verbose_name = 'Trac Proxy' | 7 | verbose_name = 'Trac Proxy' |
colab/proxy/trac/models.py
| 1 | # -*- coding: utf-8 -*- | 1 | # -*- coding: utf-8 -*- |
| 2 | -from django.db import models | ||
| 3 | -from django.conf import settings | ||
| 4 | import os | 2 | import os |
| 5 | import urllib2 | 3 | import urllib2 |
| 6 | 4 | ||
| 7 | -from accounts.models import User | 5 | +from django.db import models |
| 6 | +from django.conf import settings | ||
| 7 | + | ||
| 8 | from hitcounter.models import HitCounterModelMixin | 8 | from hitcounter.models import HitCounterModelMixin |
| 9 | 9 | ||
| 10 | +from colab.accounts.models import User | ||
| 11 | + | ||
| 10 | 12 | ||
| 11 | class Attachment(models.Model, HitCounterModelMixin): | 13 | class Attachment(models.Model, HitCounterModelMixin): |
| 12 | url = models.TextField(primary_key=True) | 14 | url = models.TextField(primary_key=True) |
colab/proxy/trac/search_indexes.py
| @@ -8,7 +8,7 @@ from django.utils.text import slugify | @@ -8,7 +8,7 @@ from django.utils.text import slugify | ||
| 8 | from haystack import indexes | 8 | from haystack import indexes |
| 9 | from haystack.utils import log as logging | 9 | from haystack.utils import log as logging |
| 10 | 10 | ||
| 11 | -from search.base_indexes import BaseIndex | 11 | +from colab.search.base_indexes import BaseIndex |
| 12 | from .models import Attachment, Ticket, Wiki, Revision | 12 | from .models import Attachment, Ticket, Wiki, Revision |
| 13 | 13 | ||
| 14 | 14 |
colab/proxy/trac/signals.py
| @@ -3,7 +3,7 @@ from django.db import connections | @@ -3,7 +3,7 @@ from django.db import connections | ||
| 3 | from django.dispatch import receiver | 3 | from django.dispatch import receiver |
| 4 | from django.db.models.signals import post_save | 4 | from django.db.models.signals import post_save |
| 5 | 5 | ||
| 6 | -from accounts.models import User | 6 | +from colab.accounts.models import User |
| 7 | 7 | ||
| 8 | 8 | ||
| 9 | @receiver(post_save, sender=User) | 9 | @receiver(post_save, sender=User) |
colab/rss/feeds.py
| @@ -6,7 +6,7 @@ from django.utils.translation import ugettext as _ | @@ -6,7 +6,7 @@ from django.utils.translation import ugettext as _ | ||
| 6 | 6 | ||
| 7 | from haystack.query import SearchQuerySet | 7 | from haystack.query import SearchQuerySet |
| 8 | 8 | ||
| 9 | -from super_archives.models import Thread | 9 | +from colab.super_archives.models import Thread |
| 10 | 10 | ||
| 11 | 11 | ||
| 12 | class LatestThreadsFeeds(Feed): | 12 | class LatestThreadsFeeds(Feed): |
colab/search/forms.py
| @@ -8,8 +8,8 @@ from django.utils.translation import ugettext_lazy as _ | @@ -8,8 +8,8 @@ from django.utils.translation import ugettext_lazy as _ | ||
| 8 | from haystack.forms import SearchForm | 8 | from haystack.forms import SearchForm |
| 9 | from haystack.inputs import AltParser | 9 | from haystack.inputs import AltParser |
| 10 | 10 | ||
| 11 | -from accounts.models import User | ||
| 12 | -from super_archives.models import Message, MailingList | 11 | +from colab.accounts.models import User |
| 12 | +from colab.super_archives.models import Message, MailingList | ||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | class ColabSearchForm(SearchForm): | 15 | class ColabSearchForm(SearchForm): |
| @@ -0,0 +1,316 @@ | @@ -0,0 +1,316 @@ | ||
| 1 | +""" | ||
| 2 | +Django settings for colab project. | ||
| 3 | + | ||
| 4 | +For more information on this file, see | ||
| 5 | +https://docs.djangoproject.com/en/1.7/topics/settings/ | ||
| 6 | + | ||
| 7 | +For the full list of settings and their values, see | ||
| 8 | +https://docs.djangoproject.com/en/1.7/ref/settings/ | ||
| 9 | +""" | ||
| 10 | + | ||
| 11 | +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) | ||
| 12 | +import os | ||
| 13 | +BASE_DIR = os.path.dirname(__file__) | ||
| 14 | + | ||
| 15 | +# Used for settings translation | ||
| 16 | +from django.utils.translation import ugettext_lazy as _ | ||
| 17 | + | ||
| 18 | +# Quick-start development settings - unsuitable for production | ||
| 19 | +# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ | ||
| 20 | + | ||
| 21 | +# SECURITY WARNING: keep the secret key used in production secret! | ||
| 22 | +SECRET_KEY = "" | ||
| 23 | + | ||
| 24 | +# SECURITY WARNING: don't run with debug turned on in production! | ||
| 25 | +DEBUG = True | ||
| 26 | + | ||
| 27 | +TEMPLATE_DEBUG = True | ||
| 28 | + | ||
| 29 | +ALLOWED_HOSTS = [] | ||
| 30 | + | ||
| 31 | +DATABASE_ROUTERS = [] | ||
| 32 | + | ||
| 33 | +# Application definition | ||
| 34 | + | ||
| 35 | +INSTALLED_APPS = ( | ||
| 36 | + 'django.contrib.admin', | ||
| 37 | + 'django.contrib.auth', | ||
| 38 | + 'django.contrib.contenttypes', | ||
| 39 | + 'django.contrib.sessions', | ||
| 40 | + 'django.contrib.messages', | ||
| 41 | + 'django.contrib.staticfiles', | ||
| 42 | + | ||
| 43 | + # First app to provide AUTH_USER_MODEL to others | ||
| 44 | + 'colab.accounts', | ||
| 45 | + | ||
| 46 | + # Not standard apps | ||
| 47 | + 'cliauth', | ||
| 48 | + 'django_mobile', | ||
| 49 | + 'django_browserid', | ||
| 50 | + 'conversejs', | ||
| 51 | + 'haystack', | ||
| 52 | + 'hitcounter', | ||
| 53 | + 'i18n_model', | ||
| 54 | + 'mptt', | ||
| 55 | + 'dpaste', | ||
| 56 | + | ||
| 57 | + # Own apps | ||
| 58 | + 'colab.home', | ||
| 59 | + 'colab.super_archives', | ||
| 60 | + 'colab.api', | ||
| 61 | + 'colab.rss', | ||
| 62 | + 'colab.planet', | ||
| 63 | + 'colab.search', | ||
| 64 | + 'colab.badger', | ||
| 65 | + 'colab.tz', | ||
| 66 | + | ||
| 67 | + # Feedzilla and deps | ||
| 68 | + 'feedzilla', | ||
| 69 | + 'taggit', | ||
| 70 | + 'common', | ||
| 71 | +) | ||
| 72 | + | ||
| 73 | +MIDDLEWARE_CLASSES = ( | ||
| 74 | + 'django.contrib.sessions.middleware.SessionMiddleware', | ||
| 75 | + 'django.middleware.common.CommonMiddleware', | ||
| 76 | + 'django.middleware.csrf.CsrfViewMiddleware', | ||
| 77 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
| 78 | + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | ||
| 79 | + 'django.contrib.messages.middleware.MessageMiddleware', | ||
| 80 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
| 81 | +) | ||
| 82 | + | ||
| 83 | +ROOT_URLCONF = 'colab.urls' | ||
| 84 | + | ||
| 85 | +WSGI_APPLICATION = 'colab.wsgi.application' | ||
| 86 | + | ||
| 87 | +# Internationalization | ||
| 88 | +# https://docs.djangoproject.com/en/1.7/topics/i18n/ | ||
| 89 | + | ||
| 90 | +LANGUAGE_CODE = 'en-us' | ||
| 91 | + | ||
| 92 | +TIME_ZONE = 'UTC' | ||
| 93 | + | ||
| 94 | +USE_I18N = True | ||
| 95 | + | ||
| 96 | +USE_L10N = True | ||
| 97 | + | ||
| 98 | +USE_TZ = True | ||
| 99 | + | ||
| 100 | + | ||
| 101 | +# Static files (CSS, JavaScript, Images) | ||
| 102 | +# https://docs.djangoproject.com/en/1.7/howto/static-files/ | ||
| 103 | + | ||
| 104 | +STATIC_ROOT = '/usr/share/nginx/colab/static/' | ||
| 105 | +MEDIA_ROOT = '/usr/share/nginx/colab/media/' | ||
| 106 | + | ||
| 107 | +STATIC_URL = '/static/' | ||
| 108 | +MEDIA_URL = '/media/' | ||
| 109 | + | ||
| 110 | + | ||
| 111 | +# Normally you should not import ANYTHING from Django directly | ||
| 112 | +# into your settings, but ImproperlyConfigured is an exception. | ||
| 113 | +from django.core.exceptions import ImproperlyConfigured | ||
| 114 | + | ||
| 115 | + | ||
| 116 | +def get_env_setting(setting): | ||
| 117 | + """ Get the environment setting or return exception """ | ||
| 118 | + try: | ||
| 119 | + return os.environ[setting] | ||
| 120 | + except KeyError: | ||
| 121 | + error_msg = "Set the %s env variable" % setting | ||
| 122 | + raise ImproperlyConfigured(error_msg) | ||
| 123 | + | ||
| 124 | + | ||
| 125 | +# Allow Django runserver to serve SVG files | ||
| 126 | +# https://code.djangoproject.com/ticket/20162 | ||
| 127 | +import mimetypes | ||
| 128 | +mimetypes.add_type('image/svg+xml', '.svg') | ||
| 129 | + | ||
| 130 | +LANGUAGES = ( | ||
| 131 | + ('en', _('English')), | ||
| 132 | + ('pt-br', _('Portuguese')), | ||
| 133 | + ('es', _('Spanish')), | ||
| 134 | +) | ||
| 135 | + | ||
| 136 | +DJANGO_DATE_FORMAT_TO_JS = { | ||
| 137 | + 'pt-br': ('pt-BR', 'dd/MM/yyyy'), | ||
| 138 | + 'es': ('es', 'dd/MM/yyyy'), | ||
| 139 | +} | ||
| 140 | + | ||
| 141 | +LANGUAGE_CODE = 'en' | ||
| 142 | + | ||
| 143 | +# The absolute path to the folder containing the attachments | ||
| 144 | +ATTACHMENTS_FOLDER_PATH = '/mnt/trac/attachments/' | ||
| 145 | + | ||
| 146 | +# ORDERING_DATA receives the options to order for as it's keys and a dict as | ||
| 147 | +# value, if you want to order for the last name, you can use something like: | ||
| 148 | +# 'last_name': {'name': 'Last Name', 'fields': 'last_name'} inside the dict, | ||
| 149 | +# you pass two major keys (name, fields) | ||
| 150 | +# The major key name is the name to appear on the template | ||
| 151 | +# the major key fields it show receive the name of the fields to order for in | ||
| 152 | +# the indexes | ||
| 153 | + | ||
| 154 | +ORDERING_DATA = { | ||
| 155 | + 'latest': { | ||
| 156 | + 'name': _(u'Recent activity'), | ||
| 157 | + 'fields': ('-modified', '-created'), | ||
| 158 | + }, | ||
| 159 | + 'hottest': { | ||
| 160 | + 'name': _(u'Relevance'), | ||
| 161 | + 'fields': None, | ||
| 162 | + }, | ||
| 163 | +} | ||
| 164 | + | ||
| 165 | + | ||
| 166 | +# File type groupings is a tuple of tuples containg what it should filter, | ||
| 167 | +# how it should be displayed, and a tuple of which mimetypes it includes | ||
| 168 | +FILE_TYPE_GROUPINGS = ( | ||
| 169 | + ('document', _(u'Document'), | ||
| 170 | + ('doc', 'docx', 'odt', 'otx', 'dotx', 'pdf', 'ott')), | ||
| 171 | + ('presentation', _(u'Presentation'), ('ppt', 'pptx', 'odp')), | ||
| 172 | + ('text', _(u'Text'), ('txt', 'po', 'conf', 'log')), | ||
| 173 | + ('code', _(u'Code'), | ||
| 174 | + ('py', 'php', 'js', 'sql', 'sh', 'patch', 'diff', 'html', '')), | ||
| 175 | + ('compressed', _(u'Compressed'), ('rar', 'zip', 'gz', 'tgz', 'bz2')), | ||
| 176 | + ('image', _(u'Image'), | ||
| 177 | + ('jpg', 'jpeg', 'png', 'tiff', 'gif', 'svg', 'psd', 'planner', 'cdr')), | ||
| 178 | + ('spreadsheet', _(u'Spreadsheet'), | ||
| 179 | + ('ods', 'xls', 'xlsx', 'xslt', 'csv')), | ||
| 180 | +) | ||
| 181 | + | ||
| 182 | +# the following variable define how many characters should be shown before | ||
| 183 | +# a highlighted word, to make sure that the highlighted word will appear | ||
| 184 | +HIGHLIGHT_NUM_CHARS_BEFORE_MATCH = 30 | ||
| 185 | +HAYSTACK_CUSTOM_HIGHLIGHTER = 'colab.utils.highlighting.ColabHighlighter' | ||
| 186 | + | ||
| 187 | +HAYSTACK_CONNECTIONS = { | ||
| 188 | + 'default': { | ||
| 189 | + 'ENGINE': 'haystack.backends.solr_backend.SolrEngine', | ||
| 190 | + 'URL': 'http://localhost:8983/solr/', | ||
| 191 | + } | ||
| 192 | +} | ||
| 193 | + | ||
| 194 | +CACHES = { | ||
| 195 | + 'default': { | ||
| 196 | + 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', | ||
| 197 | + 'LOCATION': '127.0.0.1:11211', | ||
| 198 | + } | ||
| 199 | +} | ||
| 200 | + | ||
| 201 | +DATABASE_ROUTERS = [] | ||
| 202 | + | ||
| 203 | + | ||
| 204 | +TEMPLATE_CONTEXT_PROCESSORS = ( | ||
| 205 | + 'django.contrib.auth.context_processors.auth', | ||
| 206 | + 'django.core.context_processors.debug', | ||
| 207 | + 'django.core.context_processors.i18n', | ||
| 208 | + 'django.core.context_processors.media', | ||
| 209 | + 'django.core.context_processors.static', | ||
| 210 | + 'django.core.context_processors.tz', | ||
| 211 | + 'django.contrib.messages.context_processors.messages', | ||
| 212 | + 'django.core.context_processors.request', | ||
| 213 | + 'django_mobile.context_processors.is_mobile', | ||
| 214 | + 'colab.super_archives.context_processors.mailarchive', | ||
| 215 | + 'colab.proxy.context_processors.proxied_apps', | ||
| 216 | + 'colab.home.context_processors.robots', | ||
| 217 | +) | ||
| 218 | + | ||
| 219 | +MIDDLEWARE_CLASSES = ( | ||
| 220 | + 'django.contrib.sessions.middleware.SessionMiddleware', | ||
| 221 | + 'django.middleware.locale.LocaleMiddleware', | ||
| 222 | + 'django.middleware.common.CommonMiddleware', | ||
| 223 | + 'django.middleware.csrf.CsrfViewMiddleware', | ||
| 224 | + 'django.contrib.auth.middleware.AuthenticationMiddleware', | ||
| 225 | + 'django.contrib.messages.middleware.MessageMiddleware', | ||
| 226 | + 'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||
| 227 | + 'django_mobile.middleware.MobileDetectionMiddleware', | ||
| 228 | + 'django_mobile.middleware.SetFlavourMiddleware', | ||
| 229 | + 'colab.tz.middleware.TimezoneMiddleware', | ||
| 230 | +) | ||
| 231 | + | ||
| 232 | +# Add the django_browserid authentication backend. | ||
| 233 | +AUTHENTICATION_BACKENDS = ( | ||
| 234 | + 'django.contrib.auth.backends.ModelBackend', | ||
| 235 | + 'colab.accounts.auth.ColabBrowserIDBackend', | ||
| 236 | +) | ||
| 237 | + | ||
| 238 | +STATICFILES_DIRS = ( | ||
| 239 | + os.path.join(BASE_DIR, 'static'), | ||
| 240 | +) | ||
| 241 | + | ||
| 242 | +TEMPLATE_DIRS = ( | ||
| 243 | + os.path.join(BASE_DIR, 'templates'), | ||
| 244 | +) | ||
| 245 | + | ||
| 246 | +LOCALE_PATHS = ( | ||
| 247 | + os.path.join(BASE_DIR, 'locale'), | ||
| 248 | +) | ||
| 249 | + | ||
| 250 | +AUTH_USER_MODEL = 'accounts.User' | ||
| 251 | + | ||
| 252 | +from django.contrib.messages import constants as messages | ||
| 253 | +MESSAGE_TAGS = { | ||
| 254 | + messages.INFO: 'alert-info', | ||
| 255 | + messages.SUCCESS: 'alert-success', | ||
| 256 | + messages.WARNING: 'alert-warning', | ||
| 257 | + messages.ERROR: 'alert-danger', | ||
| 258 | +} | ||
| 259 | + | ||
| 260 | +### Feedzilla (planet) | ||
| 261 | +from feedzilla.settings import * | ||
| 262 | +FEEDZILLA_PAGE_SIZE = 5 | ||
| 263 | +FEEDZILLA_SITE_TITLE = _(u'Planet Colab') | ||
| 264 | +FEEDZILLA_SITE_DESCRIPTION = _(u'Colab blog aggregator') | ||
| 265 | + | ||
| 266 | +### Mailman API settings | ||
| 267 | +MAILMAN_API_URL = 'http://localhost:9000' | ||
| 268 | + | ||
| 269 | +### BrowserID / Persona | ||
| 270 | +SITE_URL = 'localhost:8000' | ||
| 271 | +BROWSERID_AUDIENCES = [SITE_URL, SITE_URL.replace('https', 'http')] | ||
| 272 | + | ||
| 273 | + | ||
| 274 | +LOGIN_URL = '/' | ||
| 275 | +LOGIN_REDIRECT_URL = '/' | ||
| 276 | +LOGIN_REDIRECT_URL_FAILURE = '/' | ||
| 277 | +LOGOUT_REDIRECT_URL = '/user/logout' | ||
| 278 | +BROWSERID_CREATE_USER = False | ||
| 279 | + | ||
| 280 | +REVPROXY_ADD_REMOTE_USER = True | ||
| 281 | + | ||
| 282 | +## Converse.js settings | ||
| 283 | +# This URL must use SSL in order to keep chat sessions secure | ||
| 284 | +CONVERSEJS_BOSH_SERVICE_URL = SITE_URL + '/http-bind' | ||
| 285 | + | ||
| 286 | +CONVERSEJS_ALLOW_CONTACT_REQUESTS = False | ||
| 287 | +CONVERSEJS_SHOW_ONLY_ONLINE_USERS = True | ||
| 288 | + | ||
| 289 | + | ||
| 290 | +# Tastypie settings | ||
| 291 | +TASTYPIE_DEFAULT_FORMATS = ['json', ] | ||
| 292 | + | ||
| 293 | +# Dpaste settings | ||
| 294 | +DPASTE_EXPIRE_CHOICES = ( | ||
| 295 | + ('onetime', _(u'One Time Snippet')), | ||
| 296 | + (3600, _(u'In one hour')), | ||
| 297 | + (3600 * 24 * 7, _(u'In one week')), | ||
| 298 | + (3600 * 24 * 30, _(u'In one month')), | ||
| 299 | + ('never', _(u'Never')), | ||
| 300 | +) | ||
| 301 | +DPASTE_EXPIRE_DEFAULT = DPASTE_EXPIRE_CHOICES[4][0] | ||
| 302 | +DPASTE_DEFAULT_GIST_DESCRIPTION = 'Gist created from Colab DPaste' | ||
| 303 | +DPASTE_DEFAULT_GIST_NAME = 'colab_paste' | ||
| 304 | +DPASTE_LEXER_DEFAULT = 'text' | ||
| 305 | + | ||
| 306 | +from .utils.conf import load_yaml_settings | ||
| 307 | +locals().update(load_yaml_settings()) | ||
| 308 | + | ||
| 309 | +if locals().get('RAVEN_DSN', False): | ||
| 310 | + RAVEN_CONFIG = { | ||
| 311 | + 'dsn': RAVEN_DSN + '?timeout=30', | ||
| 312 | + } | ||
| 313 | + INSTALLED_APPS += ('raven.contrib.django.raven_compat',) | ||
| 314 | + | ||
| 315 | +for app_label in locals().get('PROXIED_APPS', {}).keys(): | ||
| 316 | + INSTALLED_APPS += ('colab.proxy.{}'.format(app_label),) |
colab/super_archives/__init__.py
colab/super_archives/apps.py
| @@ -3,7 +3,7 @@ from django.apps import AppConfig | @@ -3,7 +3,7 @@ from django.apps import AppConfig | ||
| 3 | 3 | ||
| 4 | 4 | ||
| 5 | class SuperArchivesConfig(AppConfig): | 5 | class SuperArchivesConfig(AppConfig): |
| 6 | - name = 'super_archives' | 6 | + name = 'colab.super_archives' |
| 7 | verbose_name = 'Super Archives' | 7 | verbose_name = 'Super Archives' |
| 8 | 8 | ||
| 9 | def ready(self): | 9 | def ready(self): |
colab/super_archives/management/commands/import_emails.py
| @@ -12,14 +12,14 @@ from optparse import make_option | @@ -12,14 +12,14 @@ from optparse import make_option | ||
| 12 | 12 | ||
| 13 | from django.db import transaction | 13 | from django.db import transaction |
| 14 | from django.template.defaultfilters import slugify | 14 | from django.template.defaultfilters import slugify |
| 15 | -from super_archives.utils.email import colab_send_email | ||
| 16 | from django.core.management.base import BaseCommand, CommandError | 15 | from django.core.management.base import BaseCommand, CommandError |
| 17 | from django.template.loader import render_to_string | 16 | from django.template.loader import render_to_string |
| 18 | from django.utils.translation import ugettext as _ | 17 | from django.utils.translation import ugettext as _ |
| 19 | 18 | ||
| 20 | -from super_archives.models import MailingList, Message, \ | 19 | +from colab.super_archives.utils.email import colab_send_email |
| 20 | +from colab.super_archives.models import MailingList, Message, \ | ||
| 21 | Thread, EmailAddress | 21 | Thread, EmailAddress |
| 22 | -from super_archives.management.commands.message import Message as \ | 22 | +from colab.super_archives.management.commands.message import Message as \ |
| 23 | CustomMessage | 23 | CustomMessage |
| 24 | 24 | ||
| 25 | 25 |
colab/super_archives/management/commands/update_blocks.py
| 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
| 2 | 2 | ||
| 3 | from django.core.management.base import BaseCommand | 3 | from django.core.management.base import BaseCommand |
| 4 | -from super_archives.models import Message | 4 | +from colab.super_archives.models import Message |
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | class Command(BaseCommand): | 7 | class Command(BaseCommand): |
colab/super_archives/management/commands/update_keywords.py
| 1 | #!/usr/bin/env python | 1 | #!/usr/bin/env python |
| 2 | 2 | ||
| 3 | from django.core.management.base import BaseCommand, CommandError | 3 | from django.core.management.base import BaseCommand, CommandError |
| 4 | -from super_archives.models import Thread | 4 | +from colab.super_archives.models import Thread |
| 5 | 5 | ||
| 6 | 6 | ||
| 7 | class Command(BaseCommand): | 7 | class Command(BaseCommand): |
colab/super_archives/migrations/0001_initial.py
| @@ -3,7 +3,7 @@ from __future__ import unicode_literals | @@ -3,7 +3,7 @@ from __future__ import unicode_literals | ||
| 3 | 3 | ||
| 4 | from django.db import models, migrations | 4 | from django.db import models, migrations |
| 5 | import hitcounter.models | 5 | import hitcounter.models |
| 6 | -import super_archives.models | 6 | +import colab.super_archives.models |
| 7 | import django.db.models.deletion | 7 | import django.db.models.deletion |
| 8 | from django.conf import settings | 8 | from django.conf import settings |
| 9 | import taggit.managers | 9 | import taggit.managers |
| @@ -36,7 +36,7 @@ class Migration(migrations.Migration): | @@ -36,7 +36,7 @@ class Migration(migrations.Migration): | ||
| 36 | fields=[ | 36 | fields=[ |
| 37 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 37 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), |
| 38 | ('address', models.EmailField(unique=True, max_length=75)), | 38 | ('address', models.EmailField(unique=True, max_length=75)), |
| 39 | - ('validation_key', models.CharField(default=super_archives.models.get_validation_key, max_length=32, null=True)), | 39 | + ('validation_key', models.CharField(default=colab.super_archives.models.get_validation_key, max_length=32, null=True)), |
| 40 | ('created', models.DateTimeField(auto_now_add=True)), | 40 | ('created', models.DateTimeField(auto_now_add=True)), |
| 41 | ('user', models.ForeignKey(related_name=b'emails_not_validated', to=settings.AUTH_USER_MODEL, null=True)), | 41 | ('user', models.ForeignKey(related_name=b'emails_not_validated', to=settings.AUTH_USER_MODEL, null=True)), |
| 42 | ], | 42 | ], |
| @@ -74,7 +74,7 @@ class Migration(migrations.Migration): | @@ -74,7 +74,7 @@ class Migration(migrations.Migration): | ||
| 74 | name='MailingListMembership', | 74 | name='MailingListMembership', |
| 75 | fields=[ | 75 | fields=[ |
| 76 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 76 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), |
| 77 | - ('mailinglist', models.ForeignKey(to='super_archives.MailingList')), | 77 | + ('mailinglist', models.ForeignKey(to='colab.super_archives.MailingList')), |
| 78 | ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), | 78 | ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), |
| 79 | ], | 79 | ], |
| 80 | options={ | 80 | options={ |
| @@ -91,7 +91,7 @@ class Migration(migrations.Migration): | @@ -91,7 +91,7 @@ class Migration(migrations.Migration): | ||
| 91 | ('received_time', models.DateTimeField(db_index=True)), | 91 | ('received_time', models.DateTimeField(db_index=True)), |
| 92 | ('message_id', models.CharField(max_length=512)), | 92 | ('message_id', models.CharField(max_length=512)), |
| 93 | ('spam', models.BooleanField(default=False)), | 93 | ('spam', models.BooleanField(default=False)), |
| 94 | - ('from_address', models.ForeignKey(to='super_archives.EmailAddress')), | 94 | + ('from_address', models.ForeignKey(to='colab.super_archives.EmailAddress')), |
| 95 | ], | 95 | ], |
| 96 | options={ | 96 | options={ |
| 97 | 'ordering': ('received_time',), | 97 | 'ordering': ('received_time',), |
| @@ -107,7 +107,7 @@ class Migration(migrations.Migration): | @@ -107,7 +107,7 @@ class Migration(migrations.Migration): | ||
| 107 | ('text', models.TextField()), | 107 | ('text', models.TextField()), |
| 108 | ('is_reply', models.BooleanField(default=False)), | 108 | ('is_reply', models.BooleanField(default=False)), |
| 109 | ('order', models.IntegerField()), | 109 | ('order', models.IntegerField()), |
| 110 | - ('message', models.ForeignKey(related_name=b'blocks', to='super_archives.Message')), | 110 | + ('message', models.ForeignKey(related_name=b'blocks', to='colab.super_archives.Message')), |
| 111 | ], | 111 | ], |
| 112 | options={ | 112 | options={ |
| 113 | 'ordering': ('order',), | 113 | 'ordering': ('order',), |
| @@ -120,7 +120,7 @@ class Migration(migrations.Migration): | @@ -120,7 +120,7 @@ class Migration(migrations.Migration): | ||
| 120 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 120 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), |
| 121 | ('name', models.CharField(max_length=512)), | 121 | ('name', models.CharField(max_length=512)), |
| 122 | ('value', models.TextField()), | 122 | ('value', models.TextField()), |
| 123 | - ('Message', models.ForeignKey(to='super_archives.Message')), | 123 | + ('Message', models.ForeignKey(to='colab.super_archives.Message')), |
| 124 | ], | 124 | ], |
| 125 | options={ | 125 | options={ |
| 126 | }, | 126 | }, |
| @@ -133,8 +133,8 @@ class Migration(migrations.Migration): | @@ -133,8 +133,8 @@ class Migration(migrations.Migration): | ||
| 133 | ('subject_token', models.CharField(max_length=512)), | 133 | ('subject_token', models.CharField(max_length=512)), |
| 134 | ('score', models.IntegerField(default=0, help_text='Thread score', verbose_name='Score')), | 134 | ('score', models.IntegerField(default=0, help_text='Thread score', verbose_name='Score')), |
| 135 | ('spam', models.BooleanField(default=False)), | 135 | ('spam', models.BooleanField(default=False)), |
| 136 | - ('latest_message', models.OneToOneField(related_name=b'+', null=True, to='super_archives.Message', help_text='Latest message posted', verbose_name='Latest message')), | ||
| 137 | - ('mailinglist', models.ForeignKey(verbose_name='Mailing List', to='super_archives.MailingList', help_text='The Mailing List where is the thread')), | 136 | + ('latest_message', models.OneToOneField(related_name=b'+', null=True, to='colab.super_archives.Message', help_text='Latest message posted', verbose_name='Latest message')), |
| 137 | + ('mailinglist', models.ForeignKey(verbose_name='Mailing List', to='colab.super_archives.MailingList', help_text='The Mailing List where is the thread')), | ||
| 138 | ('tags', taggit.managers.TaggableManager(to='taggit.Tag', through='taggit.TaggedItem', help_text='A comma-separated list of tags.', verbose_name='Tags')), | 138 | ('tags', taggit.managers.TaggableManager(to='taggit.Tag', through='taggit.TaggedItem', help_text='A comma-separated list of tags.', verbose_name='Tags')), |
| 139 | ], | 139 | ], |
| 140 | options={ | 140 | options={ |
| @@ -149,7 +149,7 @@ class Migration(migrations.Migration): | @@ -149,7 +149,7 @@ class Migration(migrations.Migration): | ||
| 149 | fields=[ | 149 | fields=[ |
| 150 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), | 150 | ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), |
| 151 | ('created', models.DateTimeField(auto_now_add=True)), | 151 | ('created', models.DateTimeField(auto_now_add=True)), |
| 152 | - ('message', models.ForeignKey(to='super_archives.Message')), | 152 | + ('message', models.ForeignKey(to='colab.super_archives.Message')), |
| 153 | ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), | 153 | ('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)), |
| 154 | ], | 154 | ], |
| 155 | options={ | 155 | options={ |
| @@ -167,7 +167,7 @@ class Migration(migrations.Migration): | @@ -167,7 +167,7 @@ class Migration(migrations.Migration): | ||
| 167 | migrations.AddField( | 167 | migrations.AddField( |
| 168 | model_name='message', | 168 | model_name='message', |
| 169 | name='thread', | 169 | name='thread', |
| 170 | - field=models.ForeignKey(to='super_archives.Thread', null=True), | 170 | + field=models.ForeignKey(to='colab.super_archives.Thread', null=True), |
| 171 | preserve_default=True, | 171 | preserve_default=True, |
| 172 | ), | 172 | ), |
| 173 | migrations.AlterUniqueTogether( | 173 | migrations.AlterUniqueTogether( |
| @@ -177,7 +177,7 @@ class Migration(migrations.Migration): | @@ -177,7 +177,7 @@ class Migration(migrations.Migration): | ||
| 177 | migrations.AddField( | 177 | migrations.AddField( |
| 178 | model_name='keyword', | 178 | model_name='keyword', |
| 179 | name='thread', | 179 | name='thread', |
| 180 | - field=models.ForeignKey(to='super_archives.Thread'), | 180 | + field=models.ForeignKey(to='colab.super_archives.Thread'), |
| 181 | preserve_default=True, | 181 | preserve_default=True, |
| 182 | ), | 182 | ), |
| 183 | migrations.AlterUniqueTogether( | 183 | migrations.AlterUniqueTogether( |
colab/super_archives/search_indexes.py
colab/super_archives/templatetags/superarchives.py
| 1 | 1 | ||
| 2 | from django import template | 2 | from django import template |
| 3 | - | ||
| 4 | -from super_archives.utils import url | ||
| 5 | from django.conf import settings | 3 | from django.conf import settings |
| 6 | 4 | ||
| 5 | +from colab.super_archives.utils import url | ||
| 6 | + | ||
| 7 | 7 | ||
| 8 | register = template.Library() | 8 | register = template.Library() |
| 9 | TEMPLATE_PATH = 'superarchives/tags/' | 9 | TEMPLATE_PATH = 'superarchives/tags/' |
| @@ -32,4 +32,4 @@ def pop_from_get(context, **kwargs): | @@ -32,4 +32,4 @@ def pop_from_get(context, **kwargs): | ||
| 32 | context['request'].META['PATH_INFO'], | 32 | context['request'].META['PATH_INFO'], |
| 33 | context['request'].META['QUERY_STRING'], | 33 | context['request'].META['QUERY_STRING'], |
| 34 | **kwargs | 34 | **kwargs |
| 35 | - ) | ||
| 36 | \ No newline at end of file | 35 | \ No newline at end of file |
| 36 | + ) |
colab/super_archives/views.py
| @@ -20,7 +20,7 @@ from django.shortcuts import render, redirect, get_object_or_404 | @@ -20,7 +20,7 @@ from django.shortcuts import render, redirect, get_object_or_404 | ||
| 20 | 20 | ||
| 21 | from haystack.query import SearchQuerySet | 21 | from haystack.query import SearchQuerySet |
| 22 | 22 | ||
| 23 | -from accounts.utils import mailman | 23 | +from colab.accounts.utils import mailman |
| 24 | from .utils.email import send_verification_email | 24 | from .utils.email import send_verification_email |
| 25 | from .models import MailingList, Thread, EmailAddress, \ | 25 | from .models import MailingList, Thread, EmailAddress, \ |
| 26 | EmailAddressValidation, Message | 26 | EmailAddressValidation, Message |
| @@ -0,0 +1,46 @@ | @@ -0,0 +1,46 @@ | ||
| 1 | +from django.conf.urls import patterns, include, url, static | ||
| 2 | +from django.conf import settings | ||
| 3 | +from django.views.generic import TemplateView | ||
| 4 | +from django.contrib import admin | ||
| 5 | + | ||
| 6 | +from .accounts.models import User | ||
| 7 | +from .search.forms import ColabSearchForm | ||
| 8 | +from .super_archives.models import Message | ||
| 9 | + | ||
| 10 | + | ||
| 11 | +admin.autodiscover() | ||
| 12 | + | ||
| 13 | +urlpatterns = patterns('', | ||
| 14 | + url(r'^$', 'colab.home.views.index', name='home'), | ||
| 15 | + url(r'^robots.txt$', 'colab.home.views.robots', name='robots'), | ||
| 16 | + | ||
| 17 | + url(r'^open-data/$', TemplateView.as_view(template_name='open-data.html'), | ||
| 18 | + name='opendata'), | ||
| 19 | + | ||
| 20 | + url(r'^search/', include('colab.search.urls')), | ||
| 21 | + url(r'^archives/', include('colab.super_archives.urls')), | ||
| 22 | + url(r'^api/', include('colab.api.urls')), | ||
| 23 | + url(r'^rss/', include('colab.rss.urls')), | ||
| 24 | + | ||
| 25 | + url(r'^user/', include('colab.accounts.urls')), # Kept for backwards compatibility | ||
| 26 | + url(r'^signup/', include('colab.accounts.urls')), # (same here) TODO: move to nginx | ||
| 27 | + url(r'^account/', include('colab.accounts.urls')), | ||
| 28 | + | ||
| 29 | + url(r'', include('django_browserid.urls')), | ||
| 30 | + | ||
| 31 | + url(r'^planet/', include('feedzilla.urls')), | ||
| 32 | + | ||
| 33 | + url(r'paste/', include('dpaste.urls.dpaste')), | ||
| 34 | + | ||
| 35 | + # Uncomment the next line to enable the admin: | ||
| 36 | + url(r'^colab/admin/', include(admin.site.urls)), | ||
| 37 | + | ||
| 38 | + url(r'^trac/', include('colab.proxy.trac.urls')), | ||
| 39 | + url(r'^gitlab/', include('colab.proxy.gitlab.urls')), | ||
| 40 | +) | ||
| 41 | + | ||
| 42 | +if settings.DEBUG: | ||
| 43 | + urlpatterns += static.static( | ||
| 44 | + settings.MEDIA_URL, | ||
| 45 | + document_root=settings.MEDIA_ROOT | ||
| 46 | + ) |
| @@ -0,0 +1,32 @@ | @@ -0,0 +1,32 @@ | ||
| 1 | + | ||
| 2 | +import os | ||
| 3 | +import yaml | ||
| 4 | + | ||
| 5 | +from django.core.exceptions import ImproperlyConfigured | ||
| 6 | + | ||
| 7 | + | ||
| 8 | +class InaccessibleYAMLSettings(ImproperlyConfigured): | ||
| 9 | + """Settings YAML is Inaccessible. | ||
| 10 | + | ||
| 11 | + Check if the file exists and if you have read permissions.""" | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +def load_yaml_settings(): | ||
| 15 | + yaml_path = os.getenv('COLAB_SETTINGS', '/etc/colab.yaml') | ||
| 16 | + | ||
| 17 | + if not os.path.exists(yaml_path): | ||
| 18 | + msg = "The yaml file {} does not exist".format(yaml_path) | ||
| 19 | + raise InaccessibleYAMLSettings(msg) | ||
| 20 | + | ||
| 21 | + try: | ||
| 22 | + with open(yaml_path) as yaml_file: | ||
| 23 | + yaml_settings = yaml.load(yaml_file.read()) | ||
| 24 | + except IOError: | ||
| 25 | + msg = ('Could not open settings file {}. Please ' | ||
| 26 | + 'check if the file exists and if user ' | ||
| 27 | + 'has read rights.').format(yaml_path) | ||
| 28 | + raise InaccessibleYAMLSettings(msg) | ||
| 29 | + | ||
| 30 | + return yaml_settings | ||
| 31 | + | ||
| 32 | +yaml_settings = load_yaml_settings() |
| @@ -0,0 +1,38 @@ | @@ -0,0 +1,38 @@ | ||
| 1 | +from haystack.utils import Highlighter | ||
| 2 | +from django.conf import settings | ||
| 3 | +from django.utils.html import escape, strip_tags | ||
| 4 | + | ||
| 5 | + | ||
| 6 | +class ColabHighlighter(Highlighter): | ||
| 7 | + def highlight(self, text_block): | ||
| 8 | + self.text_block = escape(strip_tags(text_block)) | ||
| 9 | + highlight_locations = self.find_highlightable_words() | ||
| 10 | + start_offset, end_offset = self.find_window(highlight_locations) | ||
| 11 | + return self.render_html(highlight_locations, start_offset, end_offset) | ||
| 12 | + | ||
| 13 | + def find_window(self, highlight_locations): | ||
| 14 | + """Getting the HIGHLIGHT_NUM_CHARS_BEFORE_MATCH setting | ||
| 15 | + to find how many characters before the first word found should | ||
| 16 | + be removed from the window | ||
| 17 | + """ | ||
| 18 | + | ||
| 19 | + if len(self.text_block) <= self.max_length: | ||
| 20 | + return (0, self.max_length) | ||
| 21 | + | ||
| 22 | + num_chars_before = getattr( | ||
| 23 | + settings, | ||
| 24 | + 'HIGHLIGHT_NUM_CHARS_BEFORE_MATCH', | ||
| 25 | + 0 | ||
| 26 | + ) | ||
| 27 | + | ||
| 28 | + best_start, best_end = super(ColabHighlighter, self).find_window( | ||
| 29 | + highlight_locations | ||
| 30 | + ) | ||
| 31 | + if best_start <= num_chars_before: | ||
| 32 | + best_end -= best_start | ||
| 33 | + best_start = 0 | ||
| 34 | + else: | ||
| 35 | + best_start -= num_chars_before | ||
| 36 | + best_end -= num_chars_before | ||
| 37 | + | ||
| 38 | + return (best_start, best_end) |
| @@ -0,0 +1,14 @@ | @@ -0,0 +1,14 @@ | ||
| 1 | +""" | ||
| 2 | +WSGI config for colab project. | ||
| 3 | + | ||
| 4 | +It exposes the WSGI callable as a module-level variable named ``application``. | ||
| 5 | + | ||
| 6 | +For more information on this file, see | ||
| 7 | +https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/ | ||
| 8 | +""" | ||
| 9 | + | ||
| 10 | +import os | ||
| 11 | +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "colab.settings") | ||
| 12 | + | ||
| 13 | +from django.core.wsgi import get_wsgi_application | ||
| 14 | +application = get_wsgi_application() |
| @@ -0,0 +1,10 @@ | @@ -0,0 +1,10 @@ | ||
| 1 | +#!/usr/bin/env python | ||
| 2 | +import os | ||
| 3 | +import sys | ||
| 4 | + | ||
| 5 | +if __name__ == "__main__": | ||
| 6 | + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "colab.settings") | ||
| 7 | + | ||
| 8 | + from django.core.management import execute_from_command_line | ||
| 9 | + | ||
| 10 | + execute_from_command_line(sys.argv) |