Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
222 commits
Select commit Hold shift + click to select a range
66a1a32
user stats table and model
categulario Apr 8, 2025
c498e81
create mapping_levels table and initial data
categulario Apr 15, 2025
8be8d2c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 15, 2025
7aaff56
properly configure mapping_level relationship in user model
categulario Apr 22, 2025
700206f
invert logic for _is_user_beginner
categulario Apr 22, 2025
ce6041b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 22, 2025
bf39840
integrate is_beginner column into existing migration
categulario May 5, 2025
7183d5b
fix tests related to mapping level in project_service
categulario May 5, 2025
92b30e4
consider new is_beginner column in test fixtures
categulario May 5, 2025
960fe97
get level for user from the database
categulario May 5, 2025
d141985
fix all user service tests
categulario May 5, 2025
b087969
replace critical appearences of MappingLevel enum
categulario May 5, 2025
14d5a91
Merge branch 'develop' into feature/6706-super-mapper-1-stats-table
categulario May 5, 2025
75c0692
fix project_search_service for mapping level as table
categulario May 5, 2025
7970512
fix stats_service for mapping level as table
categulario May 5, 2025
755c3c8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 5, 2025
58f1c5b
fix user_service for mapping level as table
categulario May 6, 2025
809eefd
Adapt UserDTO to mapping level as a table
categulario May 6, 2025
a5d3003
fix User.get_all_users for mapping level as table
categulario May 6, 2025
9fe3177
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 6, 2025
9ac223a
add mapping_badges table and crossing table with users
categulario May 13, 2025
6fbac05
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 13, 2025
a1453f5
alter UserStatsDTO to match new dynamic mapping levels
categulario May 13, 2025
1fd2def
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 13, 2025
531844f
fix user api
categulario May 19, 2025
331a6c6
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 19, 2025
e69097c
add MappingLevelService.get_all method
categulario May 20, 2025
69a3c68
add mapping_level list api
categulario May 20, 2025
bd0b1ab
add create and get_all methos to MappingBadgeService
categulario May 20, 2025
1b55536
badges API: list and create
categulario May 20, 2025
80ce660
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 20, 2025
97facdf
Merge branch 'develop' into feature/6706-super-mapper-1-stats-table
categulario May 26, 2025
f62d1db
add update to MappingLevel and MappingBadge services
categulario May 27, 2025
7b40686
don't allow deletion of a level with users
categulario May 27, 2025
a139142
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 27, 2025
91a063e
apis for manipulating levels
categulario May 27, 2025
6ef76e8
fix aliases in mapping_levels api
categulario May 27, 2025
0037a18
save user stats on stats query
categulario Jun 3, 2025
d1cab74
save stats on user login
categulario Jun 3, 2025
154f8fd
don't allow login to fail
categulario Jun 3, 2025
f222c40
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 3, 2025
f162319
frontend work for badges
categulario Jun 4, 2025
6d9090d
Working but unfinished badge create UI
categulario Jun 4, 2025
8c504a3
working list of badges
categulario Jun 4, 2025
85280a0
make PR pass sonarqube's quality gate
categulario Jun 5, 2025
4cf75ba
be able to edit and delete badges
categulario Jun 9, 2025
c7976c6
the levels UI starter
categulario Jun 10, 2025
b3e0361
levels don't require an image
categulario Jun 15, 2025
fe8b823
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 15, 2025
d1d2342
badges UI almost complete
categulario Jun 24, 2025
ce49a99
allow to mark a badge as internal
categulario Jun 24, 2025
05b2fe2
add checkbox to mark a badge as internal
categulario Jun 24, 2025
4ecd5f9
connect switch to form in badge form
categulario Jun 24, 2025
d20b19a
connect the requirements field to the badge form
categulario Jun 24, 2025
02c4bff
extract fragment as component
categulario Jun 24, 2025
a667574
prevent form submit on button
categulario Jun 24, 2025
431b0f1
improvements to the mapping level admin ui
categulario Jun 24, 2025
d7a108d
format
categulario Jun 24, 2025
a0f81c8
component that sets approvals in the level form
categulario Jun 25, 2025
9a33bc5
color control in level form
categulario Jun 25, 2025
5de1071
minor style adjustment
categulario Jun 25, 2025
a4d8cd6
do not receive ordering on level create, use next available
categulario Jun 26, 2025
77a0f7e
read badges for level edit form from api
categulario Jun 26, 2025
0f830ad
store relationship between levels and badges
categulario Jun 27, 2025
e0c759b
allow updating badge requirements for levels
categulario Jun 27, 2025
2837a35
more robust test suite
categulario Jun 27, 2025
d156b7f
also return badges in endpoints that return a single level
categulario Jun 27, 2025
ecc7316
be able to manage required badges for levels
categulario Jun 28, 2025
9ddc4bd
use names instead of ids
categulario Jun 28, 2025
96e03d3
handle the first moment of load properly
categulario Jun 28, 2025
e2e8694
run formatter
categulario Jun 28, 2025
dd5009f
properly pass badges for level creation
categulario Jun 28, 2025
19cdf9f
also delete associations with badges on level delete
categulario Jun 28, 2025
d4aa862
replace user list for a table
categulario Jul 1, 2025
9c6d3b3
adjustments to last changes in API
categulario Jul 1, 2025
990569d
show time of stats last updated
categulario Jul 1, 2025
160f83a
allow updating stats from user list
categulario Jul 1, 2025
ea3d99b
only show upload control if api key is set
categulario Jul 2, 2025
93c3f94
enable image uploader for badge form
categulario Jul 2, 2025
99f7c9a
show user stats in user list
categulario Jul 7, 2025
f11f47a
bunch of sonarqube fixes
categulario Jul 7, 2025
2eeb76d
Merge branch 'develop' into feature/6706-super-mapper-1-stats-table
categulario Jul 8, 2025
727d58f
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2025
538705d
migration that creates base badges
categulario Jul 8, 2025
bb282f7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 8, 2025
f15f7c0
assign badges and levels
categulario Jul 9, 2025
02b1714
Merge branch 'develop' into feature/6706-super-mapper-1-stats-table
categulario Jul 9, 2025
036b1ab
support tables for voting users into levels
categulario Jul 9, 2025
b159ffc
nominate users into their next levels
categulario Jul 9, 2025
f77041b
fix how metrics are stored in badge form
categulario Jul 9, 2025
5ed3915
assign unconditionally the beginner level to new users
categulario Jul 9, 2025
d912cae
fix date parsing in users table
categulario Jul 9, 2025
4975515
check for level upgrade if stats are manually updated
categulario Jul 9, 2025
b9a29a7
fix usage of intl in badges ui
categulario Jul 9, 2025
c1da299
standarize error when ohsome api fails
categulario Jul 9, 2025
a7c6999
level approval system
categulario Jul 10, 2025
967c163
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 10, 2025
c7c07d5
small fixes around user approval
categulario Jul 10, 2025
36b37df
fix typo
categulario Jul 10, 2025
0678435
add support for points of interest in UI
categulario Jul 10, 2025
a53b8fb
clear votes after a level upgrade
categulario Jul 10, 2025
18ccbdf
show a message if you alredy voted for a user
categulario Jul 10, 2025
d3fa11a
make api calls consistent with each other
categulario Jul 14, 2025
ad89acd
make stats match
categulario Jul 14, 2025
ebb2f52
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 14, 2025
dbf0247
endpoint for publicly listing a user's badges
categulario Jul 14, 2025
8c94a7a
show badges in user profile
categulario Jul 14, 2025
ae75b5d
change wording in badge management
categulario Jul 14, 2025
8f98da2
implement restricting mapping and validation by level
categulario Jul 15, 2025
63122e5
make project search aware of new levels
categulario Jul 15, 2025
57cc732
allow to change required level for project in UI
categulario Jul 15, 2025
f407ed3
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jul 15, 2025
f811ff4
show mapping level in project detail
categulario Jul 15, 2025
af75c98
prevent overflow in badge requirements
categulario Jul 15, 2025
3e45e19
prevent redirect when fetching from API
categulario Jul 25, 2025
3ab6564
round stats to one decimal place
categulario Jul 25, 2025
ad75bbc
validate badge requirements
categulario Jul 25, 2025
00ebb3d
require one badge per level at least
categulario Jul 25, 2025
81fedb9
make teams default validation rule for projects
categulario Jul 25, 2025
e0feee0
improve message when deleting a level with users
categulario Jul 25, 2025
7023fe0
rearrange permission table in project page
categulario Jul 25, 2025
3e1082a
properly warn if a badge could not be deleted
categulario Jul 25, 2025
38d48d9
allow to force-set user level
categulario Jul 26, 2025
2b373bd
fix get badges query in deployments
categulario Jul 29, 2025
59a77cd
make stats match between profile and user table
categulario Jul 31, 2025
cfb6c73
show progress towards next level
categulario Jul 31, 2025
1cbd8d1
run black
categulario Jul 31, 2025
657111c
show users that require approval first in the table
categulario Aug 1, 2025
172835e
allow sorting users table by stats columns
categulario Aug 4, 2025
51aa82f
make changeset count agree with production
categulario Aug 4, 2025
8909c74
fix bug in user detail
categulario Aug 4, 2025
c509cd6
black formatting
categulario Aug 4, 2025
81b1b86
Fix layout issue where long localization text overlapped login button
suzit-10 Aug 4, 2025
0e0ad3d
Merge branch 'develop' into feature/6706-super-mapper-1-stats-table
categulario Aug 5, 2025
ef69574
fix tests using new async client
categulario Aug 5, 2025
627f452
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 5, 2025
7ede391
Download task grid file with auth token using fetch and Blob
suzit-10 Aug 7, 2025
e25da07
Comment out the test cases related to anchor based file download
suzit-10 Aug 7, 2025
d0fe255
use more descriptive variable names for joins
categulario Aug 7, 2025
ae2fd86
document MappingLevel::create function
categulario Aug 7, 2025
7573650
remove hardcoded id from code
categulario Aug 7, 2025
d9dcbb1
add comment to UserLevelVote::count
categulario Aug 7, 2025
0b9243e
fix error message ragarding failed OSM call
categulario Aug 7, 2025
3b70575
add alts to images in badges
categulario Aug 7, 2025
113045d
change wording related to badge requirements
categulario Aug 7, 2025
2f5738c
user more explicit variable names
categulario Aug 7, 2025
8ac4b85
remove unused import
categulario Aug 7, 2025
f79bd21
add missing alt to image
categulario Aug 7, 2025
89dd710
fix webpack chunk name
categulario Aug 7, 2025
5b522bd
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 7, 2025
7fb4c63
add clarifying comment about is_beginner column in mapping_level.
categulario Aug 7, 2025
8b14a83
add comments to API methods
categulario Aug 7, 2025
b0d09dc
Fix logo cut-off on small screens
suzit-10 Aug 11, 2025
42c1aec
Merge pull request #6800 from categulario/feature/6706-super-mapper-1…
emi420 Aug 11, 2025
528a006
Merge pull request #6991 from hotosm/fix/6989-map-swipe-tab-crash
ramyaragupathy Aug 12, 2025
43b10ec
Merge pull request #6993 from hotosm/fix/6984-Unable-to-download-task…
ramyaragupathy Aug 12, 2025
78ebae0
Merge pull request #6985 from hotosm/fix/6508-Login-button-is-not-vis…
ramyaragupathy Aug 12, 2025
f6f144a
eslint fixes for super mapper feature
categulario Aug 12, 2025
26cc4c5
Merge pull request #6997 from categulario/fix/eslint-fixes
emi420 Aug 12, 2025
051e0e7
fix progress message for levels
categulario Aug 12, 2025
e5edc5e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 12, 2025
24b0474
Merge pull request #6998 from categulario/feat/level-progess
emi420 Aug 12, 2025
ea156a0
fix(infra/ecs): add ohsome envs
nischalstha9 Aug 13, 2025
f72125c
Merge pull request #7000 from hotosm/infra/add/ohsome-envs
nischalstha9 Aug 13, 2025
5278b6c
add --immediate-exit option to cron_jobs script
jacobwhall Aug 13, 2025
cef5ffb
allow scheduler to live on when we aren't immediately exiting
jacobwhall Aug 14, 2025
a86bad4
allow to clear mapping level filter in user table
categulario Aug 19, 2025
3a75089
show project permission box above later elements
categulario Aug 19, 2025
e143fcc
allow saving beginner level with no badges
categulario Aug 19, 2025
bc78421
fix projects to map query
categulario Aug 19, 2025
4de84a3
Merge pull request #7013 from categulario/fix/restore-functionality
emi420 Aug 20, 2025
b5af2f6
fix problem when deleting level with votes
categulario Aug 22, 2025
266ca13
Merge pull request #7014 from categulario/fix/delete-levels
emi420 Aug 22, 2025
5ffc938
project id in reset task action while setting action history
prabinoid Aug 18, 2025
8572d73
clear next level and votes on badge and level update
categulario Aug 27, 2025
52a9327
Merge pull request #7016 from categulario/fix/clear-next-level-and-vo…
emi420 Aug 27, 2025
35612b7
properly handle when there is no next level for the user
categulario Aug 28, 2025
372860b
Merge pull request #7017 from categulario/fix/next-level
emi420 Aug 28, 2025
698430e
Update user level script replaced with refresh mapper level
prabinoid Aug 29, 2025
ec479c5
Fix pre-commit checks
prabinoid Aug 29, 2025
20aea96
Update refresh mapper level script to fetch all stats but omit badges…
prabinoid Aug 29, 2025
5f34a9b
Merge pull request #7018 from hotosm/fix/script-formatting
emi420 Aug 30, 2025
e4ff401
Use check and update stats function in refresh mapper level command
prabinoid Sep 1, 2025
80785d0
project id from taskdto instead of task object
prabinoid Sep 1, 2025
98fc713
Update docs for v5 migration and cors
prabinoid Sep 2, 2025
7520e5a
Merge pull request #7003 from MapRVA/cron-immediate-exit
nischalstha9 Sep 3, 2025
b444f01
Merge pull request #7021 from hotosm/feat/development
nischalstha9 Sep 3, 2025
4445e8f
Run pre-commit on all files
prabinoid Sep 3, 2025
c7af78b
Ignore certain flake8 check for migration file only on github action
prabinoid Sep 3, 2025
6594678
Merge pull request #7022 from hotosm/fix/formatting
nischalstha9 Sep 3, 2025
12d3bcf
don't skip badge assignment for top levels
categulario Sep 3, 2025
70edd99
fix broken test case
categulario Sep 3, 2025
2c89273
test that a message is sent on new level earned
categulario Sep 3, 2025
3e65545
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 4, 2025
96c2103
Add quotes limitation to text search query
prabinoid Sep 8, 2025
cfe896c
allow listing projects to map or validate as anonymous user
categulario Sep 8, 2025
dfe8b8a
Merge pull request #7023 from categulario/fix/badges-not-assigned
emi420 Sep 8, 2025
644d1fc
Merge pull request #7024 from categulario/fix/project-search
emi420 Sep 8, 2025
d1a13f6
Merge pull request #7025 from hotosm/fix/project-search
emi420 Sep 9, 2025
d21a5ec
set default validation permission to any with intermediate level
categulario Sep 9, 2025
720c3dc
Merge pull request #7026 from categulario/fix/project-validation-perm…
emi420 Sep 9, 2025
dabef52
bring back project statistics: users per level
categulario Sep 10, 2025
6dd9c31
Merge pull request #7027 from categulario/fix/project-statistics
emi420 Sep 10, 2025
ad2a9f6
Merge pull request #7019 from hotosm/fix/script-formatting
ramyaragupathy Sep 11, 2025
40c80c4
Merge pull request #7011 from hotosm/feat/update-docs
ramyaragupathy Sep 11, 2025
736157e
add test mock data userLevels
suzit-10 Sep 11, 2025
e93d3e2
add test id to a table body
suzit-10 Sep 11, 2025
b941c83
add levels mock data on server-handlers
suzit-10 Sep 11, 2025
7f6ff2c
adapt test cases as per super-mapper changes
suzit-10 Sep 11, 2025
ff40c79
Update user stats in parallel
prabinoid Sep 12, 2025
3212b6e
Merge pull request #7029 from hotosm/fix/adapt-super-mapper-test-cases
ramyaragupathy Sep 15, 2025
4cd7704
Add batch size and concurrent workers input in command
prabinoid Sep 16, 2025
573e3b2
Merge pull request #7031 from hotosm/feat/update-users-concurrently
nischalstha9 Sep 16, 2025
2752fb6
Application db pool made dynamic and created separate connection and …
prabinoid Sep 16, 2025
9a533f0
Merge pull request #7036 from hotosm/feat/update-users-concurrently
nischalstha9 Sep 16, 2025
506441b
Merge pull request #7033 from hotosm/develop
ramyaragupathy Sep 16, 2025
6af45bb
feat: make ecs_execute_command controllable from env file
nischalstha9 Sep 18, 2025
2d98558
fix: task min-max percent
nischalstha9 Sep 18, 2025
b3df7e0
Merge pull request #7037 from hotosm/feat/infra-ecs-execute
nischalstha9 Sep 18, 2025
5ff0720
Exception handling for users not found in osm and users deleted from osm
prabinoid Sep 18, 2025
21bd7e2
Merge pull request #7038 from hotosm/feat/update-users-concurrently
nischalstha9 Sep 18, 2025
706d388
Merge pull request #7039 from hotosm/develop
nischalstha9 Sep 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pr_test_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- name: Run PEP8 checks
run: |
flake8 manage.py backend tests migrations --ignore=E203,W503
flake8 manage.py backend tests migrations --ignore=E203,W503,F401,E501
black --check manage.py backend tests migrations

