Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into MNCH-1126-whatsapp-list-items-with-comma
  • Loading branch information
Buhle79 committed Feb 14, 2024
2 parents 383d4dc + d8e1a4e commit 3bd17b2
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 23 deletions.
36 changes: 33 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,48 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
<!--
## Unreleased
### Fixed
### Added
### Changed
-->
## v1.1.0
### Fixed
- Autofill for empty slug
- Fixed Web content preview in CMS
- Fixed related pages export
- Fixed API tests
- Fixed Redis caching issues

### Added
- Added support for SMS content
- Added support for USSD content
- Added support for a Footer in WhatsApp content
- Added support for List Messages in WhatsApp content
- Added error handling on WhatsApp template submission errors, and adds issue to sentry
- Added validation of variables used in WhatsApp template submission
- Added WhatsApp title check
- Added typing information for migration test
- Added CI checks for pending migrations


### Changed
- Moved slug uniqueness validation to the model validation/clean
- Empty slugs will auto-generate a unique slug, but if a duplicate slug is specified the user will get a validation error instead of their chosen slug getting overwritten with a unique one.
- Slug uniqueness is per-locale
- Test speedups. Tests now run in parallel by default, and there's a separate contentrepo/settings/test.py for test-specific settings.
- Tests no longer run in parallel by default, because the output is a little less clear and the speedup is negligible on some systems.
- Test speedups, and there's a separate contentrepo/settings/test.py for test-specific settings.
- WhatsApp example values no longer show on the default API view, and forms part of the fields returned when the parameter `whatsapp=true` is added to the api call
- Improved testing of Importer
- Made text fields non-nullable
- Converted API tests to pytest and added docstrings
- Updated release process in Readme.

### Deprecated
- Removed the old importer
- Removed the `Authorization` and `Authentication` WhatsApp template category

-->

## v1.1.0-dev.5
### Fixed
Expand Down Expand Up @@ -55,6 +84,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Refactored ContentPage import. Translation keys are now added as translation keys instead of as tags
- Improved testing for import and export


### Deprecated
- next_prompt on WhatsApp messages is deprecated, use buttons instead. Will be removed on the next major release

Expand Down
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,28 @@ This content repository allows easy content management via a headless CMS, using


## Releases
The current LTS release is: 1.0

[Semantic versioning](https://semver.org/) is in use in this project.
1. Feature releases
- Feature releases are a MAJOR.MINOR combination, eg. `1.2`
- Feature releases occur once every 3 months, but only if required. eg. If there were only patch releases in the last 3 months, no feature release will occur.
- The latest feature release will receive any security or bug fixes as patch releases
- Each feature release will have a separate git branch
1. Patch releases
- Patch releases are used to fix bugs and security issues
- They are released as soon as they are ready
1. LTS (Long-Term Support) Releases
- Every fourth release is an LTS release
- LTS releases are listed in the documentation
- LTS releases receive security patches
- LTS releases are supported for 5 feature releases, allowing for 15 months of support with a 3 month switchover time to the next LTS

1. Development releases
- Development have the `-dev.N` suffix
- They are used to test new code before an official release is made
- Development versions have the `-dev.N` suffix
- They are built off of the `main` git branch
- They are created with git tags, eg. `v1.2.0-dev.2`
- Development releases are created before releases, eg. `v1.2.0-dev.0` gets created before `v1.2.0`
1. Releases
- Releases have a semantic version number, eg. `1.2.0`
- Releases are created when the changes have passed QA
- They are built off of the `main` git branch
- They are created with git tags, eg. `v1.2.0`

### How to create a release

1. Check that `CHANGELOG.md` is up to date.
1. Update the version number in `pyproject.toml` to the version you want to release, eg. change `1.2.0-dev.0` to `1.2.0`
1. Either create a pull request with these changes, and have it reviewed, or post a diff in Slack and have it reviewed there. Then merge, or commit and push, the changes.
1. Tag these changes with the desired release, eg. `git tag v1.2.0`, and push the tag, eg. `git push --tags`
1. Update the version number in `pyproject.toml` to the next version number, eg. `1.2.1-dev.0`.
1. Commit and push that change.


## Setting up locally

Expand Down
2 changes: 2 additions & 0 deletions contentrepo/settings/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@
FB_BUSINESS_ID = "27121231234"

WHATSAPP_CREATE_TEMPLATES = False

STATICFILES_STORAGE = "django.contrib.staticfiles.storage.StaticFilesStorage"
35 changes: 35 additions & 0 deletions home/templates/wagtail_content_import/picker_buttons_base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{% if default_picker %}
<li class="actions import-container content-import">
<div class="dropdown dropup dropdown-button match-width">
<div class="content-import button button-longrunning dropdown-toggle">
<i class="icon icon-folder-open-inverse content-import docs-blue"></i>
Import web from doc
</div>
<div class="content-import dropdown-toggle icon icon-arrow-up"></div>
<ul>
<li>
<a href="#"
data-content-import-picker="{{ default_picker.name }}"
data-import-page-url="{% block default_import_page_url %}{% endblock %}"
{% block default_extra_attrs %}{% endblock %}
class="content-import button button-longrunning">
<i class="icon {{ default_picker.icon }} content-import docs-blue"></i>
Import from {{ default_picker.verbose_name }}
</a>
</li>
{% for picker in picker_options %}
<li>
<a href="#"
data-content-import-picker="{{ picker.name }}"
data-import-page-url="{% block import_page_url %}{% endblock %}"
{% block extra_attrs %}{% endblock %}
class="content-import button button-longrunning">
<i class="icon {{ picker.icon }} content-import docs-blue"></i>
Import from {{ picker.verbose_name }}
</a>
</li>
{% endfor %}
</ul>
</div>
</li>
{% endif %}
37 changes: 37 additions & 0 deletions home/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from pathlib import Path

import pytest
from bs4 import BeautifulSoup
from pytest_django.asserts import assertTemplateUsed
from wagtail import blocks

from home.content_import_export import import_content
Expand All @@ -28,6 +30,15 @@
from .utils import create_page


# use this to access the admin interface
@pytest.fixture()
def admin_client(client, django_user_model):
creds = {"username": "test", "password": "test"}
django_user_model.objects.create_superuser(**creds)
client.login(**creds)
return client


@pytest.fixture()
def uclient(client, django_user_model):
creds = {"username": "test", "password": "test"}
Expand Down Expand Up @@ -88,6 +99,32 @@ def create_test_data(self):
tags=["self_help"],
)

