Skip to content

Commit

Permalink
SW-6182 Show planting site country in admin UI (#2558)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgrimm authored Nov 1, 2024
1 parent c8fd05f commit 44f4de8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.terraformation.backend.customer.db.OrganizationStore
import com.terraformation.backend.db.SRID
import com.terraformation.backend.db.default_schema.GlobalRole
import com.terraformation.backend.db.default_schema.OrganizationId
import com.terraformation.backend.db.default_schema.tables.daos.CountriesDao
import com.terraformation.backend.db.default_schema.tables.daos.OrganizationsDao
import com.terraformation.backend.db.tracking.MonitoringPlotId
import com.terraformation.backend.db.tracking.ObservationId
Expand Down Expand Up @@ -66,6 +67,7 @@ import org.springframework.web.servlet.mvc.support.RedirectAttributes
@Validated
class AdminPlantingSitesController(
private val clock: DatabaseBackedClock,
private val countriesDao: CountriesDao,
private val mapboxService: MapboxService,
private val objectMapper: ObjectMapper,
private val observationService: ObservationService,
Expand All @@ -80,6 +82,7 @@ class AdminPlantingSitesController(
@GetMapping("/plantingSite/{plantingSiteId}")
fun getPlantingSite(@PathVariable plantingSiteId: PlantingSiteId, model: Model): String {
val plantingSite = plantingSiteStore.fetchSiteById(plantingSiteId, PlantingSiteDepth.Subzone)
val country = plantingSite.countryCode?.let { countriesDao.fetchOneByCode(it) }
val plotCounts = plantingSiteStore.countMonitoringPlots(plantingSiteId)
val plantCounts = plantingSiteStore.countReportedPlantsInSubzones(plantingSiteId)
val organization = organizationStore.fetchOneById(plantingSite.organizationId)
Expand Down Expand Up @@ -144,6 +147,7 @@ class AdminPlantingSitesController(
currentUser().canMovePlantingSiteToAnyOrg(plantingSiteId),
)
model.addAttribute("canUpdatePlantingSite", currentUser().canUpdatePlantingSite(plantingSiteId))
model.addAttribute("country", country)
model.addAttribute("futurePlantingSeasons", futurePlantingSeasons)
model.addAttribute("months", months)
model.addAttribute("nextObservationEnd", nextObservationEnd)
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/templates/admin/plantingSite.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@

<h2 th:text="|Planting Site ${site.name} (${site.id})|">Planting Site Name (123)</h2>

<p th:if="${country} != null" th:text="|Country: ${country.name} (${country.code})|"/>

<p>
Outplantings reported:
<th:block th:text="${reportedPlants.totalPlants}">123</th:block>
Expand Down

0 comments on commit 44f4de8

Please sign in to comment.