Don't permit project rights to be created backwards

If the min value is larger than the max value, flip the order
around the other way.  Its likely the user mixed up the fields
in the UI.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-03-26 17:26:52 -07:00
parent 7ea8109ce4
commit 65f147d95d
2 changed files with 14 additions and 1 deletions

View File

@@ -211,8 +211,17 @@ public class ProjectAdminServiceImpl extends BaseServiceImplementation
public void addRight(final Project.Id projectId,
final ApprovalCategory.Id categoryId, final String groupName,
final short min, final short max,
final short amin, final short amax,
final AsyncCallback<ProjectDetail> callback) {
final short min, max;
if (amin <= amax) {
min = amin;
max = amax;
} else {
min = amax;
max = amin;
}
run(callback, new Action<ProjectDetail>() {
public ProjectDetail run(ReviewDb db) throws OrmException, Failure {
assertAmProjectOwner(db, projectId);

View File

@@ -20,4 +20,8 @@ SET max_value = 2
WHERE max_value = 1
AND category_id = 'pTAG';
UPDATE project_rights
SET min_value = max_value, max_value = min_value
WHERE max_value < min_value;
UPDATE schema_version SET version_nbr = 8;