pytest:
Expand Down
Empty file.
121 changes: 121 additions & 0 deletions backend/api/mapping_badges/resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
from databases import Database
from fastapi import APIRouter, Depends

from backend.db import get_db
from backend.models.dtos.mapping_badge_dto import (
MappingBadgeDTO,
MappingBadgeCreateDTO,
MappingBadgeUpdateDTO,
MappingBadgeListDTO,
MappingBadgePublicListDTO,
)
from backend.models.dtos.user_dto import AuthUserDTO
from backend.services.mapping_badges import MappingBadgeService
from backend.services.users.authentication_service import pm_only

router = APIRouter(
prefix="/badges",
tags=["mapping_badges"],
responses={404: {"description": "Not found"}},
)


@router.get("/")
async def get_mapping_badges(
db: Database = Depends(get_db),
) -> MappingBadgeListDTO:
"""
List mapping badges
---
tags:
- badges
produces:
- application/json
"""
return await MappingBadgeService.get_all(db)


@router.post("/")
async def create_mapping_badge(
data: MappingBadgeCreateDTO,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
) -> MappingBadgeDTO:
"""
Creates a new MappingBadge
---
tags:
- badges
produces:
- application/json
"""
return await MappingBadgeService.create(data, db)


@router.get("/{badge_id}/")
async def get_mapping_badge(
badge_id: int,
db: Database = Depends(get_db),
) -> MappingBadgeDTO:
"""
Gets information for a single badge
---
tags:
- badges
produces:
- application/json
"""
return await MappingBadgeService.get_by_id(badge_id, db)


