stats4sd / aec_portfolio

A proof of concept for the AEC Consortium Project Management / Assessment System
GNU General Public License v3.0
0 stars 0 forks source link

Cannot change code after project is created #3

Closed dave-mills closed 1 year ago

dave-mills commented 2 years ago
  1. Once the whole assessment is done, if I go 'edit project', and then change the name of the project, and try to save, tool returns an error "code already taken" - does this mean that it's not possible to change the name of a project in hindsight? Would need fixing.
dave-mills commented 2 years ago

Need to add exception into FormRequest to ignore the current value

dave-mills commented 2 years ago

@ciara-mc - at the moment, the project code's validation is just using the default 'unique' rule, which is causing the issue. This rule checks the whole database for the value to be saved, and then returns a validation error because it finds an existing entry (the entry being edited).

The current rule also checks for uniqueness across the whole platform, not just within the current organisation, which is incorrect. So I think the way to fix the bug is to update the platform to use a custom rule that does what we need. The FAW data platform does this exact thing with 'teams' and 'sites' instead of 'organisations' and 'projects':

https://github.com/stats4sd/faw-data-platform/blob/dev/app/Rules/UniqueSiteCode.php

Info on custom validation rules: https://laravel.com/docs/9.x/validation#custom-validation-rules