Skip to content

Commit

Permalink
Bugfix for CO Unit API #1059
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jan 9, 2025
1 parent b5e0da4 commit 68ba322
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/src/components/LanguageSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default class LanguageSelector extends React.PureComponent {
handleChooseLocale = locale => e => {
stopEvent(e);
if (locale !== I18n.locale) {
Cookies.set("lang", locale, {expires: 356, secure: document.location.protocol.endsWith("https")});
Cookies.set("lang", locale, {expires: 356, secure: document.location.protocol.startsWith("https")});
I18n.locale = locale;
moment.locale(locale);
languageSwitched();
Expand Down
3 changes: 1 addition & 2 deletions server/api/organisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,7 @@ def valid_co(collaboration_json):
co_unit_identifiers = [unit["id"] for unit in collaboration_json.get("units", [])]
if not co_unit_identifiers:
return False
if not all(api_key_unit_id in api_key_unit_identifiers for api_key_unit_id in co_unit_identifiers):
return False
return all(api_key_unit_id in api_key_unit_identifiers for api_key_unit_id in co_unit_identifiers)

valid_collaborations = [co for co in json_organisation.get("collaborations", []) if valid_co(co)]
json_organisation["collaborations"] = valid_collaborations
Expand Down
4 changes: 2 additions & 2 deletions server/test/api/test_organisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,12 +473,12 @@ def test_find_api(self):
self.assertEqual(1, len(group["collaboration_memberships"]))
self.assertTrue(isinstance(group["collaboration_memberships"][0], int))

def test_find_api_no_unit_access(self):
def test_find_api_unit_access(self):
res = self.get("/api/organisations/v1",
headers={"Authorization": f"Bearer {unihard_secret_unit_support}"},
with_basic_auth=False)
collaborations = res["collaborations"]
self.assertEqual(0, len(collaborations))
self.assertEqual(1, len(collaborations))

def test_search_users(self):
self.login("urn:harry")
Expand Down

0 comments on commit 68ba322

Please sign in to comment.