Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SEARCH] stocker l'index du moteur de recherche dans un bucket permanent #318

Merged
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
3 changes: 2 additions & 1 deletion clevercloud/python.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"managetasks": [
"migrate --no-input",
"collectstatic --no-input",
"compress --force"
"compress --force",
"rebuild_index --noinput"
]
}
}
27 changes: 15 additions & 12 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,6 @@
},
}

# Search Backend
HAYSTACK_CONNECTIONS = {
"default": {
"ENGINE": "haystack.backends.whoosh_backend.WhooshEngine",
"PATH": os.path.join(ROOT_DIR, "whoosh_index"),
},
}

# Environment, sets the type of env of the app (PROD, DEV…)
COMMU_ENVIRONMENT = os.getenv("COMMU_ENVIRONMENT", "PROD")
COMMU_PROTOCOL = "https"
Expand All @@ -247,7 +239,7 @@
AWS_S3_ACCESS_KEY_ID = os.getenv("CELLAR_ADDON_KEY_ID", "123")
AWS_S3_SECRET_ACCESS_KEY = os.getenv("CELLAR_ADDON_KEY_SECRET", "secret")
AWS_S3_ENDPOINT_URL = (
f"{os.getenv('CELLAR_ADDON_PROTOCOL', 'https')}://{os.getenv('CELLAR_ADDON_HOST', 'set-var-env.com/')}"
f"{os.getenv('CELLAR_ADDON_PROTOCOL', 'https')}://{os.getenv('CELLAR_ADDON_HOST', 'set-var-env.com')}"
)
AWS_STORAGE_BUCKET_NAME = os.getenv("S3_STORAGE_BUCKET_NAME", "set-bucket-name")
AWS_S3_STORAGE_BUCKET_REGION = os.getenv("S3_STORAGE_BUCKET_REGION", "fr")
Expand All @@ -259,18 +251,29 @@
MEDIA_ROOT = os.path.join(APPS_DIR, "media")

# See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url
MEDIA_URL = f"https://{AWS_S3_ENDPOINT_URL}/" # noqa
MEDIA_URL = f"{AWS_S3_ENDPOINT_URL}/" # noqa

DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"

# Search Backend
# ------------------------------------------------------------------------------
HAYSTACK_CONNECTIONS = {
"default": {
"ENGINE": "haystack.backends.whoosh_backend.WhooshEngine",
"PATH": f"{AWS_S3_ENDPOINT_URL}/whoosh_index",
},
}

# Forum - Machina settings
# ------------------------------------------------------------------------------
MACHINA_FORUM_NAME = "La Communauté"
FORUM_TOPICS_NUMBER_PER_PAGE = 10
FORUM_NUMBER_POSTS_PER_TOPIC = 5

# Forum
MACHINA_FORUM_IMAGE_WIDTH = 300
MACHINA_FORUM_IMAGE_HEIGHT = 300

# Inclusion Connect
# ------------------------------------------------------------------------------
INCLUSION_CONNECT_BASE_URL = os.getenv("INCLUSION_CONNECT_BASE_URL")
INCLUSION_CONNECT_REALM = os.getenv("INCLUSION_CONNECT_REALM")
INCLUSION_CONNECT_CLIENT_ID = os.getenv("INCLUSION_CONNECT_CLIENT_ID")
Expand Down
9 changes: 9 additions & 0 deletions config/settings/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@
"PASSWORD": os.getenv("POSTGRES_PASSWORD"),
}
}

# Search Backend
HAYSTACK_CONNECTIONS = {
"default": {
"ENGINE": "haystack.backends.whoosh_backend.WhooshEngine",
"PATH": os.path.join(ROOT_DIR, "whoosh_index"), # noqa F405
},
}

# Emails in Mailhog
# ------------------------------------------------------------------------------
EMAIL_HOST = "0.0.0.0"
Expand Down
68 changes: 25 additions & 43 deletions lacommunaute/templates/forum_search/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
{% load i18n %}
{% load highlight %}
{% load date_filters %}
{% load str_filters %}

{% block title %}{% trans "Search" %}{{ block.super }}{% endblock %}

Expand All @@ -11,53 +12,28 @@
<div class="s-title-01__container container">
<div class="s-title-01__row row">
<div class="s-title-01__col col-12">
{% if not query %}
<h1>{% trans "Search" %}</h1>
<h2 class="h3">{% trans "Search forums" %}</h2>
{% else %}
<h1>{% trans "Search" %} "{{ request.GET.q|safe }}"</h1>
<h2 class="h3">{% trans "Search forums" %}</h2>
<p class="lead">
{% blocktrans trimmed count number_of_results=page.paginator.count %}
Your search has returned <b>{{ number_of_results }}</b> result
{% plural %}
Your search has returned <b>{{ number_of_results }}</b> results
{% endblocktrans %}
</p>
{% endif %}
<h1>{% trans "Search forums" %}</h1>
</div>
</div>
</div>
</section>

