Skip to content

Commit

Permalink
Merge pull request #3817 from hotosm/develop
Browse files Browse the repository at this point in the history
v4.2.0 Release
  • Loading branch information
willemarcel committed Nov 3, 2020
2 parents 92c9aad + 2601863 commit 8e49495
Show file tree
Hide file tree
Showing 59 changed files with 639 additions and 1,326 deletions.
591 changes: 46 additions & 545 deletions .circleci/config.yml

Large diffs are not rendered by default.

24 changes: 16 additions & 8 deletions backend/models/postgis/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ class Project(db.Model):
default=[
Editors.ID.value,
Editors.JOSM.value,
Editors.POTLATCH_2.value,
Editors.FIELD_PAPERS.value,
Editors.CUSTOM.value,
],
index=True,
Expand All @@ -184,8 +182,6 @@ class Project(db.Model):
default=[
Editors.ID.value,
Editors.JOSM.value,
Editors.POTLATCH_2.value,
Editors.FIELD_PAPERS.value,
Editors.CUSTOM.value,
],
index=True,
Expand Down Expand Up @@ -333,11 +329,18 @@ def clone(project_id: int, author_id: int):
orig_changeset, ""
)

# Copy array relationships.
for field in ["interests", "campaign", "teams"]:
# Populate teams, interests and campaigns
teams = []
for team in orig.teams:
team_data = team.__dict__.copy()
team_data.pop("_sa_instance_state")
team_data.update({"project_id": new_proj.id})
teams.append(ProjectTeams(**team_data))
new_proj.teams = teams

for field in ["interests", "campaign"]:
value = getattr(orig, field)
setattr(new_proj, field, value)

new_proj.custom_editor = orig.custom_editor

return new_proj
Expand Down Expand Up @@ -401,11 +404,13 @@ def update(self, project_dto: ProjectDTO):
validation_editors_array.append(Editors[validation_editor].value)
self.validation_editors = validation_editors_array
self.country = project_dto.country_tag

# Add list of allowed users, meaning the project can only be mapped by users in this list
if hasattr(project_dto, "allowed_users"):
self.allowed_users = [] # Clear existing relationships then re-insert
for user in project_dto.allowed_users:
self.allowed_users.append(user)

# Update teams and projects relationship.
self.teams = []
if hasattr(project_dto, "project_teams") and project_dto.project_teams:
Expand All @@ -417,6 +422,7 @@ def update(self, project_dto: ProjectDTO):

role = TeamRoles[team_dto.role].value
ProjectTeams(project=self, team=team, role=role)

# Set Project Info for all returned locales
for dto in project_dto.project_info_locales:

Expand Down Expand Up @@ -447,6 +453,7 @@ def update(self, project_dto: ProjectDTO):
else:
if self.custom_editor:
self.custom_editor.delete()

# handle campaign update
try:
new_ids = [c.id for c in project_dto.campaigns]
Expand Down Expand Up @@ -478,8 +485,9 @@ def update(self, project_dto: ProjectDTO):
current_ids.sort()
if new_ids != current_ids:
self.interests = Interest.query.filter(Interest.id.in_(new_ids)).all()

# try to update country info if that information is not present
if len(self.country) == 0:
if not self.country:
self.set_country_info()

db.session.commit()
Expand Down
1 change: 1 addition & 0 deletions backend/models/postgis/statuses.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class ValidatingNotAllowed(Enum):
NOT_A_VALIDATION_TEAM = 105
USER_NOT_TEAM_MEMBER = 106
PROJECT_HAS_NO_TEAM = 107
USER_ALREADY_HAS_TASK_LOCKED = 108