def test_import_button_text(self, admin_client):

page = ContentPage.objects.first()
page_id = page.id
url = f"/admin/pages/{page_id}/edit/"
response = admin_client.get(url)

assert response.status_code == 200
content_str = response.content.decode("utf-8")

# Use BeautifulSoup to parse the HTML content
soup = BeautifulSoup(content_str, "html.parser")

# confirm the correct template is rendered
assertTemplateUsed(response, "wagtail_content_import/picker_buttons_base.html")

# Find the div with the specified class
div_element = soup.find(
"div", class_="content-import button button-longrunning dropdown-toggle"
)

# Check if the text is present in the div's contents
assert div_element and "Import web from doc" in div_element.get_text(
strip=True
), "Text not found on the page."

def test_login_required(self, client):
"""
Users that aren't logged in shouldn't be allowed to access the API
Expand Down
4 changes: 2 additions & 2 deletions home/tests/test_content_import_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ def test_ContentPageIndex_required_fields(self, csv_impexp: ImportExport) -> Non
content = csv_impexp.export_content()
src, dst = csv_impexp.csvs2dicts(csv_bytes, content)

# the importer adds extra fields, so we fikter for the ones we want
# the importer adds extra fields, so we filter for the ones we want
allowed_keys = ["message", "slug", "parent", "web_title", "locale"]
dst = [{k: v for k, v in item.items() if k in allowed_keys} for item in dst]
src = [{k: v for k, v in item.items() if k in allowed_keys} for item in src]
Expand All @@ -909,7 +909,7 @@ def test_ContentPage_required_fields(self, csv_impexp: ImportExport) -> None:
content = csv_impexp.export_content()
src, dst = csv_impexp.csvs2dicts(csv_bytes, content)

# the importer adds extra fields, so we fikter for the ones we want
# the importer adds extra fields, so we filter for the ones we want
allowed_keys = ["message", "slug", "parent", "web_title", "locale"]
dst = [{k: v for k, v in item.items() if k in allowed_keys} for item in dst]
src = [{k: v for k, v in item.items() if k in allowed_keys} for item in src]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "contentrepo"
version = "1.1.0-dev.4"
version = "1.1.1-dev.0"
authors = [
{ name="Praekelt.org", email="[email protected]" },
]
Expand Down

0 comments on commit 3bd17b2

Please sign in to comment.