Skip to content

Commit

Permalink
refactor(backend): rename public beta org to hotosm (#1784)
Browse files Browse the repository at this point in the history
* build: update osm-fieldwork --> v0.16.1 for xlsform updates

* build: add migration for renaming fmtm-public-beta --> hotosm

* build: rename fmtm-public-beta --> hotosm in all code
  • Loading branch information
spwoodcock authored Sep 16, 2024
1 parent 30c30e5 commit c25c8a8
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 19 deletions.
6 changes: 3 additions & 3 deletions src/backend/app/auth/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async def check_access(
Access is determined based on the user's role and permissions:
- If the user has an 'ADMIN' role, access is granted.
- If the user has a 'READ_ONLY' role, access is denied.
- If the organisation is the public beta, then grant access.
- If the organisation is HOTOSM, then grant access.
- For other roles, access is granted if the user is an organisation manager
for the specified organisation (org_id) or has the specified role
in the specified project (project_id).
Expand Down Expand Up @@ -95,13 +95,13 @@ async def check_access(
SELECT 1
FROM organisations
WHERE (organisations.id = :org_id
AND organisations.slug = 'fmtm-public-beta')
AND organisations.slug = 'hotosm')
OR EXISTS (
SELECT 1
FROM projects
JOIN organisations AS org
ON projects.organisation_id = org.id
WHERE org.slug = 'fmtm-public-beta'
WHERE org.slug = 'hotosm'
AND projects.id = :project_id
)
) THEN true
Expand Down
10 changes: 5 additions & 5 deletions src/backend/app/organisations/organisation_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def init_admin_org(db: Session):
-- Start a transaction
BEGIN;
-- Insert FMTM Public Beta organisation
-- Insert HOTOSM organisation
INSERT INTO public.organisations (
name,
slug,
Expand All @@ -58,10 +58,10 @@ async def init_admin_org(db: Session):
odk_central_password
)
VALUES (
'FMTM Public Beta',
'fmtm-public-beta',
'HOTOSM',
'hotosm',
'https://avatars.githubusercontent.com/u/458752?s=280&v=4',
'HOTOSM Public Beta for FMTM.',
'Humanitarian OpenStreetMap Team.',
'https://hotosm.org',
'FREE',
true,
Expand Down Expand Up @@ -106,7 +106,7 @@ async def init_admin_org(db: Session):
-- Set localadmin user as org admin
WITH org_cte AS (
SELECT id FROM public.organisations
WHERE name = 'FMTM Public Beta'
WHERE name = 'HOTOSM'
)
INSERT INTO public.organisation_managers (organisation_id, user_id)
SELECT (SELECT id FROM org_cte), :admin_user_id
Expand Down
15 changes: 15 additions & 0 deletions src/backend/migrations/005-rename-public-beta.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- ## Migration to:
-- * Rename FMTM Public Beta org --> HOTOSM

-- Start a transaction
BEGIN;

UPDATE public.organisations
SET
name = 'HOTOSM',
slug = 'hotosm',
description = 'Humanitarian OpenStreetMap Team'
WHERE slug = 'fmtm-public-beta';

-- Commit the transaction
COMMIT;
8 changes: 4 additions & 4 deletions src/backend/pdm.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/backend/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies = [
"pyjwt>=2.8.0",
"async-lru>=2.0.4",
"osm-login-python==2.0.0",
"osm-fieldwork==0.16.0",
"osm-fieldwork==0.16.1",
"osm-rawdata==0.3.2",
"fmtm-splitter==1.3.0",
]
Expand Down
6 changes: 1 addition & 5 deletions src/backend/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,7 @@ async def admin_user(db):
@pytest.fixture(scope="function")
def organisation(db):
"""A test organisation."""
return (
db.query(DbOrganisation)
.filter(DbOrganisation.name == "FMTM Public Beta")
.first()
)
return db.query(DbOrganisation).filter(DbOrganisation.name == "HOTOSM").first()


@pytest.fixture(scope="function")
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/e2e/01-create-new-project.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ test('create new project', async ({ browserName, page }) => {
await page.locator('#description').click();
await page.locator('#description').fill('desc');
await page.getByRole('combobox').click();
await page.getByLabel('FMTM Public Beta').click();
await page.getByLabel('HOTOSM').click();
await page.getByRole('button', { name: 'NEXT' }).click();

// 2. Upload Area Step
Expand Down

0 comments on commit c25c8a8

Please sign in to comment.