(self, field)
| 194 | self._selected_project = project |
| 195 | |
| 196 | def validate_environment_ids(self, field): |
| 197 | if not self._selected_project and self.project_id.data: |
| 198 | self._selected_project = self._projects_by_id.get(self.project_id.data) |
| 199 | if not self._selected_project: |
| 200 | return |
| 201 | environment_ids = self._parse_environment_ids(field.data) |
| 202 | if environment_ids is None: |
| 203 | raise ValidationError(_("Invalid environment selection.")) |
| 204 | environment_ids = list(dict.fromkeys(environment_ids)) |
| 205 | field.data = environment_ids |
| 206 | for environment_id in environment_ids: |
| 207 | if not self._selected_project.get_environment_by_id(environment_id): |
| 208 | raise ValidationError(_("Environment not found.")) |
| 209 | association_id = self.association_id.data |
| 210 | for association in self.associations: |
| 211 | if association.project_id != self.project_id.data: |
| 212 | continue |
| 213 | if association.storage_id != self.storage_id.data: |
| 214 | continue |
| 215 | if association_id and str(association.id) == association_id: |
| 216 | continue |
| 217 | raise ValidationError( |
| 218 | _("This project is already connected to this storage.") |
| 219 | ) |
| 220 | |
| 221 | |
| 222 | class StorageProjectRemoveForm(StarletteForm): |
nothing calls this directly
no test coverage detected