<section class="s-section">
<div class="s-section__container container">
{% if not query %}
<div class="row">
<div class="col-12">
<div class="c-box">
<form method="get" action="." class="form">
<div class="form-row align-items-end">
<div class="col">
{% include "partials/form_field.html" with field=form.q %}
</div>
<div class="col-auto mb-3">
<button type="submit" class="btn btn-primary btn-ico">
<i class="ri-search-line"></i>
<span>{% trans "Search" %}</span>
</button>
</div>
</div>
</form>
</div>
<div class="row">
<div class="col-12">
<div class="c-box">
{% include "forum_search/search_form.html" %}
</div>
</div>
{% else %}
<div class="row">
</div>

{% if query %}
<div class="row mt-3">
<div class="col-12">
<div class="c-box">
{% if page.paginator.count %}
<h3 class="h4 mb-0">{% trans "Results" %}</h3>
<h3 class="h4 mb-0">{{ page.paginator.count }} {% trans "result" %}{{ page.paginator.count|pluralizefr }}</h3>
<div class="table-responsive-lg">
<table class="table table-hover mt-3 mt-md-4">
<caption class="sr-only">Liste de résultats</caption>
Expand All @@ -66,7 +42,13 @@ <h3 class="h4 mb-0">{% trans "Results" %}</h3>
{% if result.topic %}
<tr>
<td class="position-relative">
<a href="{% url 'forum_conversation:topic' result.forum_slug result.forum result.topic_slug result.topic %}" class="btn-link stretched-link">{{ result.topic_subject }}</a><br>
<a href="{% url 'forum_conversation:topic' result.forum_slug result.forum result.topic_slug result.topic %}"
class="btn-link stretched-link matomo-event"
data-matomo-category="engagement"
data-matomo-action="view"
data-matomo-option="topic"
>
{{ result.topic_subject }}</a><br>
<small class="text-muted">
{% spaceless %}
<i class="fas fa-clock"></i>&nbsp;
Expand All @@ -84,7 +66,13 @@ <h3 class="h4 mb-0">{% trans "Results" %}</h3>
{% else %}
<tr>
<td class="position-relative">
<a href="{% url 'forum_extension:forum' result.forum_slug result.forum %}" class="btn-link stretched-link">{{ result.forum_name }}</a><br>
<a href="{% url 'forum_extension:forum' result.forum_slug result.forum %}"
class="btn-link stretched-link matomo-event"
data-matomo-category="engagement"
data-matomo-action="view"
data-matomo-option="forum"
>
{{ result.forum_name }}</a><br>
<small class="text-muted">
{% spaceless %}
<i class="fas fa-clock"></i>&nbsp;
Expand All @@ -105,12 +93,6 @@ <h3 class="h4 mb-0">{% trans "Results" %}</h3>
{% else %}
<div class="d-flex flex-column flex-md-row align-items-md-center justify-content-md-between">
<h3 class="h4 mb-0">{% trans "No results." %}</h3>
<div class="flex-column flex-md-row btn-group btn-group-sm btn-group-action" role="group">
<a class="btn btn-primary btn-ico justify-content-center mt-3 mt-md-0" href="{% url 'forum_search_extension:search' %}">
<i class="ri-search-line"></i>
<span>{% trans "New search" %}</span>
</a>
</div>
</div>
{% endif %}
{% if page.has_previous or page.has_next %}
Expand Down
20 changes: 20 additions & 0 deletions lacommunaute/templates/forum_search/search_form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% load i18n %}

<form method="get" action="." class="form">
<div class="form-row align-items-end">
<div class="col">
{% include "partials/form_field.html" with field=form.q %}
</div>
<div class="col-auto mb-3">
<button type="submit"
class="btn btn-primary btn-ico matomo-event"
data-matomo-category="engagement"
data-matomo-action="search"
data-matomo-option="submit_query"
>
<i class="ri-search-line"></i>
<span>{% trans "Search" %}</span>
</button>
</div>
</div>
</form>
Binary file modified locale/fr/LC_MESSAGES/django.mo
Binary file not shown.
3 changes: 3 additions & 0 deletions locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,9 @@ msgstr[0] "Votre recherche a renvoyé <b>%(number_of_results)s</b> résultat"
msgstr[1] "Votre recherche a renvoyé <b>%(number_of_results)s</b> résultats"

#: lacommunaute/templates/machina/forum_search/search.html:70
msgid "result"
msgstr "résultat"

msgid "Results"
msgstr "Résultats"

Expand Down