@router.patch("/{badge_id}/")
async def update_mapping_badge(
data: MappingBadgeUpdateDTO,
badge_id: int,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
) -> MappingBadgeDTO:
"""
Updates a mapping badge
---
tags:
- badges
produces:
- application/json
"""
data.id = badge_id

return await MappingBadgeService.update(data, db)


@router.delete("/{badge_id}/")
async def delete_mapping_badge(
badge_id: int,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
):
"""
Deletes a mapping badge
---
tags:
- badges
produces:
- application/json
"""
await MappingBadgeService.delete(badge_id, db)


@router.get("/user/{user_id}/")
async def get_for_user(
user_id: int,
db: Database = Depends(get_db),
) -> MappingBadgePublicListDTO:
"""
Get all mapping badges that a user has earned
---
tags:
- badges
produces:
- application/json
"""
return await MappingBadgeService.get_for_user(user_id, db)
Empty file.
102 changes: 102 additions & 0 deletions backend/api/mapping_levels/resources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
from databases import Database
from fastapi import APIRouter, Depends

from backend.db import get_db
from backend.models.dtos.mapping_level_dto import (
MappingLevelCreateDTO,
MappingLevelUpdateDTO,
)
from backend.models.dtos.user_dto import AuthUserDTO
from backend.services.mapping_levels import MappingLevelService
from backend.services.users.authentication_service import pm_only

