Skip to content

Commit

Permalink
style: Lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
annehaley committed Sep 25, 2024
1 parent 7372b16 commit 10330c3
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 22 deletions.
5 changes: 4 additions & 1 deletion uvdat/core/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class Project(models.Model):

def readable_by(self, user):
return (
user.is_superuser or user == self.owner or user in self.collaborators.all() or user in self.followers.all()
user.is_superuser
or user == self.owner
or user in self.collaborators.all()
or user in self.followers.all()
)

def editable_by(self, user):
Expand Down
4 changes: 2 additions & 2 deletions uvdat/core/rest/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from rest_framework.viewsets import ModelViewSet

from uvdat.core.models import Chart
from uvdat.core.rest.serializers import ChartSerializer
from uvdat.core.rest.filter import AccessControl
from uvdat.core.rest.serializers import ChartSerializer


class ChartViewSet(ModelViewSet):
queryset = Chart.objects.all()
serializer_class = ChartSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'

def validate_editable(self, chart, func, *args, **kwargs):
if chart.editable:
Expand Down
8 changes: 4 additions & 4 deletions uvdat/core/rest/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
from rest_framework.viewsets import ModelViewSet

from uvdat.core.models import Dataset, NetworkEdge, NetworkNode
from uvdat.core.rest.filter import AccessControl
from uvdat.core.rest.serializers import (
DatasetSerializer,
RasterMapLayerSerializer,
VectorMapLayerSerializer,
NetworkEdgeSerializer,
NetworkNodeSerializer,
RasterMapLayerSerializer,
VectorMapLayerSerializer,
)
from uvdat.core.rest.filter import AccessControl
from uvdat.core.tasks.chart import add_gcc_chart_datum


class DatasetViewSet(ModelViewSet):
queryset = Dataset.objects.all()
serializer_class = DatasetSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'

@action(detail=True, methods=['get'])
def map_layers(self, request, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions uvdat/core/rest/file_item.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from rest_framework.viewsets import ModelViewSet

from uvdat.core.models import FileItem
from uvdat.core.rest.serializers import FileItemSerializer
from uvdat.core.rest.filter import AccessControl
from uvdat.core.rest.serializers import FileItemSerializer


class FileItemViewSet(ModelViewSet):
queryset = FileItem.objects.all()
serializer_class = FileItemSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'
1 change: 1 addition & 0 deletions uvdat/core/rest/filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from rest_framework.filters import BaseFilterBackend


class AccessControl(BaseFilterBackend):
def filter_queryset(self, request, queryset, view):
project_id = request.query_params.get('project')
Expand Down
4 changes: 2 additions & 2 deletions uvdat/core/rest/map_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class RasterMapLayerViewSet(ModelViewSet, LargeImageFileDetailMixin):
queryset = RasterMapLayer.objects.select_related('dataset').all()
serializer_class = RasterMapLayerSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'
FILE_FIELD_NAME = 'cloud_optimized_geotiff'

@action(
Expand All @@ -93,7 +93,7 @@ class VectorMapLayerViewSet(ModelViewSet):
queryset = VectorMapLayer.objects.select_related('dataset').all()
serializer_class = VectorMapLayerSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'

def retrieve(self, request, *args, **kwargs):
instance = self.get_object()
Expand Down
6 changes: 3 additions & 3 deletions uvdat/core/rest/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ class NetworkViewSet(ModelViewSet):
queryset = Network.objects.all()
serializer_class = NetworkSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'


class NetworkNodeViewSet(ModelViewSet):
queryset = NetworkNode.objects.all()
serializer_class = NetworkNodeSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'


class NetworkEdgeViewSet(ModelViewSet):
queryset = NetworkEdge.objects.all()
serializer_class = NetworkEdgeSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'
4 changes: 2 additions & 2 deletions uvdat/core/rest/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
from rest_framework.viewsets import ModelViewSet

from uvdat.core.models import Project
from uvdat.core.rest.filter import AccessControl
from uvdat.core.rest.serializers import ProjectSerializer
from uvdat.core.tasks.osmnx import load_roads
from uvdat.core.rest.filter import AccessControl


class ProjectViewSet(ModelViewSet):
queryset = Project.objects.all()
serializer_class = ProjectSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'

def perform_create(self, serializer):
serializer.save(owner=self.request.user)
Expand Down
6 changes: 3 additions & 3 deletions uvdat/core/rest/regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from rest_framework.viewsets import ModelViewSet

from uvdat.core.models import DerivedRegion, SourceRegion
from uvdat.core.tasks.regions import DerivedRegionCreationError, create_derived_region
from uvdat.core.rest.filter import AccessControl
from uvdat.core.tasks.regions import DerivedRegionCreationError, create_derived_region

from .serializers import (
DerivedRegionCreationSerializer,
Expand All @@ -21,14 +21,14 @@ class SourceRegionViewSet(ModelViewSet):
queryset = SourceRegion.objects.all()
serializer_class = SourceRegionSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'


class DerivedRegionViewSet(ModelViewSet):
queryset = DerivedRegion.objects.all()
serializer_class = DerivedRegionListSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'

def get_serializer_class(self):
if self.detail:
Expand Down
2 changes: 1 addition & 1 deletion uvdat/core/rest/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_center(self, obj):

def to_internal_value(self, data):
center = data.get('default_map_center')
data = super().to_internal_value(data)
data = super().to_internal_value(data)
if isinstance(center, list):
data['default_map_center'] = Point(center[1], center[0])
return data
Expand Down
2 changes: 1 addition & 1 deletion uvdat/core/rest/simulations.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class SimulationViewSet(ModelViewSet):
queryset = SimulationResult.objects.all()
serializer_class = uvdat_serializers.SimulationResultSerializer
filter_backends = [AccessControl]
lookup_field = "id"
lookup_field = 'id'

@action(
detail=False,
Expand Down
1 change: 0 additions & 1 deletion uvdat/core/rest/user.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json

from django.contrib.auth import logout
from django.contrib.auth.models import User
from django.http import HttpResponse
from rest_framework.decorators import action
Expand Down

0 comments on commit 10330c3

Please sign in to comment.