Skip to content

Commit

Permalink
Merge pull request #301 from euphorie/scrum-2316-mailing-lists-sorting
Browse files Browse the repository at this point in the history
Mailing lists: Stable sorting
  • Loading branch information
reinhardt authored Jan 14, 2025
2 parents 7ab8dff + 63f495c commit c6e6735
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/osha/oira/client/browser/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _get_mailing_lists_for(self, brain):
self._get_entry(
"-".join((brain.getId, language)), f"{brain.Title} ({language})"
)
for language in languages
for language in sorted(languages)
]

def filter_permission(self, brains, query, user):
Expand Down Expand Up @@ -197,7 +197,7 @@ def results(self):
query = {
"portal_type": ["euphorie.clientcountry", "euphorie.survey"],
"path": "/".join(self.context.getPhysicalPath()),
"sort_on": "sortable_title",
"sort_on": ("sortable_title", "path"),
}

# Filter for query string if given. Else return all results.
Expand Down
18 changes: 9 additions & 9 deletions src/osha/oira/client/tests/test_mailing_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def setUp(self):
survey = """<sector xmlns="http://xml.simplon.biz/euphorie/survey/1.0">
<title>Test</title>
<survey>
<title>Second Survey</title>
<title>Software development</title>
<language>fr</language>
</survey>
</sector>"""
Expand Down Expand Up @@ -86,15 +86,15 @@ def test_mailing_lists_batching(self):
self.assertEqual(
results[1],
{
"id": "nl/test/second-survey|U2Vjb25kIFN1cnZleQ==",
"text": "Second Survey (nl/test/second-survey) [0 subscribers]",
"id": "nl/ict/software-development|U29mdHdhcmUgZGV2ZWxvcG1lbnQ=",
"text": "Software development (nl/ict/software-development) [0 subscribers]", # noqa: E501
},
)
self.assertEqual(
results[2],
{
"id": "nl/ict/software-development|U29mdHdhcmUgZGV2ZWxvcG1lbnQ=",
"text": "Software development (nl/ict/software-development) [0 subscribers]", # noqa: E501
"id": "nl/test/software-development|U29mdHdhcmUgZGV2ZWxvcG1lbnQ=",
"text": "Software development (nl/test/software-development) [0 subscribers]", # noqa: E501
},
)

Expand All @@ -111,15 +111,15 @@ def test_mailing_lists_batching(self):
self.assertEqual(
results[0],
{
"id": "nl-nl|VGhlIE5ldGhlcmxhbmRzIChubCk=",
"text": "The Netherlands (nl) [0 subscribers]",
"id": "nl-fr|VGhlIE5ldGhlcmxhbmRzIChmcik=",
"text": "The Netherlands (fr) [0 subscribers]",
},
)
self.assertEqual(
results[1],
{
"id": "nl-fr|VGhlIE5ldGhlcmxhbmRzIChmcik=",
"text": "The Netherlands (fr) [0 subscribers]",
"id": "nl-nl|VGhlIE5ldGhlcmxhbmRzIChubCk=",
"text": "The Netherlands (nl) [0 subscribers]",
},
)

Expand Down

0 comments on commit c6e6735

Please sign in to comment.