diff --git a/backend/api/projects/resources.py b/backend/api/projects/resources.py index b8b56a5d9..3eefb9829 100644 --- a/backend/api/projects/resources.py +++ b/backend/api/projects/resources.py @@ -289,7 +289,7 @@ def patch(self, project_id): properties: projectDatabase: type: string - default: OSM + default: projectStatus: type: string default: DRAFT diff --git a/backend/models/dtos/project_dto.py b/backend/models/dtos/project_dto.py index 965b06917..23dc13f6d 100644 --- a/backend/models/dtos/project_dto.py +++ b/backend/models/dtos/project_dto.py @@ -15,7 +15,6 @@ from backend.models.dtos.team_dto import ProjectTeamDTO from backend.models.dtos.interests_dto import InterestDTO from backend.models.postgis.statuses import ( - ProjectDatabase, ProjectStatus, ProjectPriority, MappingTypes, @@ -27,22 +26,6 @@ ) from backend.models.dtos.campaign_dto import CampaignDTO -def is_known_project_database(value): - """ Validates that Project Database is known value """ - if value.upper() == "ALL": - return True - - if type(value) == list: - return # Don't validate the entire list, just the individual values - - try: - ProjectDatabase[value.upper()] - except KeyError: - raise ValidationError( - f"Unknown projectDatabase: {value} Valid values are {ProjectDatabase.OSM.name}, " - f"{ProjectDatabase.PDMAP.name}" - ) - def is_known_project_status(value): """Validates that Project Status is known value""" @@ -160,7 +143,6 @@ class DraftProjectDTO(Model): database = StringType( required=True, serialized_name="database", - validators=[is_known_project_database], serialize_when_none=False, ) area_of_interest = BaseType(required=True, serialized_name="areaOfInterest") @@ -197,7 +179,6 @@ class ProjectDTO(Model): database = StringType( required=True, serialized_name="database", - validators=[is_known_project_database], serialize_when_none=False, ) project_status = StringType( @@ -332,7 +313,7 @@ class ProjectSearchDTO(Model): preferred_locale = StringType(default="en") difficulty = StringType(validators=[is_known_project_difficulty]) - database = StringType(validators=[is_known_project_database]) + database = StringType() action = StringType() mapping_types = ListType(StringType, validators=[is_known_mapping_type]) mapping_types_exact = BooleanType(required=False) diff --git a/backend/models/postgis/project.py b/backend/models/postgis/project.py index add2f9e51..6fa1cddf8 100644 --- a/backend/models/postgis/project.py +++ b/backend/models/postgis/project.py @@ -38,7 +38,6 @@ from backend.models.postgis.project_info import ProjectInfo from backend.models.postgis.project_chat import ProjectChat from backend.models.postgis.statuses import ( - ProjectDatabase, ProjectStatus, ProjectPriority, TaskStatus, @@ -121,7 +120,7 @@ class Project(db.Model): # Columns id = db.Column(db.Integer, primary_key=True) - database = db.Column(db.Integer, default=ProjectDatabase.OSM.value, nullable=False) + database = db.Column(db.String, nullable=False) status = db.Column(db.Integer, default=ProjectStatus.DRAFT.value, nullable=False) created = db.Column(db.DateTime, default=timestamp, nullable=False) priority = db.Column(db.Integer, default=ProjectPriority.MEDIUM.value) @@ -240,7 +239,7 @@ def create_draft_project(self, draft_project_dto: DraftProjectDTO): self.organisation = draft_project_dto.organisation if draft_project_dto.database is not None: - self.database = ProjectDatabase[draft_project_dto.database].value + self.database = draft_project_dto.database self.status = ProjectStatus.DRAFT.value self.author_id = draft_project_dto.user_id @@ -395,7 +394,7 @@ def get(project_id: int) -> Optional["Project"]: def update(self, project_dto: ProjectDTO): """Updates project from DTO""" - self.database = ProjectDatabase[project_dto.database].value + self.database = project_dto.database self.status = ProjectStatus[project_dto.project_status].value self.priority = ProjectPriority[project_dto.project_priority].value locales = [i.locale for i in project_dto.project_info_locales] @@ -871,7 +870,7 @@ def get_project_summary( summary.random_task_selection_enforced = self.enforce_random_task_selection summary.private = self.private summary.license_id = self.license_id - summary.database = ProjectDatabase(self.database).name + summary.database = self.database summary.status = ProjectStatus(self.status).name summary.id_presets = self.id_presets summary.extra_id_params = self.extra_id_params @@ -1005,7 +1004,7 @@ def _get_project_and_base_dto(self): """Populates a project DTO with properties common to all roles""" base_dto = ProjectDTO() base_dto.project_id = self.id - base_dto.database= ProjectDatabase(self.database).name + base_dto.database= self.database base_dto.project_status = ProjectStatus(self.status).name base_dto.default_locale = self.default_locale base_dto.project_priority = ProjectPriority(self.priority).name diff --git a/backend/services/project_search_service.py b/backend/services/project_search_service.py index e6275f15c..71ff65de1 100644 --- a/backend/services/project_search_service.py +++ b/backend/services/project_search_service.py @@ -27,7 +27,6 @@ ValidationPermission, MappingPermission, ProjectDifficulty, - ProjectDatabase, ) from backend.models.postgis.campaign import Campaign from backend.models.postgis.organisation import Organisation @@ -128,7 +127,7 @@ def create_result_dto(project, preferred_locale, total_contributors): list_dto.locale = project_info_dto.locale list_dto.name = project_info_dto.name list_dto.priority = ProjectPriority(project.priority).name - list_dto.database = ProjectDatabase(project.database).name + list_dto.database = project.database list_dto.difficulty = ProjectDifficulty(project.difficulty).name list_dto.short_description = project_info_dto.short_description list_dto.last_updated = project.last_updated @@ -260,7 +259,7 @@ def _filter_projects(search_dto: ProjectSearchDTO, user): ) if search_dto.database and search_dto.database.upper() != "ALL": query = query.filter( - Project.database == ProjectDatabase[search_dto.database].value + Project.database == search_dto.database ) if search_dto.difficulty and search_dto.difficulty.upper() != "ALL": query = query.filter( diff --git a/frontend/src/components/formInputs.js b/frontend/src/components/formInputs.js index 953d988e5..a6c92513d 100644 --- a/frontend/src/components/formInputs.js +++ b/frontend/src/components/formInputs.js @@ -93,6 +93,42 @@ export function OrganisationSelectInput({ className }) { ); } +export const SandboxBoxSelect = ({ className, boxId, onChange }) => { + const [boxes, setBoxes] = useState([]); + + useEffect(() => { + fetch(`https://dashboard.osmsandbox.us/v1/boxes`) + .then(response => response.json()) + .then(result => { + /*result.push({ + name: "✦ New Box ✦" + });*/ + setBoxes(result); + }) + .catch(error => { + console.error('Error initializing session:', error); + }); + }); + + const getBoxPlaceholder = (id) => { + const orgs = boxes.filter((org) => org.organisationId === id); + return orgs.length ? orgs[0].name : ; + }; + + return ( + updateMetadata({ ...metadata, @@ -91,6 +94,19 @@ export default function Review({ metadata, updateMetadata, selectedOrgObj, updat ))} ) : null} + + {metadata.database !== "OSM" ? ( + { + setError(null); + var updatedMeta = { ...metadata, database: option.name || '' }; + updateMetadata(updatedMeta); + }} + className="z-5 w-75 pt3" + /> + ) : null} + {selectedOrgObj.databases && selectedOrgObj.databases.length === 1 ? (