router = APIRouter(
prefix="/levels",
tags=["mapping_levels"],
responses={404: {"description": "Not found"}},
)


@router.get("/")
async def get_mapping_levels(
db: Database = Depends(get_db),
):
"""
List mapping levels
---
tags:
- levels
produces:
- application/json
"""
return await MappingLevelService.get_all(db)


@router.post("/")
async def create_mapping_level(
data: MappingLevelCreateDTO,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
):
"""
Create a new mapping level
---
tags:
- levels
produces:
- application/json
"""
return await MappingLevelService.create(data, db)


@router.get("/{level_id}/")
async def get_mapping_level(
level_id: int,
db: Database = Depends(get_db),
):
"""
Get a mapping level by its id
---
tags:
- levels
produces:
- application/json
"""
return await MappingLevelService.get_by_id(level_id, db)


@router.patch("/{level_id}/")
async def update_mapping_level(
data: MappingLevelUpdateDTO,
level_id: int,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
):
"""
Update a given mapping level
---
tags:
- levels
produces:
- application/json
"""
data.id = level_id

return await MappingLevelService.update(data, db)


@router.delete("/{level_id}/")
async def delete_mapping_level(
level_id: int,
db: Database = Depends(get_db),
user: AuthUserDTO = Depends(pm_only),
):
"""
Delete the specified mapping level
---
tags:
- levels
produces:
- application/json
"""
await MappingLevelService.delete(level_id, db)
2 changes: 0 additions & 2 deletions backend/api/projects/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ async def get_activities(
db,
)
if not project_dto:

return JSONResponse(
content={
"Error": "User not permitted: Private Project",
Expand Down Expand Up @@ -133,7 +132,6 @@ async def get_latest_activities(
db,
)
if not project_dto:

return JSONResponse(
content={
"Error": "User not permitted: Private Project",
Expand Down
1 change: 0 additions & 1 deletion backend/api/projects/contributions.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ async def get_project_contributions(
db,
)
if not project_dto:

return JSONResponse(
content={
"Error": "User not permitted: Private Project",
Expand Down
1 change: 0 additions & 1 deletion backend/api/projects/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,6 @@ async def get_project_summary(
db,
)
if not project_dto:

return JSONResponse(
content={
"Error": "User not permitted: Private Project",
Expand Down
2 changes: 0 additions & 2 deletions backend/api/tasks/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ async def get_project_tasks(
description: Internal Server Error
"""
try:

is_private, status = await ProjectService.get_project_privacy_and_status(
project_id, db
)
Expand All @@ -137,7 +136,6 @@ async def get_project_tasks(
db,
)
if not project_dto:

return JSONResponse(
content={
"Error": "User not permitted: Private Project",
Expand Down
53 changes: 53 additions & 0 deletions backend/api/users/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,59 @@ async def set_user_role(
)


@router.patch("/{username}/actions/update-stats")
async def update_stats(
request: Request,
username: str,
_: AuthUserDTO = Depends(pm_only),
db: Database = Depends(get_db),
):
"""
Updates user stats
---
tags:
- users
- stats
produces:
- application/json
"""
try:
user = await UserService.get_user_by_username(username, db)
stats = await UserService.get_and_save_stats(user.id, db)
await UserService.check_and_update_mapper_level(user.id, db, stats)
except UserServiceError as e:
return JSONResponse(
content={"Error": str(e).split("-")[1], "SubCode": str(e).split("-")[0]},
status_code=500,
)


@router.patch("/{username}/actions/approve-level")
async def approve_level(
request: Request,
username: str,
voter: AuthUserDTO = Depends(pm_only),
db: Database = Depends(get_db),
):
"""
Casts a vote for the promotion of a user to their next level
---
tags:
- users
- levels
produces:
- application/json
"""
try:
user = await UserService.get_user_by_username(username, db)
await UserService.approve_level(user.id, voter.id, db)
except UserServiceError as e:
return JSONResponse(
content={"Error": str(e).split("-")[1], "SubCode": str(e).split("-")[0]},
status_code=400,
)


@router.patch("/{user_name}/actions/set-expert-mode/{is_expert}/")
async def set_user_is_expert(
request: Request,
Expand Down
3 changes: 2 additions & 1 deletion backend/api/users/openstreetmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from backend.db import get_db
from backend.models.dtos.user_dto import AuthUserDTO
from backend.services.users.authentication_service import login_required
from backend.services.users.user_service import OSMServiceError, UserService
from backend.services.users.user_service import UserService
from backend.services.users.osm_service import OSMServiceError

router = APIRouter(
prefix="/users",
Expand Down
7 changes: 7 additions & 0 deletions backend/api/users/resources.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import Optional

from databases import Database
from fastapi import APIRouter, Depends, Request, Query, Path
from fastapi.responses import JSONResponse
Expand Down Expand Up @@ -61,6 +63,8 @@ async def get_user(
async def list_users(
page: int = Query(1, description="Page of results user requested"),
pagination: bool = Query(True, description="Whether to return paginated results"),
sort: Optional[str] = Query(None, description="sort by this metric"),
sort_dir: str = Query(default="asc", description="sort direction"),
per_page: int = Query(
20, alias="perPage", description="Number of results per page"
),
Expand Down Expand Up @@ -125,9 +129,12 @@ async def list_users(
pagination=pagination,
page=page if pagination else None,
per_page=per_page,
sort=sort,
sort_dir=sort_dir,
username=username,
mapping_level=level,
role=role,
voter_id=user.id,
)
except Exception as e:
logger.error(f"Error validating request: {str(e)}")
Expand Down
Loading
Loading