| 220 | |
| 221 | |
| 222 | class StorageProjectRemoveForm(StarletteForm): |
| 223 | association_id = HiddenField(_l("Association ID"), validators=[DataRequired()]) |
| 224 | confirm = StringField(_l("Confirmation"), validators=[DataRequired()]) |
| 225 | |
| 226 | def __init__( |
| 227 | self, request: Request, *args, associations: list["StorageProject"], **kwargs |
| 228 | ): |
| 229 | super().__init__(request, *args, **kwargs) |
| 230 | self.associations = associations |
| 231 | self._associations_by_id = { |
| 232 | str(association.id): association for association in associations |
| 233 | } |
| 234 | self.association = None |
| 235 | |
| 236 | def validate_association_id(self, field): |
| 237 | association = self._associations_by_id.get(field.data) |
| 238 | if not association: |
| 239 | raise ValidationError(_("Association not found.")) |
| 240 | self.association = association |
| 241 | |
| 242 | def validate_confirm(self, field): |
| 243 | if not self.association: |
| 244 | return |
| 245 | project_name = self.association.project.name if self.association.project else "" |
| 246 | if field.data != project_name: |
| 247 | raise ValidationError(_("Project name confirmation did not match.")) |
| 248 | |
| 249 | |
| 250 | class StorageQueryForm(StarletteForm): |
nothing calls this directly
no outgoing calls
no test coverage detected