diff --git a/frontend/src/components/projectDetail/infoPanel.js b/frontend/src/components/projectDetail/infoPanel.js index 3fa172337..9a471288f 100644 --- a/frontend/src/components/projectDetail/infoPanel.js +++ b/frontend/src/components/projectDetail/infoPanel.js @@ -12,21 +12,18 @@ import { BigProjectTeaser } from './bigProjectTeaser'; import { useComputeCompleteness } from '../../hooks/UseProjectCompletenessCalc'; const ProjectDatabaseInfo = (props) => { - //if (props.db === 'OSM') { - // - return ( -

-
-

- -

-
- -
+ return ( +
+
+

+ +

+
+
- ); - //} +
+ ); }; const ProjectDetailTypeBar = (props) => { diff --git a/frontend/src/components/projectEdit/descriptionForm.js b/frontend/src/components/projectEdit/descriptionForm.js index 23e30ed15..e59fe4134 100644 --- a/frontend/src/components/projectEdit/descriptionForm.js +++ b/frontend/src/components/projectEdit/descriptionForm.js @@ -40,7 +40,7 @@ export const DescriptionForm = ({ languages }) => { setProjectInfo({ ...projectInfo, diff --git a/frontend/src/components/taskSelection/action.js b/frontend/src/components/taskSelection/action.js index 6d127b9d5..0c0b53efe 100644 --- a/frontend/src/components/taskSelection/action.js +++ b/frontend/src/components/taskSelection/action.js @@ -220,7 +220,7 @@ export function TaskMapAction({ project, tasks, activeTasks, getTasks, action, e
} > - {project.database === 'OSM' ? ( + {project.database === '' ? ( editor === 'ID' ? ( ) @@ -272,7 +273,7 @@ export function TaskMapAction({ project, tasks, activeTasks, getTasks, action, e )}
{showSidebar ? ( -
+
+
{!isUserTeamsLoading && ['mappingIsComplete', 'selectAnotherProject'].includes(taskAction) && ( diff --git a/frontend/src/views/project.js b/frontend/src/views/project.js index 3150b8550..8dac71c57 100644 --- a/frontend/src/views/project.js +++ b/frontend/src/views/project.js @@ -298,6 +298,7 @@ export const ProjectDetailPage = () => { } return ( +