class UserGender(Enum):
Expand Down
4 changes: 2 additions & 2 deletions backend/models/postgis/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class InvalidGeoJson(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class UserLicenseError(Exception):
Expand All @@ -31,7 +31,7 @@ class InvalidData(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class ST_SetSRID(GenericFunction):
Expand Down
2 changes: 1 addition & 1 deletion backend/services/grid/split_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class SplitServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class SplitService:
Expand Down
4 changes: 2 additions & 2 deletions backend/services/mapping_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class MappingServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class MappingService:
Expand Down Expand Up @@ -96,7 +96,7 @@ def lock_task_for_mapping(lock_task_dto: LockTaskDTO) -> TaskDTO:
raise UserLicenseError("User must accept license to map this task")
else:
raise MappingServiceError(
f"Mapping not allowed because: {error_reason.name}"
f"Mapping not allowed because: {error_reason}"
)

task.lock_task_for_mapping(lock_task_dto.user_id)
Expand Down
2 changes: 1 addition & 1 deletion backend/services/messaging/message_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MessageServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class MessageService:
Expand Down
2 changes: 1 addition & 1 deletion backend/services/organisation_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class OrganisationServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class OrganisationService:
Expand Down
4 changes: 2 additions & 2 deletions backend/services/project_admin_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class ProjectAdminServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class ProjectStoreError(Exception):
""" Custom Exception to notify callers an error occurred with database CRUD operations """

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class ProjectAdminService:
Expand Down
4 changes: 2 additions & 2 deletions backend/services/project_search_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ class ProjectSearchServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class BBoxTooBigError(Exception):
""" Custom Exception to notify callers an error occurred when handling mapping """

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class ProjectSearchService:
Expand Down
2 changes: 1 addition & 1 deletion backend/services/project_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class ProjectServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class ProjectService:
Expand Down
4 changes: 2 additions & 2 deletions backend/services/team_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ class TeamServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class TeamJoinNotAllowed(Exception):
""" Custom Exception to notify bad user level on joining team """

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class TeamService:
Expand Down
2 changes: 1 addition & 1 deletion backend/services/users/authentication_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AuthServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class AuthenticationService:
Expand Down
2 changes: 1 addition & 1 deletion backend/services/users/osm_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class OSMServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class OSMService:
Expand Down
2 changes: 1 addition & 1 deletion backend/services/users/user_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class UserServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class UserService:
Expand Down
6 changes: 4 additions & 2 deletions backend/services/validator_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ValidatorServiceError(Exception):

def __init__(self, message):
if current_app:
current_app.logger.error(message)
current_app.logger.debug(message)


class ValidatorService:
Expand Down Expand Up @@ -75,9 +75,11 @@ def lock_tasks_for_validation(validation_dto: LockForValidationDTO) -> TaskDTOs:
if not user_can_validate:
if error_reason == ValidatingNotAllowed.USER_NOT_ACCEPTED_LICENSE:
raise UserLicenseError("User must accept license to map this task")
elif error_reason == ValidatingNotAllowed.USER_ALREADY_HAS_TASK_LOCKED:
raise ValidatorServiceError("User already has a task locked")
else:
raise ValidatorServiceError(
f"Validation not allowed because: {error_reason.name}"
f"Validation not allowed because: {error_reason}"
)

# Lock all tasks for validation
Expand Down
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ services:
backend:
<<: *backend
container_name: backend
restart: always
labels:
- traefik.http.routers.backend.rule=Host(`localhost`) && PathPrefix(`/api/`)
- traefik.http.services.backend.loadbalancer.server.port=5000
Expand All @@ -28,6 +29,7 @@ services:

frontend:
image: hotosm-tasking-manager:frontend
restart: always
networks:
- tm-web
labels:
Expand All @@ -37,12 +39,14 @@ services:
postgresql:
image: mdillon/postgis:11
container_name: postgresql
restart: always
env_file: ${ENV_FILE:-tasking-manager.env}
networks:
- tm-web

traefik:
image: traefik:v2.3
restart: always
ports:
- "80:80"
volumes:
Expand Down
6 changes: 3 additions & 3 deletions docs/setup-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ If you don't want to setup a backend server, you can work on frontend developmen
**Dependencies**

The following dependencies must be available _globally_ on your system:
* Download and install [NodeJS LTS v10+](https://nodejs.org/en/) and [yarn](https://classic.yarnpkg.com/en/docs/install)
* Download and install [NodeJS LTS v12+](https://nodejs.org/en/) and [yarn](https://classic.yarnpkg.com/en/docs/install)
* Go into the `frontend` directory and execute `yarn`.

#### Available Scripts
Expand Down Expand Up @@ -61,8 +61,8 @@ The backend is made up of a postgres database and an associated API that calls v

#### Dependencies

* [Python 3.6+](https://www.python.org/downloads/)
* Note: The project does not work with Python 2.x. You **will** need Python 3.6+
* [Python 3.7+](https://www.python.org/downloads/)
* Python 3.7 is what HOT uses in production. You can use Python 3.8 too.
* [PostgreSQL](https://www.postgresql.org/download/) with [PostGIS](https://postgis.net/install/)
* [pip](https://pip.pypa.io/en/stable/installing/)
* [libgeos-dev](https://trac.osgeo.org/geos/)
Expand Down
Loading

0 comments on commit 8e49495

Please sign in to comment.