| 133 | environment_ids = StringField(_l("Environments"), validators=[Optional()]) |
| 134 | |
| 135 | def __init__( |
| 136 | self, |
| 137 | request: Request, |
| 138 | *args, |
| 139 | storage: Storage | None = None, |
| 140 | storages: list[Storage] | None = None, |
| 141 | projects: list[Project], |
| 142 | associations: list["StorageProject"], |
| 143 | **kwargs, |
| 144 | ): |
| 145 | super().__init__(request, *args, **kwargs) |
| 146 | self.storage = storage |
| 147 | self.storages = storages or [] |
| 148 | self.projects = projects |
| 149 | self.associations = associations |
| 150 | self._projects_by_id = {project.id: project for project in projects} |
| 151 | self._storages_by_id = {storage.id: storage for storage in self.storages} |
| 152 | self._associations_by_id = { |
| 153 | str(association.id): association for association in associations |
| 154 | } |
| 155 | self._selected_project = None |
| 156 | self._selected_storage = None |
| 157 | self.association = None |
| 158 | if self.environment_ids.data in (None, ""): |
| 159 | self.environment_ids.data = [] |
| 160 | |
| 161 | def _parse_environment_ids(self, value): |
| 162 | return _parse_environment_ids(value) |