|
27 | 27 | CEASeverDemoAuthCheck
|
28 | 28 | from cea.interfaces.dashboard.lib.database.session import SessionDep
|
29 | 29 | from cea.interfaces.dashboard.lib.logs import getCEAServerLogger
|
30 |
| -from cea.interfaces.dashboard.settings import LimitSettings |
| 30 | +from cea.interfaces.dashboard.settings import LimitSettings, get_settings |
31 | 31 | from cea.interfaces.dashboard.utils import secure_path, OutsideProjectRootError
|
32 | 32 | from cea.utilities.dbf import dbf_to_dataframe
|
33 | 33 | from cea.utilities.standardize_coordinates import get_geographic_coordinate_system, raster_to_WSG_and_UTM
|
@@ -249,13 +249,15 @@ async def create_new_project(project_root: CEAProjectRoot, new_project: NewProje
|
249 | 249 | """
|
250 | 250 | Create new project folder
|
251 | 251 | """
|
| 252 | + settings = get_settings() |
252 | 253 | limit_settings = LimitSettings()
|
253 |
| - num_projects = len(await get_project_choices(project_root)) |
254 |
| - if limit_settings.num_projects is not None and limit_settings.num_projects <= num_projects: |
255 |
| - raise HTTPException( |
256 |
| - status_code=status.HTTP_400_BAD_REQUEST, |
257 |
| - detail=f"Maximum number of projects reached ({limit_settings.num_projects}). Number of projects found: {num_projects}", |
258 |
| - ) |
| 254 | + if not settings.local: |
| 255 | + num_projects = len(await get_project_choices(project_root)) |
| 256 | + if limit_settings.num_projects is not None and limit_settings.num_projects <= num_projects: |
| 257 | + raise HTTPException( |
| 258 | + status_code=status.HTTP_400_BAD_REQUEST, |
| 259 | + detail=f"Maximum number of projects reached ({limit_settings.num_projects}). Number of projects found: {num_projects}", |
| 260 | + ) |
259 | 261 |
|
260 | 262 | if new_project.project_root is None and project_root is None:
|
261 | 263 | raise HTTPException(
|
@@ -350,13 +352,15 @@ async def create_new_scenario_v2(project_root: CEAProjectRoot, scenario_form: An
|
350 | 352 | detail=str(e),
|
351 | 353 | )
|
352 | 354 |
|
| 355 | + settings = get_settings() |
353 | 356 | limit_settings = LimitSettings()
|
354 |
| - num_scenarios = len(cea.config.get_scenarios_list(cea_project)) |
355 |
| - if limit_settings.num_scenarios is not None and limit_settings.num_scenarios <= num_scenarios: |
356 |
| - raise HTTPException( |
357 |
| - status_code=status.HTTP_400_BAD_REQUEST, |
358 |
| - detail=f"Maximum number of scenarios reached ({limit_settings.num_scenarios}). Number of scenarios found: {num_scenarios}", |
359 |
| - ) |
| 357 | + if not settings.local: |
| 358 | + num_scenarios = len(cea.config.get_scenarios_list(cea_project)) |
| 359 | + if limit_settings.num_scenarios is not None and limit_settings.num_scenarios <= num_scenarios: |
| 360 | + raise HTTPException( |
| 361 | + status_code=status.HTTP_400_BAD_REQUEST, |
| 362 | + detail=f"Maximum number of scenarios reached ({limit_settings.num_scenarios}). Number of scenarios found: {num_scenarios}", |
| 363 | + ) |
360 | 364 |
|
361 | 365 | scenario_name = os.path.normpath(scenario_form.scenario_name)
|
362 | 366 | if scenario_name == "." or scenario_name == ".." or os.path.basename(scenario_name) != scenario_name:
|
@@ -388,13 +392,13 @@ async def create_zone(scenario_form, locator):
|
388 | 392 | # Ensure that zone exists
|
389 | 393 | zone_df = geopandas.read_file(locator.get_zone_geometry())
|
390 | 394 |
|
391 |
| - limit_settings = LimitSettings() |
392 |
| - num_buildings = len(zone_df) |
393 |
| - if limit_settings.num_buildings is not None and limit_settings.num_buildings <= num_buildings: |
394 |
| - raise HTTPException( |
395 |
| - status_code=status.HTTP_400_BAD_REQUEST, |
396 |
| - detail=f"Maximum number of buildings reached ({limit_settings.num_buildings}). Number of buildings found: {num_buildings}", |
397 |
| - ) |
| 395 | + if not settings.local: |
| 396 | + num_buildings = len(zone_df) |
| 397 | + if limit_settings.num_buildings is not None and limit_settings.num_buildings <= num_buildings: |
| 398 | + raise HTTPException( |
| 399 | + status_code=status.HTTP_400_BAD_REQUEST, |
| 400 | + detail=f"Maximum number of buildings reached ({limit_settings.num_buildings}). Number of buildings found: {num_buildings}", |
| 401 | + ) |
398 | 402 |
|
399 | 403 | # Copy zone from user-input
|
400 | 404 | else:
|
|
0 commit comments