Skip to content

Commit

Permalink
patch: add custom url path for observation image view set (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinashechiraya authored Oct 7, 2024
1 parent 7fd82aa commit b99cd01
Showing 1 changed file with 76 additions and 63 deletions.
139 changes: 76 additions & 63 deletions django_project/monitor/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.urls import path, include
from rest_framework.routers import DefaultRouter

# Observation-related views
from monitor.observation_views import (
ObservationListCreateView,
ObservationRetrieveUpdateDeleteView,
Expand All @@ -12,6 +13,8 @@
upload_pest_image,
delete_pest_image
)

# Site-related views
from monitor.site_views import (
AssessmentListCreateView,
AssessmentRetrieveUpdateDestroyView,
Expand All @@ -22,6 +25,8 @@
SaveObservationImagesView,
SitesWithObservationsView
)

# Other general views
from monitor.views import (
index,
wms_get_feature_info,
Expand All @@ -46,33 +51,24 @@

# URL patterns for the miniSASS app
urlpatterns = [
path('', index, name='monitor_index'),
path('wms/~<str:wms_url>~<str:wms_params>', wms_get_feature_info),
# Observation Image URLs
path(
'sites/is-land/<str:lat>/<str:long>/',
CheckSiteIsLand.as_view(),
name='check-coordinate-is-land'
'observations/<int:observation_pk>/images/',
ObservationImageViewSet.as_view({'get': 'list'}),
name='observation-image-view-list'
),
path('sites/<str:x>/<str:y>/<str:d>/', get_sites),
path('closest_site/<str:x>/<str:y>/<str:d>/', get_closest_site),
path('unique/<str:field>/', get_unique),
path('legacy/observation/<int:obs_id>/', zoom_observation),
path('legacy/observations/<int:site_id>/', get_observations),
path('observations/download/<int:site_id>/', download_observations),
path('observations/download/filtered/~<str:filter_string>',
download_observations_filtered),
path(
'observations/download-v2/<int:site_id>/',
DownloadObservations.as_view(),
name='download-observations'
'upload-pest-images/',
upload_pest_image,
name='upload-pest-images'
),
path(
'observations/download/filtered/~<str:filter_string>',
download_observations_filtered
'observation-images/<int:observation_pk>/delete/<int:pk>/',
delete_pest_image,
name='remove-pest-image'
),
path('schools/', get_schools),
path('<int:monitor_id>/', detail, name='monitor_detail'),

# General observation URLs
path(
'observations/',
ObservationListCreateView.as_view(),
Expand All @@ -83,84 +79,101 @@
ObservationRetrieveUpdateDeleteView.as_view(),
name='observation-retrieve-update-delete'
),

path(
'sites/',
SitesListCreateView.as_view(),
name='sites-list-create'
'observations/recent-observations/',
RecentObservationListView.as_view(),
name='recent-observation-list'
),
path(
'sites/<int:pk>/',
SiteRetrieveUpdateDestroyView.as_view(),
name='site-retrieve-update-destroy'
'observations/observation-details/<int:pk>/',
ObservationRetrieveView.as_view(),
name='observation-details'
),
path(
'observations-create/',
create_observations,
name='create_observations'
),
path(
'upload-pest-images/',
upload_pest_image,
name='upload-pest-images'
'observations/download/<int:site_id>/',
download_observations
),
path(
'observation-images/<int:observation_pk>/delete/<int:pk>/',
delete_pest_image,
name='remove-pest-image'
'observations/download/filtered/~<str:filter_string>',
download_observations_filtered
),

path(
'observations/recent-observations/',
RecentObservationListView.as_view(),
name='recent-observation-list'
'observations/download-v2/<int:site_id>/',
DownloadObservations.as_view(),
name='download-observations'
),

path(
'observations/observation-details/<int:pk>/',
ObservationRetrieveView.as_view(),
name='observation-details'
'observations/by-site/<int:site_id>/',
get_observations_by_site,
name='observations-by-site'
),

path(
'site-observations/<latitude>/<longitude>/',
SiteObservationsByLocation.as_view(),
name='site-observations'
'observations/<int:observationId>/save-images/',
SaveObservationImagesView.as_view(),
name='save_observation_images'
),

path(
'observations/observation-details/<int:observation_pk>/',
'observations/observation-details/<int:observation_pk>/',
include(router.urls)
),

# Site-related URLs
path(
'site-assessments/',
AssessmentListCreateView.as_view(),
name='assessment-list-create'
),
path(
'site-assessments/<int:pk>/',
AssessmentRetrieveUpdateDestroyView.as_view(),
name='assessment-retrieve-update-destroy'
'sites/',
SitesListCreateView.as_view(),
name='sites-list-create'
),
path(
'observations/by-site/<int:site_id>/',
get_observations_by_site,
name='observations-by-site'
'sites/<int:pk>/',
SiteRetrieveUpdateDestroyView.as_view(),
name='site-retrieve-update-destroy'
),
path(
'sites/<int:site_id>/save-images/',
SaveSiteImagesView.as_view(),
name='save_site_images'
),
path(
'observations/<int:observationId>/save-images/',
SaveObservationImagesView.as_view(),
name='save_observation_images'
),
path(
'sites-with-observations/',
SitesWithObservationsView.as_view(),
name='sites-with-observations'
),
path(
'site-observations/<latitude>/<longitude>/',
SiteObservationsByLocation.as_view(),
name='site-observations'
),

# Site assessment URLs
path(
'site-assessments/',
AssessmentListCreateView.as_view(),
name='assessment-list-create'
),
path(
'site-assessments/<int:pk>/',
AssessmentRetrieveUpdateDestroyView.as_view(),
name='assessment-retrieve-update-destroy'
),

# Other functionality
path('', index, name='monitor_index'),
path('wms/~<str:wms_url>~<str:wms_params>', wms_get_feature_info),
path(
'sites/is-land/<str:lat>/<str:long>/',
CheckSiteIsLand.as_view(),
name='check-coordinate-is-land'
),
path('sites/<str:x>/<str:y>/<str:d>/', get_sites),
path('closest_site/<str:x>/<str:y>/<str:d>/', get_closest_site),
path('unique/<str:field>/', get_unique),
path('legacy/observation/<int:obs_id>/', zoom_observation),
path('legacy/observations/<int:site_id>/', get_observations),
path('schools/', get_schools),
path('<int:monitor_id>/', detail, name='monitor_detail'),
]

0 comments on commit b99cd01

Please sign in to comment.