Skip to content

Commit

Permalink
Collected paradigm generation code and relabelling out of frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
fbanados committed Oct 21, 2024
1 parent 7f94b0c commit 4cf8f96
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion frontend/js/paradigm.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function setupParadigmSizeToggleButton(currentParadigmSize) {
displayButtonAsLoading(toggleButton);

fetch(
window.Urls["cree-dictionary-paradigm-detail"]() +
window.Urls["morphodict-paradigm-detail"]() +
`?lemma-id=${lemmaId}&paradigm-size=${nextParadigmSize}`
)
.then((r) => {
Expand Down
4 changes: 2 additions & 2 deletions src/morphodict/frontend/templates/morphodict/word-detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ <h1 id="head" class="definition-title">

<section id="paradigm">
{% if paradigm %}
{% include './components/paradigm-label-switcher.html' %}
{% include './components/paradigm.html' %}
{% include 'morphodict/components/paradigm-label-switcher.html' %}
{% include 'morphodict/components/paradigm.html' %}
{% endif %}
</section>
</article>
Expand Down
5 changes: 5 additions & 0 deletions src/morphodict/paradigm/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class ParadigmConfig(AppConfig):
name = "morphodict.paradigm"
File renamed without changes.
2 changes: 1 addition & 1 deletion src/morphodict/paradigm/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
path(
"_paradigm_details/",
views.paradigm_internal,
name="cree-dictionary-paradigm-detail",
name="morphodict-paradigm-detail",
),
]
5 changes: 5 additions & 0 deletions src/morphodict/relabelling/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class RelabellingConfig(AppConfig):
name = "morphodict.relabelling"
2 changes: 2 additions & 0 deletions src/morphodict/site/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,14 @@
"morphodict.lexicon",
# Internal apps
# TODO: our internal app organization is kind of a mess 🙃
"morphodict.relabelling",
"morphodict.api",
"morphodict.frontend",
"morphodict.cvd",
"morphodict.search_quality",
"morphodict.phrase_translate",
"morphodict.orthography",
"morphodict.paradigm",
# This comes last so that other apps can override templates
"django.contrib.admin",
]
Expand Down
6 changes: 3 additions & 3 deletions src/morphodict/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@ def test_paradigm_details_internal_400_404(
get_data["lemma-id"] = lemma_id
if paradigm_size is not None:
get_data["paradigm-size"] = paradigm_size
response = c.get(reverse("cree-dictionary-paradigm-detail"), get_data)
response = c.get(reverse("morphodict-paradigm-detail"), get_data)
assert response.status_code == expected_code

@pytest.mark.parametrize(("method",), (("post",), ("put",), ("delete",)))
def test_paradigm_details_internal_wrong_method(self, method: str):
c = Client()
response = getattr(c, method)(
reverse("cree-dictionary-paradigm-detail"),
reverse("morphodict-paradigm-detail"),
{"lemma-id": 1, "paradigm-size": "BASIC"},
)
assert response.status_code == HttpResponseNotAllowed.status_code
Expand Down Expand Up @@ -146,7 +146,7 @@ def test_paradigm_from_full_page_and_api(client: Client):

# Get fragment from API request:
response = client.get(
reverse("cree-dictionary-paradigm-detail"),
reverse("morphodict-paradigm-detail"),
cast(
Dict[str, int | str],
{
Expand Down

0 comments on commit 4cf8f96

Please sign in to comment.