From 8add514d0bbe0d3fd23947b8b689fcbe214a92c9 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Tue, 11 Jun 2024 10:58:37 -0500 Subject: [PATCH] CLDR-16835 options to announce to non-tc locs, non-tc orgs --- tools/cldr-apps/js/src/views/AnnounceForm.vue | 9 ++++++++- tools/cldr-apps/js/src/views/AnnouncePost.vue | 9 ++++++--- .../org/unicode/cldr/web/AnnouncementData.java | 17 +++++++++++++++-- .../org/unicode/cldr/web/api/Announcements.java | 7 +++++-- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/tools/cldr-apps/js/src/views/AnnounceForm.vue b/tools/cldr-apps/js/src/views/AnnounceForm.vue index 2a49e0a0da8..e129121a27e 100644 --- a/tools/cldr-apps/js/src/views/AnnounceForm.vue +++ b/tools/cldr-apps/js/src/views/AnnounceForm.vue @@ -16,6 +16,9 @@ Mine TC Orgs + Non-TC Orgs All @@ -42,7 +45,7 @@ @@ -158,6 +161,8 @@ export default defineComponent({ return "all organizations"; case "TC": return "TC organizations"; + case "NonTC": + return "Non-TC organizations"; case "Mine": return "your organization only"; default: @@ -166,12 +171,14 @@ export default defineComponent({ }, describeLocs() { + if (this.formState.locs === "!") return "Non-TC locales"; return this.formState.locs === "" || this.formState.locs === "*" ? "all locales" : "the following locale(s): " + this.formState.locs; }, validateLocales() { + if (this.formState.locs === "!") return; cldrAnnounce.combineAndValidateLocales( this.formState.locs, this.updateValidatedLocales diff --git a/tools/cldr-apps/js/src/views/AnnouncePost.vue b/tools/cldr-apps/js/src/views/AnnouncePost.vue index 4f02d270ced..bffb6430f55 100644 --- a/tools/cldr-apps/js/src/views/AnnouncePost.vue +++ b/tools/cldr-apps/js/src/views/AnnouncePost.vue @@ -12,9 +12,7 @@
To: {{ announcement.audience }} • {{ "Organization(s): " + announcement.orgs }} • - {{ - announcement.locs ? "Locale(s): " + announcement.locs : "All locales" - }} + {{ localeText }}
{{ announcement.subject }} @@ -50,6 +48,11 @@ export default { .replaceAll("\n", "\n
\n") .replaceAll(/(http\S+)/g, "$1"); }, + localeText() { + if (!this.announcement.locs) return "All locales"; + if (this.announcement.locs === "!") return "DDL Locales"; + return "Locale(s): " + this.announcement.locs; + }, }, }; diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/AnnouncementData.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/AnnouncementData.java index 061a74b921b..1682fae02ab 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/AnnouncementData.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/AnnouncementData.java @@ -2,10 +2,11 @@ import com.ibm.icu.dev.util.ElapsedTimer; import java.sql.*; -import java.sql.Timestamp; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.stream.Collectors; +import org.unicode.cldr.test.SubmissionLocales; import org.unicode.cldr.util.*; import org.unicode.cldr.web.api.Announcements; @@ -148,6 +149,7 @@ private static void emailNotify( } String subject = "CLDR Survey Tool announcement: " + request.subject; String locs = (request.locs == null || request.locs.isEmpty()) ? "All" : request.locs; + if (locs.equals(Announcements.LOCS_NON_TC)) locs = "(DDL Locales)"; String body = "From: " + poster.name @@ -223,7 +225,16 @@ private static void addRecipientIfPasses( AnnouncementFilter aFilter = new AnnouncementFilter(user); Announcements.Announcement a = new Announcements.Announcement(0, poster.id, null, null, null); - a.setFilters(request.locs, request.orgs, request.audience); + String filterLocs = request.locs; + if (filterLocs != null && filterLocs.equals(Announcements.LOCS_NON_TC)) { + // expand the filter + filterLocs = + SurveyMain.getLocalesSet().stream() + .filter(loc -> !SubmissionLocales.isTcLocale(loc)) + .map(l -> l.getBaseName()) + .collect(Collectors.joining(" ")); + } + a.setFilters(filterLocs, request.orgs, request.audience); if (aFilter.passes(a)) { logger.fine("In AnnouncementData.addRecipientIfPasses, adding recipient: " + user.id); recipients.add(user.id); @@ -470,6 +481,8 @@ private boolean matchOrg(String orgs, int posterId) { return true; } else if (Announcements.ORGS_TC.equals(orgs)) { return user.getOrganization().isTCOrg(); + } else if (Announcements.ORGS_NON_TC.equals(orgs)) { + return !user.getOrganization().isTCOrg(); } else if (Announcements.ORGS_MINE.equals(orgs)) { UserRegistry.User posterUser = CookieSession.sm.reg.getInfo(posterId); return posterUser != null && posterUser.isSameOrg(user); diff --git a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/Announcements.java b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/Announcements.java index 1688aefb68e..6d2af1b6713 100644 --- a/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/Announcements.java +++ b/tools/cldr-apps/src/main/java/org/unicode/cldr/web/api/Announcements.java @@ -26,14 +26,17 @@ public class Announcements { public static final String ORGS_MINE = "Mine"; public static final String ORGS_TC = "TC"; + public static final String ORGS_NON_TC = "NonTC"; public static final String ORGS_ALL = "All"; + public static final String LOCS_NON_TC = "!"; + private static final Set validAudiences = new HashSet<>( Arrays.asList( AUDIENCE_TC, AUDIENCE_MANAGERS, AUDIENCE_VETTERS, AUDIENCE_EVERYONE)); private static final Set validOrgs = - new HashSet<>(Arrays.asList(ORGS_MINE, ORGS_TC, ORGS_ALL)); + new HashSet<>(Arrays.asList(ORGS_MINE, ORGS_NON_TC, ORGS_TC, ORGS_ALL)); @GET @Produces(MediaType.APPLICATION_JSON) @@ -250,7 +253,7 @@ public boolean isValid() { } public void normalize() { - if (locs != null) { + if (locs != null && !locs.equals(LOCS_NON_TC)) { String normalized = LocaleNormalizer.normalizeQuietly(locs); LocaleSet locSet = LocaleNormalizer.setFromStringQuietly(normalized, null); LocaleSet langSet = locSet.combineRegionalVariants();