Merge Request #83
← To merge requests
From
fix_master
into
master
Changing colab settings and auto settings for DB
Commits (24)
Showing
34 changed files
Show diff stats
.gitignore
.travis.yml
Vagrantfile
@@ -6,10 +6,10 @@ | @@ -6,10 +6,10 @@ | ||
6 | # - trusty64 | 6 | # - trusty64 |
7 | # - chef/centos-7.0 | 7 | # - chef/centos-7.0 |
8 | 8 | ||
9 | -default_box = "precise64" | 9 | +default_box = "trusty64" |
10 | if $stdin.isatty | 10 | if $stdin.isatty |
11 | if Dir.glob(File.join(File.dirname("__FILE__"), '.vagrant/**/id')).empty? | 11 | if Dir.glob(File.join(File.dirname("__FILE__"), '.vagrant/**/id')).empty? |
12 | - options = ["precise64", "trusty64", "chef/centos-7.0"] | 12 | + options = ["trusty64", "chef/centos-7.0"] |
13 | 13 | ||
14 | puts "Bases boxes available locally:" | 14 | puts "Bases boxes available locally:" |
15 | puts '------------------------------' | 15 | puts '------------------------------' |
colab/accounts/templates/accounts/user_detail.html
1 | {% extends "base.html" %} | 1 | {% extends "base.html" %} |
2 | 2 | ||
3 | -{% load i18n gravatar i18n_model %} | 3 | +{% load i18n gravatar %} |
4 | 4 | ||
5 | {% block title %}Perfil{% endblock %} | 5 | {% block title %}Perfil{% endblock %} |
6 | 6 | ||
@@ -126,25 +126,6 @@ | @@ -126,25 +126,6 @@ | ||
126 | </div> | 126 | </div> |
127 | </div> | 127 | </div> |
128 | 128 | ||
129 | - | ||
130 | - {% if user_.badge_set.exists %} | ||
131 | - <div class="col-lg-8 col-md-12 col-sm-7"> | ||
132 | - <div class="panel panel-default"> | ||
133 | - <div class="panel-heading"> | ||
134 | - <h3 class="panel-title">{% trans "Badges" %}</h3> | ||
135 | - </div> | ||
136 | - <div class="panel-body"> | ||
137 | - <div> | ||
138 | - {% for badge in user_.badge_set.all %} | ||
139 | - {% translate badge as badge_trans %} | ||
140 | - <img src="data:image/png;base64,{{ badge.image_base64 }}" title="({{ badge_trans.title }}) {{ badge_trans.description }}" /> | ||
141 | - {% endfor %} | ||
142 | - </div> | ||
143 | - </div> | ||
144 | - </div> | ||
145 | - </div> | ||
146 | - {% endif %} | ||
147 | - | ||
148 | </div> <!-- End of user-profile row --> | 129 | </div> <!-- End of user-profile row --> |
149 | 130 | ||
150 | <div class="row"> | 131 | <div class="row"> |
colab/management/initconfig.py
@@ -32,12 +32,17 @@ ALLOWED_HOSTS = [ | @@ -32,12 +32,17 @@ ALLOWED_HOSTS = [ | ||
32 | # SOCIAL_NETWORK_ENABLED = True | 32 | # SOCIAL_NETWORK_ENABLED = True |
33 | 33 | ||
34 | ## Database settings | 34 | ## Database settings |
35 | -DATABASES = {{ | ||
36 | - 'default': {{ | ||
37 | - 'ENGINE': 'django.db.backends.sqlite3', | ||
38 | - 'NAME': 'colab.sqlite3', | ||
39 | - }} | ||
40 | -}} | 35 | +## |
36 | +## When DEBUG is True colab will create the DB on | ||
37 | +## the repository root. In case of production settings | ||
38 | +## (DEBUG False) the DB settings must be set. | ||
39 | +## | ||
40 | +# DATABASES = {{ | ||
41 | +# 'default': {{ | ||
42 | +# 'ENGINE': 'django.db.backends.sqlite3', | ||
43 | +# 'NAME': '/path/to/colab.sqlite3', | ||
44 | +# }} | ||
45 | +# }} | ||
41 | 46 | ||
42 | ## Disable indexing | 47 | ## Disable indexing |
43 | ROBOTS_NOINDEX = False | 48 | ROBOTS_NOINDEX = False |
colab/settings.py
@@ -9,6 +9,7 @@ https://docs.djangoproject.com/en/1.7/ref/settings/ | @@ -9,6 +9,7 @@ https://docs.djangoproject.com/en/1.7/ref/settings/ | ||
9 | """ | 9 | """ |
10 | 10 | ||
11 | BROKER_URL = 'amqp://guest:guest@localhost:5672/' | 11 | BROKER_URL = 'amqp://guest:guest@localhost:5672/' |
12 | + | ||
12 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) | 13 | # Build paths inside the project like this: os.path.join(BASE_DIR, ...) |
13 | import os | 14 | import os |
14 | BASE_DIR = os.path.dirname(__file__) | 15 | BASE_DIR = os.path.dirname(__file__) |
@@ -43,10 +44,8 @@ INSTALLED_APPS = ( | @@ -43,10 +44,8 @@ INSTALLED_APPS = ( | ||
43 | 'colab.accounts', | 44 | 'colab.accounts', |
44 | 45 | ||
45 | # Not standard apps | 46 | # Not standard apps |
46 | - 'django_mobile', | ||
47 | 'haystack', | 47 | 'haystack', |
48 | 'hitcounter', | 48 | 'hitcounter', |
49 | - 'i18n_model', | ||
50 | 'taggit', | 49 | 'taggit', |
51 | 'djcelery', | 50 | 'djcelery', |
52 | 51 | ||
@@ -54,10 +53,10 @@ INSTALLED_APPS = ( | @@ -54,10 +53,10 @@ INSTALLED_APPS = ( | ||
54 | 'colab.home', | 53 | 'colab.home', |
55 | 'colab.plugins', | 54 | 'colab.plugins', |
56 | 'colab.super_archives', | 55 | 'colab.super_archives', |
57 | - 'colab.api', | ||
58 | 'colab.rss', | 56 | 'colab.rss', |
59 | 'colab.search', | 57 | 'colab.search', |
60 | 'colab.tz', | 58 | 'colab.tz', |
59 | + 'colab.utils', | ||
61 | ) | 60 | ) |
62 | 61 | ||
63 | ROOT_URLCONF = 'colab.urls' | 62 | ROOT_URLCONF = 'colab.urls' |
@@ -168,7 +167,15 @@ HAYSTACK_CUSTOM_HIGHLIGHTER = 'colab.utils.highlighting.ColabHighlighter' | @@ -168,7 +167,15 @@ HAYSTACK_CUSTOM_HIGHLIGHTER = 'colab.utils.highlighting.ColabHighlighter' | ||
168 | HAYSTACK_CONNECTIONS = { | 167 | HAYSTACK_CONNECTIONS = { |
169 | 'default': { | 168 | 'default': { |
170 | 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', | 169 | 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', |
171 | - 'PATH': os.path.join(os.path.dirname(__file__), 'whoosh_index'), | 170 | + 'PATH': os.path.join(BASE_DIR, 'whoosh_index'), |
171 | + } | ||
172 | +} | ||
173 | + | ||
174 | +DEFAULT_DATABASE = os.path.join(BASE_DIR, 'colab.sqlite3') | ||
175 | +DATABASES = { | ||
176 | + 'default': { | ||
177 | + 'ENGINE': 'django.db.backends.sqlite3', | ||
178 | + 'NAME': DEFAULT_DATABASE, | ||
172 | } | 179 | } |
173 | } | 180 | } |
174 | 181 | ||
@@ -183,7 +190,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( | @@ -183,7 +190,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( | ||
183 | 'django.core.context_processors.tz', | 190 | 'django.core.context_processors.tz', |
184 | 'django.contrib.messages.context_processors.messages', | 191 | 'django.contrib.messages.context_processors.messages', |
185 | 'django.core.context_processors.request', | 192 | 'django.core.context_processors.request', |
186 | - 'django_mobile.context_processors.is_mobile', | ||
187 | 'colab.super_archives.context_processors.mailarchive', | 193 | 'colab.super_archives.context_processors.mailarchive', |
188 | 'colab.plugins.context_processors.colab_apps', | 194 | 'colab.plugins.context_processors.colab_apps', |
189 | 'colab.home.context_processors.robots', | 195 | 'colab.home.context_processors.robots', |
@@ -200,8 +206,6 @@ MIDDLEWARE_CLASSES = ( | @@ -200,8 +206,6 @@ MIDDLEWARE_CLASSES = ( | ||
200 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | 206 | 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |
201 | 'django.contrib.messages.middleware.MessageMiddleware', | 207 | 'django.contrib.messages.middleware.MessageMiddleware', |
202 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', | 208 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', |
203 | - 'django_mobile.middleware.MobileDetectionMiddleware', | ||
204 | - 'django_mobile.middleware.SetFlavourMiddleware', | ||
205 | 'colab.tz.middleware.TimezoneMiddleware', | 209 | 'colab.tz.middleware.TimezoneMiddleware', |
206 | ) | 210 | ) |
207 | 211 | ||
@@ -245,12 +249,12 @@ REVPROXY_ADD_REMOTE_USER = True | @@ -245,12 +249,12 @@ REVPROXY_ADD_REMOTE_USER = True | ||
245 | # Tastypie settings | 249 | # Tastypie settings |
246 | TASTYPIE_DEFAULT_FORMATS = ['json', ] | 250 | TASTYPIE_DEFAULT_FORMATS = ['json', ] |
247 | 251 | ||
248 | -from .utils.conf import load_colab_apps, load_py_settings | 252 | +from .utils import conf |
249 | 253 | ||
250 | SOCIAL_NETWORK_ENABLED = locals().get('SOCIAL_NETWORK_ENABLED') or False | 254 | SOCIAL_NETWORK_ENABLED = locals().get('SOCIAL_NETWORK_ENABLED') or False |
251 | 255 | ||
252 | -locals().update(load_colab_apps()) | ||
253 | -locals().update(load_py_settings()) | 256 | +locals().update(conf.load_colab_apps()) |
257 | +locals().update(conf.load_py_settings()) | ||
254 | 258 | ||
255 | COLAB_APPS = locals().get('COLAB_APPS') or {} | 259 | COLAB_APPS = locals().get('COLAB_APPS') or {} |
256 | PROXIED_APPS = {} | 260 | PROXIED_APPS = {} |
@@ -290,3 +294,5 @@ STATICFILES_DIRS += [ | @@ -290,3 +294,5 @@ STATICFILES_DIRS += [ | ||
290 | TEMPLATE_DIRS += ( | 294 | TEMPLATE_DIRS += ( |
291 | os.path.join(BASE_DIR, 'templates'), | 295 | os.path.join(BASE_DIR, 'templates'), |
292 | ) | 296 | ) |
297 | + | ||
298 | +conf.validate_database(DATABASES, DEFAULT_DATABASE, DEBUG) |
colab/static/css/screen.css
@@ -275,88 +275,6 @@ ul.unstyled-list .glyphicon-chevron-right { | @@ -275,88 +275,6 @@ ul.unstyled-list .glyphicon-chevron-right { | ||
275 | border-color: #999; | 275 | border-color: #999; |
276 | } | 276 | } |
277 | 277 | ||
278 | -/* Converse JS */ | ||
279 | - | ||
280 | -#chatpanel form#converse-login { | ||
281 | - padding: 0; | ||
282 | -} | ||
283 | - | ||
284 | -#chatpanel form#converse-login input, | ||
285 | -#chatpanel form#converse-login label { | ||
286 | - margin: 2px 10px; | ||
287 | -} | ||
288 | - | ||
289 | -#chatpanel form#converse-login .login-submit{ | ||
290 | - margin-top: 10px; | ||
291 | -} | ||
292 | - | ||
293 | -#chatpanel a.configure-chatroom-button, | ||
294 | -#chatpanel a.close-chatbox-button { | ||
295 | - background-color: #F6F6F6; | ||
296 | - margin-right: 0.6em; | ||
297 | -} | ||
298 | - | ||
299 | -#chatpanel .chat-head #controlbox-tabs li { | ||
300 | - width:32%; | ||
301 | -} | ||
302 | - | ||
303 | -#chatpanel .oc-chat-head { | ||
304 | - height: 37px; | ||
305 | -} | ||
306 | - | ||
307 | -#chatpanel .chatbox dl.dropdown { | ||
308 | - margin-top: 0; | ||
309 | -} | ||
310 | - | ||
311 | -#chatpanel #converse-roster { | ||
312 | - height: 207px; | ||
313 | -} | ||
314 | - | ||
315 | -#chatpanel #toggle-controlbox { | ||
316 | - font-size: 100% !important; | ||
317 | - padding: 0 4px 26px !important; | ||
318 | -} | ||
319 | - | ||
320 | -#chatpanel { | ||
321 | - height: 342px !important; | ||
322 | -} | ||
323 | - | ||
324 | -#chatpanel div#controlbox-panes { | ||
325 | - width: auto; | ||
326 | -} | ||
327 | - | ||
328 | -#chatpanel .chat-head-chatbox, #chatpanel .chat-head-chatroom { | ||
329 | - height: 40.5px; | ||
330 | -} | ||
331 | - | ||
332 | -#chatpanel form.sendXMPPMessage { | ||
333 | - height: 76px; | ||
334 | - border: none; | ||
335 | -} | ||
336 | - | ||
337 | -#chatpanel form.sendXMPPMessage textarea { | ||
338 | - width: 189px; | ||
339 | - max-width: 285px; | ||
340 | - max-height: 66px; | ||
341 | -} | ||
342 | - | ||
343 | -#chatpanel .chatbox form.sendXMPPMessage textarea { | ||
344 | - max-width: 189px; | ||
345 | -} | ||
346 | - | ||
347 | -#chatpanel .chat-content, | ||
348 | -#chatpanel .chatroom .participants{ | ||
349 | - width: auto; | ||
350 | -} | ||
351 | - | ||
352 | -#chatpanel div#chatrooms { | ||
353 | - overflow-y: visible; | ||
354 | -} | ||
355 | - | ||
356 | - | ||
357 | -/* End of Converse JS*/ | ||
358 | - | ||
359 | - | ||
360 | /* user profile update */ | 278 | /* user profile update */ |
361 | 279 | ||
362 | .btn.delete-email:not(:hover) { | 280 | .btn.delete-email:not(:hover) { |
colab/super_archives/templates/message-thread.html
@@ -59,7 +59,7 @@ | @@ -59,7 +59,7 @@ | ||
59 | console.debug('trying to vote'); | 59 | console.debug('trying to vote'); |
60 | $btn.button('loading'); | 60 | $btn.button('loading'); |
61 | $ajax = $.ajax({ | 61 | $ajax = $.ajax({ |
62 | - url: "/api/message/" + msg_id + "/vote", | 62 | + url: "/archives/message/" + msg_id + "/vote", |
63 | type: method, | 63 | type: method, |
64 | context: $btn.get(0), | 64 | context: $btn.get(0), |
65 | beforeSend: function(xhr, settings) { | 65 | beforeSend: function(xhr, settings) { |
colab/super_archives/urls.py
1 | from django.conf.urls import patterns, url | 1 | from django.conf.urls import patterns, url |
2 | 2 | ||
3 | -from .views import EmailView, EmailValidationView, ThreadView | ||
4 | -from .views import ThreadDashboardView | 3 | +from .views import (EmailView, EmailValidationView, ThreadView, |
4 | + ThreadDashboardView, VoteView) | ||
5 | 5 | ||
6 | 6 | ||
7 | urlpatterns = patterns( | 7 | urlpatterns = patterns( |
@@ -13,4 +13,5 @@ urlpatterns = patterns( | @@ -13,4 +13,5 @@ urlpatterns = patterns( | ||
13 | name="archive_email_validation_view"), | 13 | name="archive_email_validation_view"), |
14 | url(r'manage/email/(?P<key>[0-9a-z]{32})?', EmailView.as_view(), | 14 | url(r'manage/email/(?P<key>[0-9a-z]{32})?', EmailView.as_view(), |
15 | name="archive_email_view"), | 15 | name="archive_email_view"), |
16 | + url(r'message/(?P<msg_id>\d+)/vote$', VoteView.as_view()), | ||
16 | ) | 17 | ) |
colab/super_archives/views.py
@@ -32,6 +32,8 @@ class ThreadView(View): | @@ -32,6 +32,8 @@ class ThreadView(View): | ||
32 | thread = get_object_or_404(Thread, subject_token=thread_token, | 32 | thread = get_object_or_404(Thread, subject_token=thread_token, |
33 | mailinglist__name=mailinglist) | 33 | mailinglist__name=mailinglist) |
34 | 34 | ||
35 | + # TODO: Refactor this code | ||
36 | + # Use local flag is_private instead of always check the API!! | ||
35 | all_privates = dict(mailman.all_lists(private=True)) | 37 | all_privates = dict(mailman.all_lists(private=True)) |
36 | if all_privates[thread.mailinglist.name]: | 38 | if all_privates[thread.mailinglist.name]: |
37 | if not request.user.is_authenticated(): | 39 | if not request.user.is_authenticated(): |
@@ -294,3 +296,40 @@ class EmailValidationView(View): | @@ -294,3 +296,40 @@ class EmailValidationView(View): | ||
294 | return http.HttpResponseServerError() | 296 | return http.HttpResponseServerError() |
295 | 297 | ||
296 | return http.HttpResponse(status=204) | 298 | return http.HttpResponse(status=204) |
299 | + | ||
300 | + | ||
301 | +class VoteView(View): | ||
302 | + | ||
303 | + http_method_names = [u'get', u'put', u'delete', u'head'] | ||
304 | + | ||
305 | + def put(self, request, msg_id): | ||
306 | + if not request.user.is_authenticated(): | ||
307 | + return http.HttpResponseForbidden() | ||
308 | + | ||
309 | + try: | ||
310 | + Message.objects.get(id=msg_id).vote(request.user) | ||
311 | + except IntegrityError: | ||
312 | + # 409 Conflict | ||
313 | + # used for duplicated entries | ||
314 | + return http.HttpResponse(status=409) | ||
315 | + | ||
316 | + # 201 Created | ||
317 | + return http.HttpResponse(status=201) | ||
318 | + | ||
319 | + def get(self, request, msg_id): | ||
320 | + votes = Message.objects.get(id=msg_id).votes_count() | ||
321 | + return http.HttpResponse(votes, content_type='application/json') | ||
322 | + | ||
323 | + def delete(self, request, msg_id): | ||
324 | + if not request.user.is_authenticated(): | ||
325 | + return http.HttpResponseForbidden() | ||
326 | + | ||
327 | + try: | ||
328 | + Message.objects.get(id=msg_id).unvote(request.user) | ||
329 | + except ObjectDoesNotExist: | ||
330 | + return http.HttpResponseGone() | ||
331 | + | ||
332 | + # 204 No Content | ||
333 | + # empty body, as per RFC2616. | ||
334 | + # object deleted | ||
335 | + return http.HttpResponse(status=204) |
colab/templates/footer.html
@@ -6,7 +6,6 @@ | @@ -6,7 +6,6 @@ | ||
6 | <p class="col-lg-12 text-center">{% trans "Last email imported at" %} {{ last_imported_message.received_time|date:'DATETIME_FORMAT' }}</p> | 6 | <p class="col-lg-12 text-center">{% trans "Last email imported at" %} {{ last_imported_message.received_time|date:'DATETIME_FORMAT' }}</p> |
7 | {% endif %} | 7 | {% endif %} |
8 | <p class="col-lg-12 text-center"> | 8 | <p class="col-lg-12 text-center"> |
9 | - <a href="{% url 'opendata' %}"><img src="{% static 'img/opendata3.png' %}"/></a> | ||
10 | <a href="http://creativecommons.org/licenses/by-sa/4.0/deed.pt_BR"><img src="{% static 'img/cc_by_sa.png' %}"/></a> | 9 | <a href="http://creativecommons.org/licenses/by-sa/4.0/deed.pt_BR"><img src="{% static 'img/cc_by_sa.png' %}"/></a> |
11 | </p> | 10 | </p> |
12 | <p class="col-lg-12 text-center"> | 11 | <p class="col-lg-12 text-center"> |
colab/urls.py
@@ -8,31 +8,19 @@ from django.views.generic import RedirectView | @@ -8,31 +8,19 @@ from django.views.generic import RedirectView | ||
8 | admin.autodiscover() | 8 | admin.autodiscover() |
9 | 9 | ||
10 | urlpatterns = patterns('', | 10 | urlpatterns = patterns('', |
11 | + url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'), | ||
11 | url(r'^robots.txt$', 'colab.home.views.robots', name='robots'), | 12 | url(r'^robots.txt$', 'colab.home.views.robots', name='robots'), |
12 | url(r'^dashboard$', 'colab.home.views.dashboard', name='dashboard'), | 13 | url(r'^dashboard$', 'colab.home.views.dashboard', name='dashboard'), |
13 | - url(r'^$', RedirectView.as_view(url=settings.COLAB_HOME_URL), name='home'), | ||
14 | - | ||
15 | - url(r'^open-data/$', TemplateView.as_view(template_name='open-data.html'), | ||
16 | - name='opendata'), | ||
17 | - | ||
18 | url(r'^search/', include('colab.search.urls')), | 14 | url(r'^search/', include('colab.search.urls')), |
19 | - url(r'^archives/', include('colab.super_archives.urls')), | ||
20 | - url(r'^api/', include('colab.api.urls')), | ||
21 | url(r'^rss/', include('colab.rss.urls')), | 15 | url(r'^rss/', include('colab.rss.urls')), |
22 | 16 | ||
23 | - # Kept for backwards compatibility | ||
24 | - url(r'^user/', include('colab.accounts.urls')), | ||
25 | - # Kept for backwards compatibility | ||
26 | - url(r'^user/', include('colab.accounts.urls')), | ||
27 | - # (same here) TODO: move to nginx | ||
28 | - url(r'^signup/', include('colab.accounts.urls')), | ||
29 | url(r'^account/', include('colab.accounts.urls')), | 17 | url(r'^account/', include('colab.accounts.urls')), |
30 | url(r'^myaccount/(?P<route>.*)$', | 18 | url(r'^myaccount/(?P<route>.*)$', |
31 | 'colab.accounts.views.myaccount_redirect', name='myaccount'), | 19 | 'colab.accounts.views.myaccount_redirect', name='myaccount'), |
32 | 20 | ||
33 | - # Uncomment the next line to enable the admin: | ||
34 | url(r'^colab/admin/', include(admin.site.urls)), | 21 | url(r'^colab/admin/', include(admin.site.urls)), |
35 | 22 | ||
23 | + url(r'^archives/', include('colab.super_archives.urls')), | ||
36 | url(r'^gitlab/', include('colab.plugins.gitlab.urls')), | 24 | url(r'^gitlab/', include('colab.plugins.gitlab.urls')), |
37 | url(r'^mezuro/', include('colab.plugins.mezuro.urls')), | 25 | url(r'^mezuro/', include('colab.plugins.mezuro.urls')), |
38 | url(r'^social/', include('colab.plugins.noosfero.urls')), | 26 | url(r'^social/', include('colab.plugins.noosfero.urls')), |
colab/utils/conf.py
@@ -13,6 +13,14 @@ class InaccessibleSettings(ImproperlyConfigured): | @@ -13,6 +13,14 @@ class InaccessibleSettings(ImproperlyConfigured): | ||
13 | Check if the file exists and if you have read permissions.""" | 13 | Check if the file exists and if you have read permissions.""" |
14 | 14 | ||
15 | 15 | ||
16 | +class DatabaseUndefined(ImproperlyConfigured): | ||
17 | + """Default database is not set. | ||
18 | + | ||
19 | + When DEBUG is set to True a local sqlite database can be used for | ||
20 | + developement porposes but otherwise the `default` database must | ||
21 | + be set.""" | ||
22 | + | ||
23 | + | ||
16 | def _load_py_file(py_path, path): | 24 | def _load_py_file(py_path, path): |
17 | original_path = sys.path | 25 | original_path = sys.path |
18 | 26 | ||
@@ -94,3 +102,11 @@ def load_colab_apps(): | @@ -94,3 +102,11 @@ def load_colab_apps(): | ||
94 | COLAB_APPS[app_name][key] = value | 102 | COLAB_APPS[app_name][key] = value |
95 | 103 | ||
96 | return {'COLAB_APPS': COLAB_APPS} | 104 | return {'COLAB_APPS': COLAB_APPS} |
105 | + | ||
106 | + | ||
107 | +def validate_database(database_dict, default_db, debug): | ||
108 | + db_name = database_dict.get('default', {}).get('NAME') | ||
109 | + if not debug and db_name == default_db: | ||
110 | + msg = ('Since DEBUG is set to False DATABASE must be set on ' | ||
111 | + 'Colab settings') | ||
112 | + raise DatabaseUndefined(msg) |
@@ -0,0 +1,18 @@ | @@ -0,0 +1,18 @@ | ||
1 | + | ||
2 | +from django.test import TestCase, override_settings | ||
3 | +from django.conf import settings | ||
4 | + | ||
5 | +from ..conf import DatabaseUndefined, validate_database | ||
6 | + | ||
7 | + | ||
8 | +class TestConf(TestCase): | ||
9 | + | ||
10 | + @override_settings(DEBUG=False, DATABASES={ | ||
11 | + 'default': { | ||
12 | + 'NAME': settings.DEFAULT_DATABASE, | ||
13 | + }, | ||
14 | + }) | ||
15 | + def test_database_undefined(self): | ||
16 | + with self.assertRaises(DatabaseUndefined): | ||
17 | + validate_database(settings.DATABASES, settings.DEFAULT_DATABASE, | ||
18 | + settings.DEBUG) |
misc/etc/cron.d/colab
@@ -2,14 +2,8 @@ | @@ -2,14 +2,8 @@ | ||
2 | 2 | ||
3 | 34 2 * * * colab colab-admin rebuild_index --noinput &> /dev/null | 3 | 34 2 * * * colab colab-admin rebuild_index --noinput &> /dev/null |
4 | 4 | ||
5 | -0 * * * * colab colab-admin cleanup_snippets &> /dev/null | ||
6 | - | ||
7 | -*/5 * * * * colab colab-admin update_badges &> /dev/null | ||
8 | - | ||
9 | * * * * * colab colab-admin import_proxy_data &> /dev/null | 5 | * * * * * colab colab-admin import_proxy_data &> /dev/null |
10 | 6 | ||
11 | 27 3 * * * colab colab-admin clearsessions &> /dev/null | 7 | 27 3 * * * colab colab-admin clearsessions &> /dev/null |
12 | 8 | ||
13 | -10 * * * * colab colab-admin update_planet &> /dev/null | ||
14 | - | ||
15 | * * * * * colab colab-admin import_emails &> /dev/null | 9 | * * * * * colab colab-admin import_emails &> /dev/null |
setup.py
@@ -3,26 +3,23 @@ from setuptools import setup, find_packages | @@ -3,26 +3,23 @@ from setuptools import setup, find_packages | ||
3 | 3 | ||
4 | 4 | ||
5 | REQUIREMENTS = [ | 5 | REQUIREMENTS = [ |
6 | - 'Django>=1.7.8,<1.8', | 6 | + 'Django>=1.7.9,<1.8', |
7 | 'pytz>=2011n', | 7 | 'pytz>=2011n', |
8 | 'django-hitcounter>=0.1.1', | 8 | 'django-hitcounter>=0.1.1', |
9 | - 'django-tastypie>=0.12.1', | ||
10 | - 'django-revproxy>=0.9.3', | 9 | + |
10 | + # Search | ||
11 | 'django-haystack>=2.2', | 11 | 'django-haystack>=2.2', |
12 | 'Whoosh>=2.7.0', | 12 | 'Whoosh>=2.7.0', |
13 | 13 | ||
14 | - # Diazo | 14 | + # revproxy |
15 | + 'django-revproxy>=0.9.3', | ||
15 | 'diazo>=1.0.5', | 16 | 'diazo>=1.0.5', |
16 | 17 | ||
17 | - # Celery | 18 | + # Async Signals |
18 | 'django-celery==3.1.16', | 19 | 'django-celery==3.1.16', |
19 | 20 | ||
20 | ### Move out of colab (as plugins): | 21 | ### Move out of colab (as plugins): |
21 | 22 | ||
22 | - # Deps for badger | ||
23 | - 'Pillow==2.8.1', | ||
24 | - 'django-i18n-model>=0.0.7', | ||
25 | - | ||
26 | # Deps for super_archives | 23 | # Deps for super_archives |
27 | 'etiquetando==0.1', | 24 | 'etiquetando==0.1', |
28 | 'django-taggit>=0.12.1', | 25 | 'django-taggit>=0.12.1', |
@@ -32,10 +29,6 @@ REQUIREMENTS = [ | @@ -32,10 +29,6 @@ REQUIREMENTS = [ | ||
32 | # Deps for gitlab plugin | 29 | # Deps for gitlab plugin |
33 | 'python-dateutil>=1.5', | 30 | 'python-dateutil>=1.5', |
34 | 'requests', | 31 | 'requests', |
35 | - | ||
36 | - # Converse.js (XMPP client) | ||
37 | - 'django-conversejs>=0.3.4', | ||
38 | - 'django-mobile>=0.3.0', | ||
39 | ] | 32 | ] |
40 | 33 | ||
41 | TEST_REQUIREMENTS = [ | 34 | TEST_REQUIREMENTS = [ |
tests/colab_settings.py
1 | 1 | ||
2 | ## Set to false in production | 2 | ## Set to false in production |
3 | -DEBUG = False | 3 | +DEBUG = True |
4 | TEMPLATE_DEBUG = False | 4 | TEMPLATE_DEBUG = False |
5 | 5 | ||
6 | ## System admins | 6 | ## System admins |
@@ -25,15 +25,7 @@ ALLOWED_HOSTS = [ | @@ -25,15 +25,7 @@ ALLOWED_HOSTS = [ | ||
25 | ] | 25 | ] |
26 | 26 | ||
27 | ### Uncomment to enable social networks fields profile | 27 | ### Uncomment to enable social networks fields profile |
28 | -# SOCIAL_NETWORK_ENABLED = True | ||
29 | - | ||
30 | -## Database settings | ||
31 | -DATABASES = { | ||
32 | - 'default': { | ||
33 | - 'ENGINE': 'django.db.backends.sqlite3', | ||
34 | - 'NAME': 'colab.sqlite3', | ||
35 | - } | ||
36 | -} | 28 | +SOCIAL_NETWORK_ENABLED = True |
37 | 29 | ||
38 | ## Disable indexing | 30 | ## Disable indexing |
39 | ROBOTS_NOINDEX = True | 31 | ROBOTS_NOINDEX = True |
@@ -59,3 +51,5 @@ LOGGING = { | @@ -59,3 +51,5 @@ LOGGING = { | ||
59 | }, | 51 | }, |
60 | }, | 52 | }, |
61 | } | 53 | } |
54 | + | ||
55 | +STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.StaticFilesStorage' |
tests/run.py
@@ -3,7 +3,7 @@ | @@ -3,7 +3,7 @@ | ||
3 | import os | 3 | import os |
4 | import sys | 4 | import sys |
5 | 5 | ||
6 | -os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings' | 6 | +os.environ['DJANGO_SETTINGS_MODULE'] = 'colab.settings' |
7 | os.environ['COLAB_SETTINGS'] = 'tests/colab_settings.py' | 7 | os.environ['COLAB_SETTINGS'] = 'tests/colab_settings.py' |
8 | os.environ['COLAB_PLUGINS'] = 'tests/plugins.d' | 8 | os.environ['COLAB_PLUGINS'] = 'tests/plugins.d' |
9 | os.environ['COVERAGE_PROCESS_START'] = '.coveragerc' | 9 | os.environ['COVERAGE_PROCESS_START'] = '.coveragerc' |
vagrant/centos.sh
@@ -15,53 +15,16 @@ if [ -n "$http_proxy" ]; then | @@ -15,53 +15,16 @@ if [ -n "$http_proxy" ]; then | ||
15 | fi | 15 | fi |
16 | fi | 16 | fi |
17 | 17 | ||
18 | -### Install dependencies | ||
19 | - | ||
20 | -yum -y groupinstall "Development tools" | ||
21 | - | ||
22 | -yum install -y git unzip mercurial libev-devel gettext libxml2-devel libxslt-devel openssl-devel libffi-devel libjpeg-turbo-devel zlib-devel freetype-devel postgresql-devel python-devel postgresql-server java epel-release | ||
23 | 18 | ||
24 | -### Install Rabbitmq | ||
25 | -yum install -y rabbitmq-server | ||
26 | -systemctl start rabbitmq-server | ||
27 | - | ||
28 | -### Install Virtualenvwrapper | ||
29 | -which pip2.7 > /dev/null || | ||
30 | - curl -s -L https://raw.githubusercontent.com/pypa/pip/1.5.6/contrib/get-pip.py | | ||
31 | - python2.7 | ||
32 | - | ||
33 | -if [ ! -f /etc/profile.d/virtualenvwrapper.sh ] | ||
34 | -then | ||
35 | - pip install virtualenvwrapper | ||
36 | - cat > "/etc/profile.d/virtualenvwrapper.sh" <<EOF | ||
37 | -export VIRTUALENVWRAPPER_PYTHON="/usr/bin/python2.7" | ||
38 | -source /usr/bin/virtualenvwrapper.sh | ||
39 | -EOF | ||
40 | -fi | ||
41 | - | ||
42 | -### Create conf directory | ||
43 | -mkdir -p /etc/colab | ||
44 | -chown vagrant:vagrant /etc/colab | ||
45 | - | ||
46 | - | ||
47 | -## Configuring postgres | ||
48 | -if [ ! -f /var/lib/pgsql/data/pg_hba.conf.bkp ]; then | ||
49 | - service postgresql initdb | ||
50 | - cp /var/lib/pgsql/data/pg_hba.conf /var/lib/pgsql/data/pg_hba.conf.bkp | ||
51 | - echo "local all all ident" > /var/lib/pgsql/data/pg_hba.conf | ||
52 | - echo "host all all 127.0.0.1/32 md5" >> /var/lib/pgsql/data/pg_hba.conf | ||
53 | - echo "host all all ::1/128 md5" >> /var/lib/pgsql/data/pg_hba.conf | ||
54 | - service postgresql restart | ||
55 | -fi | 19 | +### Install dependencies |
56 | 20 | ||
21 | +yum install -y epel-release | ||
57 | 22 | ||
58 | -### Create colab user in PostgreSQL | ||
59 | -echo "CREATE USER colab WITH PASSWORD 'colab';" | sudo -u postgres -i psql 2> /dev/null || echo | ||
60 | -echo "ALTER USER colab CREATEDB;" | sudo -u postgres -i psql 2> /dev/null | 23 | +yum -y groupinstall "Development tools" |
61 | 24 | ||
62 | -### Create colab DB in PostgreSQL | ||
63 | -sudo -u postgres -i createdb --owner=colab colab 2> /dev/null | echo | 25 | +yum install -y git unzip gettext libxml2-devel libxslt-devel openssl-devel libffi-devel python-devel python-pip python-virtualenvwrapper rabbitmq-server |
64 | 26 | ||
65 | -### Forcing postgresql to start at boot | ||
66 | -sudo chkconfig postgresql on | ||
67 | 27 | ||
28 | +### Init Rabbitmq | ||
29 | +chkconfig rabbitmq-server on | ||
30 | +systemctl start rabbitmq-server |
vagrant/provision.sh
@@ -31,6 +31,10 @@ for dir in /vagrant/colab /vagrant; do | @@ -31,6 +31,10 @@ for dir in /vagrant/colab /vagrant; do | ||
31 | done | 31 | done |
32 | pip install -e $basedir | 32 | pip install -e $basedir |
33 | 33 | ||
34 | +### Create conf directory | ||
35 | +sudo mkdir -p /etc/colab | ||
36 | +sudo chown vagrant:vagrant /etc/colab | ||
37 | + | ||
34 | if [ ! -s /etc/colab/settings.py ]; then | 38 | if [ ! -s /etc/colab/settings.py ]; then |
35 | colab-init-config > /etc/colab/settings.py | 39 | colab-init-config > /etc/colab/settings.py |
36 | fi | 40 | fi |
@@ -41,4 +45,4 @@ colab-admin loaddata /vagrant/tests/test_data.json | @@ -41,4 +45,4 @@ colab-admin loaddata /vagrant/tests/test_data.json | ||
41 | # Init.d Celery files | 45 | # Init.d Celery files |
42 | sudo cp $basedir/vagrant/misc/etc/init.d/celeryd /etc/init.d/ | 46 | sudo cp $basedir/vagrant/misc/etc/init.d/celeryd /etc/init.d/ |
43 | sudo cp $basedir/vagrant/misc/etc/default/celeryd /etc/default/ | 47 | sudo cp $basedir/vagrant/misc/etc/default/celeryd /etc/default/ |
44 | -sudo systemctl start celeryd | 48 | +sudo service celeryd start |
vagrant/ubuntu.sh
@@ -5,16 +5,4 @@ set -ex | @@ -5,16 +5,4 @@ set -ex | ||
5 | ### Install dependencies | 5 | ### Install dependencies |
6 | apt-get update | 6 | apt-get update |
7 | 7 | ||
8 | -apt-get install curl git unzip mercurial build-essential libev-dev gettext libxml2-dev libxslt1-dev libssl-dev libffi-dev libjpeg-dev zlib1g-dev libfreetype6-dev libpq-dev python-dev postgresql virtualenvwrapper python-pip java-common -y | ||
9 | - | ||
10 | - | ||
11 | -### Create conf directory | ||
12 | -mkdir -p /etc/colab | ||
13 | -chown vagrant:vagrant /etc/colab | ||
14 | - | ||
15 | -### Create colab user in PostgreSQL | ||
16 | -echo "CREATE USER colab WITH PASSWORD 'colab';" | sudo -u postgres -i psql 2> /dev/null || echo | ||
17 | -echo "ALTER USER colab CREATEDB;" | sudo -u postgres -i psql 2> /dev/null | ||
18 | - | ||
19 | -#i## Create colab DB in PostgreSQL | ||
20 | -sudo -u postgres -i createdb --owner=colab colab 2> /dev/null | echo | 8 | +apt-get install curl git unzip build-essential gettext libxml2-dev libxslt1-dev libssl-dev libffi-dev python-dev virtualenvwrapper python-pip rabbitmq-server -y |
-
Added 19 new commits:
- 83ef0de7 - Set colab_settings for tests
- c72f8481 - Fixed pep8
- f1e92a83 - Fixed Gitlab tests
- 5498660e - Removing old deps from badger
- a2965d3c - remove legacy converse.js stuff
- 121feb9a - Removed i18n_model (no longer needed)
- 6c3931c0 - Reorganized deps on setup.py
- ef767871 - Removed django-mobile
- e373e29d - Readded tastypie
- f83576eb - Removed open-data api
- 87c02305 - Removed old TODO file
- 9c0fc2b4 - Moved voting to super_archives
- 70e66881 - Refactored vagrant install scripts
- f1daeea2 - Ignore whoosh_index
- aaaff48e - Added TODO
- 2f9c5931 - Added missing slash
- 6cb1ec46 - Removed old cron jobs left behind
- 60d43389 - Removed tastypie dep
- 9c651342 - Merge branch 'cleanup-old-deps' into fix_master