Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Run tests
run: docker compose run --rm web bin/wait-for-deps.sh coverage run --source=nuntium,contactos,mailit,instance,mailreporter manage.py test nuntium contactos mailit instance mailreporter

- run: docker compose logs db elasticsearch
- run: docker compose logs db
if: ${{ always() }}

# Run codecov passing appropriate codecov.io CI environment variables to container
Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ FROM python:2.7

ENV PYTHONUNBUFFERED 1

RUN echo "deb http://archive.debian.org/debian buster main" > /etc/apt/sources.list \
&& echo "deb http://archive.debian.org/debian-security buster/updates main" >> /etc/apt/sources.list

COPY pkglist /tmp/
RUN apt-get update \
&& apt-get install -y $(cat /tmp/pkglist) \
&& apt-get install -y --no-install-recommends $(cat /tmp/pkglist) \
# cleaning up unused files
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
Expand Down
1 change: 0 additions & 1 deletion bin/wait-for-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ set -o errexit
set -o nounset

source $(dirname $0)/wait-for-postgres.sh
source $(dirname $0)/wait-for-elasticsearch.sh

exec "$@"
13 changes: 0 additions & 13 deletions bin/wait-for-elasticsearch.sh

This file was deleted.

22 changes: 3 additions & 19 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ services:

web:
build: .
user: root
volumes:
- .:/app
- web-attachments:/app/attachments
Expand All @@ -14,7 +15,6 @@ services:
command: bin/wait-for-deps.sh ./manage.py runserver 0.0.0.0:8000
depends_on:
- db
- elasticsearch
- rabbitmq
environment:
- CELERY_BROKER_URL=amqp://guest:guest@rabbitmq//
Expand All @@ -23,45 +23,39 @@ services:
- DJANGO_DEBUG_TOOLBAR
- DJANGO_SECRET_KEY=not-secret-in-dev
- DJANGO_TESTING
- ELASTICSEARCH_INDEX=writeinpublic
- ELASTICSEARCH_URL=http://elasticsearch:9200/
- EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
- SESSION_COOKIE_DOMAIN=127.0.0.1.nip.io

worker:
build: .
user: root
volumes:
- .:/app
- web-attachments:/app/attachments
command: bin/wait-for-deps.sh celery -A writeit worker
depends_on:
- db
- elasticsearch
- rabbitmq
environment:
- DATABASE_URL=postgresql://writeinpublic:devpassword@db/writeinpublic
- DJANGO_DEBUG=True
- DJANGO_SECRET_KEY=not-secret-in-dev
- ELASTICSEARCH_INDEX=writeinpublic
- ELASTICSEARCH_URL=http://elasticsearch:9200/
- EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend

beat:
build: .
user: root
volumes:
- .:/app
- beat-data:/var/celerybeat
command: bin/wait-for-deps.sh celery -A writeit beat --pidfile= -s /var/celerybeat/celerybeat-schedule
depends_on:
- db
- elasticsearch
- rabbitmq
environment:
- DATABASE_URL=postgresql://writeinpublic:devpassword@db/writeinpublic
- DJANGO_DEBUG=True
- DJANGO_SECRET_KEY=not-secret-in-dev
- ELASTICSEARCH_INDEX=writeinpublic
- ELASTICSEARCH_URL=http://elasticsearch:9200/
- EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend

db:
Expand All @@ -73,15 +67,6 @@ services:
volumes:
- db-data:/var/lib/postgresql/data

elasticsearch:
image: elasticsearch:1
volumes:
- elasticsearch-data:/usr/share/elasticsearch/data
environment:
- ES_MAX_MEM=1g
ports:
- 9200

rabbitmq:
image: rabbitmq:3.7.28-management
volumes:
Expand All @@ -96,6 +81,5 @@ volumes:
web-attachments:
web-coverage:
db-data:
elasticsearch-data:
rabbitmq-data:
beat-data:
11 changes: 0 additions & 11 deletions global_test_case.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import re

from django.test import TestCase
from unittest import skipUnless
from django.core.management import call_command
from tastypie.test import ResourceTestCase
from django.conf import settings
from django.contrib.sites.models import Site
Expand All @@ -13,7 +11,6 @@
from django.test import RequestFactory
from django.test.client import Client
import logging
from haystack.signals import BaseSignalProcessor

_LOCALS = threading.local()

Expand Down Expand Up @@ -150,11 +147,6 @@ class ResourceGlobalTestCase(WriteItTestCaseMixin, ResourceTestCase):
pass


@skipUnless(settings.LOCAL_ELASTICSEARCH, "No local elasticsearch")
class SearchIndexTestCase(GlobalTestCase):
def setUp(self):
super(SearchIndexTestCase, self).setUp()
call_command('rebuild_index', verbosity=0, interactive=False)

from djcelery.contrib.test_runner import CeleryTestSuiteRunner
from django_nose import NoseTestSuiteRunner
Expand All @@ -169,9 +161,6 @@ def run_tests(self, test_labels, extra_tests=None, **kwargs):
return super(WriteItTestRunner, self).run_tests(test_labels, extra_tests, **kwargs)


class CeleryTestingSignalProcessor(BaseSignalProcessor):
pass


from vcr import VCR

