From 86af6e40ca2b0f4adf7bf6d919018e1ef38ba5e5 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 11 Jun 2024 09:27:22 -0500 Subject: [PATCH] CLDR-16835 ddl phase - back end changes for separate ddl phase - back end changes supporting a separate ddl phase --- .../java/org/unicode/cldr/web/DataPage.java | 3 +- .../java/org/unicode/cldr/web/SurveyAjax.java | 2 +- .../java/org/unicode/cldr/web/SurveyMain.java | 28 +++++++++++++++---- .../org/unicode/cldr/web/UserRegistry.java | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DataPage.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DataPage.java index 767ecee8cba..232d76d2c51 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DataPage.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/DataPage.java @@ -988,8 +988,7 @@ public Map getNonDistinguishingAttributes() { */ public StatusAction getStatusAction(InputMethod inputMethod) { // null because this is for display. - return SurveyMain.phase() - .getCPhase() + return SurveyMain.getCPhase(locale) .getShowRowAction(this, inputMethod, getPathHeader(), userForVotelist); } diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java index 78b3bb218ba..720a3e85bef 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java @@ -2658,7 +2658,7 @@ public static void handleBulkSubmit( final List checkResult = new ArrayList<>(); TestCache.TestResultBundle cc = stf.getTestResult(loc, DataPage.getOptions(cs, loc)); UserRegistry.User u = theirU; - CheckCLDR.Phase cPhase = CLDRConfig.getInstance().getPhase(); + CheckCLDR.Phase cPhase = SurveyMain.getCPhase(loc); Set allValidPaths = stf.getPathsForFile(loc); CLDRProgressTask progress = sm.openProgress("Bulk:" + loc, all.size()); CLDRFile cldrUnresolved = cf.getUnresolved(); diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java index 8c85cd52bf1..b633a42f6b5 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyMain.java @@ -65,6 +65,7 @@ import org.unicode.cldr.test.CheckCLDR; import org.unicode.cldr.test.ExampleGenerator; import org.unicode.cldr.test.HelpMessages; +import org.unicode.cldr.test.SubmissionLocales; import org.unicode.cldr.util.CLDRCacheDir; import org.unicode.cldr.util.CLDRConfig; import org.unicode.cldr.util.CLDRConfigImpl; @@ -2078,9 +2079,9 @@ public String getLocaleLink(WebContext ctx, CLDRLocale locale, String n) { if (canModify) { rv = rv + (modifyThing(ctx)); int odisp; - if ((SurveyMain.phase() == Phase.VETTING - || SurveyMain.phase() == Phase.SUBMIT - || isPhaseVettingClosed()) + if ((SurveyMain.phase(locale) == Phase.VETTING + || SurveyMain.phase(locale) == Phase.SUBMIT + || isPhaseVettingClosed(locale)) && ((odisp = DisputePageManager.getOrgDisputeCount(ctx)) > 0)) { rv = rv + ctx.iconHtml("disp", "(" + odisp + " org disputes)"); } @@ -2827,7 +2828,11 @@ private void doStartup() { String ddlPhaseString = survprops.getProperty("CLDR_DDL_PHASE", null); Phase ddlPhase = null; try { - if (ddlPhaseString != null) { + if (ddlPhaseString != null && !ddlPhaseString.isEmpty()) { + if (currentPhase == Phase.READONLY) { + busted( + "Error: Cannot have a CLDR_DDL_PHASE when CLDR_PHASE=READONLY. Remove the CLDR_DDL_PHASE."); + } ddlPhase = (Phase.valueOf(ddlPhaseString)); } } catch (IllegalArgumentException iae) { @@ -3569,8 +3574,8 @@ public static String localhost() { // ============= Following have to do with phases - public static boolean isPhaseVettingClosed() { - return phase() == Phase.VETTING_CLOSED; + public static boolean isPhaseVettingClosed(CLDRLocale locale) { + return phase(locale) == Phase.VETTING_CLOSED; } public static boolean isPhaseReadonly() { @@ -3585,6 +3590,17 @@ public static Phase phase() { return currentPhase; } + public static Phase phase(CLDRLocale locale) { + return (SubmissionLocales.isTcLocale(locale) ? phase() : getDDLPhase()); + } + + /** + * @returns the current phase for the locale. This is the preferred API. + */ + public static CheckCLDR.Phase getCPhase(CLDRLocale loc) { + return phase(loc).getCPhase(); + } + public static Phase getDDLPhase() { return currentDdlPhase; } diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java index d7a2f67ef45..f4f56b5e9a4 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java @@ -1978,7 +1978,7 @@ public static ModifyDenial userCanModifyLocaleWhy(User u, CLDRLocale locale) { if (userIsAdmin(u) || userIsTC(u)) return null; // Otherwise, if closed, deny - if (SurveyMain.isPhaseVettingClosed()) return ModifyDenial.DENY_PHASE_CLOSED; + if (SurveyMain.isPhaseVettingClosed(locale)) return ModifyDenial.DENY_PHASE_CLOSED; if (SurveyMain.isPhaseReadonly()) return ModifyDenial.DENY_PHASE_READONLY; return null;