Skip to content

Commit

Permalink
some refactorings and adding treatment rank to all features
Browse files Browse the repository at this point in the history
  • Loading branch information
george-silva committed Dec 23, 2024
1 parent 4c1ddb1 commit 4b79279
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
18 changes: 9 additions & 9 deletions src/planscape/collaboration/services.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from typing import Any, List
from collaboration.models import Permissions, Role, UserObjectRole
from django.db import transaction
from django.db.models import Model
from django.contrib.contenttypes.models import ContentType
import logging

from django.contrib.auth import get_user_model
from collaboration.permissions import CollaboratorPermission
from collaboration.tasks import send_invitation
from django.contrib.contenttypes.models import ContentType
from django.db import transaction
from django.db.models import Model, QuerySet
from planning.models import PlanningArea
import logging

from collaboration.models import Permissions, Role, UserObjectRole
from collaboration.permissions import CollaboratorPermission
from collaboration.tasks import send_invitation
from planscape.exceptions import InvalidOwnership

User = get_user_model()
Expand Down Expand Up @@ -105,7 +105,7 @@ def create_invite(


@transaction.atomic()
def link_invites(user) -> List[UserObjectRole]:
def link_invites(user) -> "QuerySet[UserObjectRole]":
"""Links all invites to a fresh created user.
Returns all the invitations that were linked.
"""
Expand Down
1 change: 0 additions & 1 deletion src/planscape/datasets/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django_filters import rest_framework as filters
from django.db.models import QuerySet
from rest_framework.request import Request
from impacts.models import TreatmentPlan, TreatmentPlanStatus
from datasets.models import DataLayer, Dataset


Expand Down
22 changes: 12 additions & 10 deletions src/planscape/planning/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,23 @@
import math
import os
import zipfile
import fiona

from datetime import date, time, datetime
from datetime import date, datetime, time
from functools import partial
from pathlib import Path
from typing import Any, Dict, Optional, Tuple, Type, Union
from typing import Any, Dict, Optional, Tuple, Type

import fiona
from actstream import action
from collaboration.permissions import PlanningAreaPermission, ScenarioPermission
from django.conf import settings
from django.contrib.gis.geos import GEOSGeometry, MultiPolygon, Polygon
from django.contrib.gis.db.models import Union as UnionOp
from django.contrib.gis.geos import GEOSGeometry, MultiPolygon, Polygon
from django.db import transaction
from django.utils.timezone import now
from fiona.crs import from_epsg
from collaboration.permissions import PlanningAreaPermission, ScenarioPermission
from planscape.typing import TLooseGeom, TUser
from stands.models import Stand, StandSizeChoices, area_from_size
from utils.geometry import to_multi

from planning.geometry import coerce_geojson
from planning.models import (
PlanningArea,
Expand All @@ -30,9 +33,7 @@
)
from planning.tasks import async_forsys_run
from planscape.exceptions import InvalidGeometry
from stands.models import Stand, StandSizeChoices, area_from_size
from utils.geometry import to_multi
from actstream import action
from planscape.typing import TLooseGeom, TUser

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -206,6 +207,7 @@ def create_scenario_from_upload(validated_data, user) -> Scenario:
)
f.setdefault("properties", {})
f["properties"]["project_id"] = new_feature.pk
f["properties"]["treatment_rank"] = idx

# Store geometry with added properties into ScenarioResult.result
ScenarioResult.objects.create(
Expand Down

0 comments on commit 4b79279

Please sign in to comment.