Expand Down
11 changes: 0 additions & 11 deletions nuntium/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from popolo.models import Person
from django.forms import ValidationError
from django.utils.translation import ugettext as _, ungettext, pgettext_lazy
from haystack.forms import SearchForm
from django.utils.html import format_html
from django.utils.encoding import force_text
from django.utils.safestring import mark_safe
Expand Down Expand Up @@ -193,16 +192,6 @@ class Meta:
fields = []


class MessageSearchForm(SearchForm):
pass


class PerInstanceSearchForm(SearchForm):
def __init__(self, *args, **kwargs):
self.writeitinstance = kwargs.pop('writeitinstance', None)
super(PerInstanceSearchForm, self).__init__(*args, **kwargs)
self.searchqueryset = self.searchqueryset.filter(writeitinstance=self.writeitinstance.id)


class PopitParsingFormMixin(object):
def get_scheme(self, hostname, scheme):
Expand Down
26 changes: 0 additions & 26 deletions nuntium/search_indexes.py

This file was deleted.

4 changes: 2 additions & 2 deletions nuntium/subdomain_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
MessageThreadsView,
MessagesFromPersonView,
MessagesPerPersonView,
PerInstanceSearchView,
per_instance_search,
WriteMessageView,
WriteSignView,
WriteItInstanceDetailView,
Expand Down Expand Up @@ -127,7 +127,7 @@
url(r'^from/(?P<message_slug>[-\w]+)/?$', MessagesFromPersonView.as_view(), name='all-messages-from-the-same-author-as'),
url(r'^to/(?P<pk>[-\d]+)/$', MessagesPerPersonView.as_view(), name='thread_to'),

url(r'^search/$', PerInstanceSearchView(), name='instance_search'),
url(r'^search/$', per_instance_search, name='instance_search'),
url(r'^attachment/(?P<pk>[-\d]+)/$', download_attachment_view, name='attachment'),
url(r'^manage/', include(managepatterns)),
url(r'^accounts/logout/$', 'django.contrib.auth.views.logout', kwargs={'next_page': '/'}, name='logout'),
Expand Down
27 changes: 11 additions & 16 deletions nuntium/templates/nuntium/instance_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,15 @@
{% load subdomainurls %}
{% block content %}
{% load markdown_deux_tags %}
<ul class="flash-messages">
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>

{% if query %}
<h3>{% trans 'Results' %}</h3>
{% for result in page.object_list %}
{% for result in page %}
<div class="search_result">
{% if result.model_name == 'message' %}
{% include 'nuntium/message/message_in_list.html' with message=result.object %}
{% endif %}
{% if result.model_name == 'answer' %}
{% include 'nuntium/answer/answer_in_list.html' with answer=result.object %}
{% if result.subject %}
{% include 'nuntium/message/message_in_list.html' with message=result %}
{% else %}
{% include 'nuntium/answer/answer_in_list.html' with answer=result %}
{% endif %}
</div>
{% empty %}
Expand All @@ -37,11 +32,11 @@ <h3>{% trans 'Results' %}</h3>
{% endblock content %}

{% block search_form %}
<form class="navbar-form navbar-right" method="get" role="form">
<form class="navbar-form navbar-right" method="get" role="form">
<div class="form-group">
<label class="sr-only" for="exampleInputEmail2">Search within messages</label>
<input type="text" class="form-control" name="q" id="id_q" placeholder="{% trans 'Search within messages' %}" value="{{ form.q.value }}">
<label class="sr-only" for="id_q">{% trans 'Search within messages' %}</label>
<input type="text" class="form-control" name="q" id="id_q" placeholder="{% trans 'Search within messages' %}" value="{{ query }}">
</div>
<button type="submit" class="btn btn-success" >{% trans 'Search' %}</button>
<button type="submit" class="btn btn-success">{% trans 'Search' %}</button>
</form>
{% endblock search_form%}
{% endblock search_form %}
27 changes: 8 additions & 19 deletions nuntium/templates/nuntium/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,24 @@
{% load subdomainurls %}
{% block content %}
{% load markdown_deux_tags %}
<ul class="flash-messages">
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>

<form method="get" >
<form method="get">
<table>
{{ form.as_table }}
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" value="{% trans 'Search' %}">
</td>
<td><input type="text" name="q" value="{{ query }}" /></td>
<td><input type="submit" value="{% trans 'Search' %}"></td>
</tr>
</table>
</form>



{% if query %}
<h3>{% trans 'Results' %}</h3>
{% for result in page.object_list %}
{% for result in page %}
<div class="search_result">
{% if result.model_name == 'message' %}
{% include 'nuntium/message/message_in_list.html' with message=result.object %}
{% endif %}
{% if result.model_name == 'answer' %}
{% include 'nuntium/answer/answer_in_list.html' with answer=result.object %}
{% if result.subject %}
{% include 'nuntium/message/message_in_list.html' with message=result %}
{% else %}
{% include 'nuntium/answer/answer_in_list.html' with answer=result %}
{% endif %}
</div>
{% empty %}
Expand Down
2 changes: 0 additions & 2 deletions nuntium/templates/search/indexes/nuntium/answer_text.txt

This file was deleted.

2 changes: 0 additions & 2 deletions nuntium/templates/search/indexes/nuntium/message_text.txt

This file was deleted.

Loading