Skip to content

Commit 76b711c

Browse files
authored
CLDR-17953 Enable TC to generate VXML (#4334)
1 parent dd463ff commit 76b711c

File tree

16 files changed

+77
-67
lines changed

16 files changed

+77
-67
lines changed

tools/cldr-apps/js/src/esm/cldrGenerateVxml.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function canGenerateVxml() {
3939
function viewMounted(setData) {
4040
callbackToSetData = setData;
4141
const perm = cldrStatus.getPermissions();
42-
canGenerate = Boolean(perm?.userIsAdmin);
42+
canGenerate = Boolean(perm?.userCanGenerateVxml);
4343
}
4444

4545
function start() {

tools/cldr-apps/js/src/views/GenerateVxml.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ defineExpose({
8484
</script>
8585

8686
<template>
87-
<div v-if="!hasPermission">Please log in as Admin to use this feature.</div>
87+
<div v-if="!hasPermission">
88+
Please log in as a user with sufficient permissions.
89+
</div>
8890
<div v-else>
8991
<p v-if="status != STATUS.INIT">Generation Status: {{ status }}</p>
9092
<p class="buttons">

tools/cldr-apps/js/src/views/MainMenu.vue

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
<ul>
33
<template v-if="loggedIn">
44
<li v-if="isAdmin"><a href="#admin///">Admin Panel</a></li>
5-
<li v-if="isAdmin"><a href="#generate_vxml///">Generate VXML</a></li>
5+
<li v-if="canGenerateVxml">
6+
<a href="#generate_vxml///">Generate VXML</a>
7+
</li>
68
<!-- My Account only has border-top (section-header) if Admin Panel is shown -->
79
<li v-if="isAdmin" class="section-header">My Account</li>
810
<li v-else>My Account</li>
@@ -144,6 +146,7 @@ export default {
144146
data() {
145147
return {
146148
accountLocked: false,
149+
canGenerateVxml: false,
147150
canImportOldVotes: false,
148151
canListUsers: false,
149152
canMonitorVetting: false,
@@ -168,20 +171,21 @@ export default {
168171
methods: {
169172
initializeData() {
170173
const perm = cldrStatus.getPermissions();
171-
this.accountLocked = perm && perm.userIsLocked;
172-
this.canImportOldVotes = perm && perm.userCanImportOldVotes;
173-
this.canListUsers = !!perm?.userCanListUsers;
174-
this.canMonitorVetting = !!perm?.userCanUseVettingParticipation;
175-
this.canMonitorForum = perm && perm.userCanMonitorForum;
174+
this.accountLocked = Boolean(perm?.userIsLocked);
175+
this.canGenerateVxml = Boolean(perm?.userCanGenerateVxml);
176+
this.canImportOldVotes = Boolean(perm?.userCanImportOldVotes);
177+
this.canListUsers = Boolean(perm?.userCanListUsers);
178+
this.canMonitorVetting = Boolean(perm?.userCanUseVettingParticipation);
179+
this.canMonitorForum = Boolean(perm?.userCanMonitorForum);
176180
// this.canSeeStatistics will be false until there is a new implementation
177-
this.canUseVettingSummary = perm && perm.userCanUseVettingSummary;
178-
this.isAdmin = perm && perm.userIsAdmin;
181+
this.canUseVettingSummary = Boolean(perm?.userCanUseVettingSummary);
182+
this.isAdmin = Boolean(perm?.userIsAdmin);
179183
this.canSeeUnofficialEmail =
180-
cldrStatus.getIsUnofficial() && !!perm?.userIsManager;
181-
this.isTC = perm && perm.userIsTC;
184+
cldrStatus.getIsUnofficial() && Boolean(perm?.userIsManager);
185+
this.isTC = Boolean(perm?.userIsTC);
182186
183187
const user = cldrStatus.getSurveyUser();
184-
this.loggedIn = !!user;
188+
this.loggedIn = Boolean(user);
185189
this.userId = user ? user.id : 0;
186190
187191
this.org = cldrStatus.getOrganizationName();

tools/cldr-apps/src/main/java/org/unicode/cldr/web/AnnouncementData.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,11 @@ private boolean inAudience(String audience) {
505505
if (Announcements.AUDIENCE_EVERYONE.equals(audience)) {
506506
return true;
507507
} else if (Announcements.AUDIENCE_VETTERS.equals(audience)) {
508-
return userLevel.isVetter();
508+
return userLevel.isVetterOrStronger();
509509
} else if (Announcements.AUDIENCE_MANAGERS.equals(audience)) {
510510
return userLevel.isManagerOrStronger();
511511
} else if (Announcements.AUDIENCE_TC.equals(audience)) {
512-
return userLevel.isTC();
512+
return userLevel.isTCOrStronger();
513513
} else {
514514
logger.severe("Unrecognized audience: " + audience);
515515
return false;

tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ private boolean isValidSurveyToolVote(UserRegistry.User user, String xpath) {
422422
if (ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.DEPRECATED) return false;
423423
if (ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.HIDE
424424
|| ph.getSurveyToolStatus() == PathHeader.SurveyToolStatus.READ_ONLY) {
425-
if (!UserRegistry.userIsTC(user)) return false;
425+
if (!UserRegistry.userIsTCOrStronger(user)) return false;
426426
}
427427

428428
if (sm.getSupplementalDataInfo().getCoverageValue(xpath, locale.getBaseName())
@@ -918,7 +918,7 @@ private void makeSureInPathsForFile(String xpath, User user, String value)
918918
throws InvalidXPathException {
919919
if (!getPathsForFile().contains(xpath)) {
920920
if (value == null
921-
&& UserRegistry.userIsTC(user)
921+
&& UserRegistry.userIsTCOrStronger(user)
922922
&& XPathTable.getAlt(xpath) != null) {
923923
synchronized (this) {
924924
Set<String> set = new HashSet<>(pathsForFile);
@@ -1026,7 +1026,7 @@ private void saveVoteToDb(
10261026
}
10271027
ps.executeUpdate();
10281028

1029-
if (wasFlagged && UserRegistry.userIsTC(user)) {
1029+
if (wasFlagged && UserRegistry.userIsTCOrStronger(user)) {
10301030
clearFlag(conn, locale, xpathId);
10311031
didClearFlag = true;
10321032
}

tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyAjax.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ private void processRequest(
207207
} else if (what.equals(WHAT_FLAGGED)) {
208208
SurveyJSONWrapper r = newJSONStatus(request, sm);
209209
mySession = CookieSession.retrieve(sess);
210-
new SurveyFlaggedItems(UserRegistry.userIsTC(mySession.user)).getJson(r);
210+
new SurveyFlaggedItems(UserRegistry.userIsTCOrStronger(mySession.user)).getJson(r);
211211
send(r, out);
212212
} else if (what.equals(WHAT_STATS_BYDAYUSERLOC)) {
213213
String votesAfterString = SurveyMain.getVotesAfterString();
@@ -610,7 +610,7 @@ private void processRequest(
610610
*/
611611
if (mySession.user != null
612612
&& mySession.user.canImportOldVotes()
613-
&& !UserRegistry.userIsTC(mySession.user)
613+
&& !UserRegistry.userIsTCOrStronger(mySession.user)
614614
&& !alreadyAutoImportedVotes(mySession.user.id, "ask")) {
615615
r.put("canAutoImport", "true");
616616
}
@@ -707,7 +707,7 @@ private void processRequest(
707707
if (them != null
708708
&& ((them.id == mySession.user.id)
709709
|| // it's me
710-
UserRegistry.userIsTC(mySession.user)
710+
UserRegistry.userIsTCOrStronger(mySession.user)
711711
|| (UserRegistry.userIsExactlyManager(
712712
mySession.user)
713713
&& (them.getOrganization()
@@ -877,7 +877,7 @@ private Integer getIntParameter(HttpServletRequest request, final String fieldNa
877877
* @throws SurveyException
878878
*/
879879
public void assertIsTC(CookieSession mySession) throws SurveyException {
880-
if (!UserRegistry.userIsTC(mySession.user)) {
880+
if (!UserRegistry.userIsTCOrStronger(mySession.user)) {
881881
throw new SurveyException(ErrorCode.E_NO_PERMISSION);
882882
}
883883
}
@@ -1568,7 +1568,7 @@ private long viewOldVotes(
15681568
// sort by pathheader
15691569
Arrays.sort(rows, Comparator.comparing(o -> ((PathHeader) o.get("pathHeader"))));
15701570

1571-
boolean useWinningVotes = UserRegistry.userIsTC(user);
1571+
boolean useWinningVotes = UserRegistry.userIsTCOrStronger(user);
15721572

15731573
/* Some variables are only used if oldvotes != null; otherwise leave them null. */
15741574
JSONArray contested = null; // contested = losing

tools/cldr-apps/src/main/java/org/unicode/cldr/web/SurveyForum.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ private void gatherUsersInterestedInLocale(
198198
&& !u.email.isEmpty()
199199
&& !(UserRegistry.userIsLocked(u)
200200
|| UserRegistry.userIsExactlyAnonymous(u))) {
201-
if (UserRegistry.userIsVetter(u)) {
201+
if (UserRegistry.userIsVetterOrStronger(u)) {
202202
cc_emails.add(u.id);
203203
} else {
204204
bcc_emails.add(u.id);
@@ -301,7 +301,7 @@ private void gatherUsersInterestedInThread(
301301
return; // don't notify the poster of their own action
302302
}
303303
UserRegistry.User rootPoster = sm.reg.getInfo(rootPosterId);
304-
if (UserRegistry.userIsTC(rootPoster)) {
304+
if (UserRegistry.userIsTCOrStronger(rootPoster)) {
305305
cc_emails.add(rootPosterId);
306306
}
307307
}
@@ -316,7 +316,7 @@ private void gatherUsersInterestedInThread(
316316
*/
317317
private boolean userCanUsePostType(PostInfo postInfo) {
318318
User user = postInfo.getUser();
319-
boolean isTC = UserRegistry.userIsTC(user);
319+
boolean isTC = UserRegistry.userIsTCOrStronger(user);
320320
if (!isTC && SurveyMain.isPhaseReadonly()) {
321321
return false;
322322
}

tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserList.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public UserList(
9696
org = null; // all
9797
}
9898
}
99-
canShowLocked = UserRegistry.userIsExactlyManager(me) || UserRegistry.userIsTC(me);
99+
canShowLocked = UserRegistry.userIsManagerOrStronger(me);
100100
showLocked = canShowLocked && ctx.prefBool(PREF_SHOWLOCKED);
101101
isValid = isJustMe || UserRegistry.userCanListUsers(me);
102102
}

tools/cldr-apps/src/main/java/org/unicode/cldr/web/UserRegistry.java

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public String toString() {
293293
}
294294

295295
public String toHtml(User forUser) {
296-
if (forUser == null || !userIsTC(forUser)) {
296+
if (forUser == null || !userIsTCOrStronger(forUser)) {
297297
return "(" + org + "#" + id + ")";
298298
} else {
299299
return "<a href='mailto:"
@@ -316,7 +316,7 @@ public String toHtml() {
316316
}
317317

318318
public String toString(User forUser) {
319-
if (forUser == null || !userIsTC(forUser)) {
319+
if (forUser == null || !userIsTCOrStronger(forUser)) {
320320
return "(" + org + "#" + id + ")";
321321
} else {
322322
return email
@@ -496,6 +496,10 @@ public String toJSONString() throws JSONException {
496496
.toString();
497497
}
498498

499+
public boolean canGenerateVxml() {
500+
return userIsTCOrStronger(this);
501+
}
502+
499503
public boolean canImportOldVotes() {
500504
return canImportOldVotes(CLDRConfig.getInstance().getPhase());
501505
}
@@ -513,6 +517,7 @@ public int getVoteCount() {
513517
/** This one is hidden because it uses JSONObject and can't be serialized */
514518
JSONObject getPermissionsJson() throws JSONException {
515519
return new JSONObject()
520+
.put("userCanGenerateVxml", canGenerateVxml())
516521
.put("userCanImportOldVotes", canImportOldVotes())
517522
.put("userCanUseVettingSummary", userCanUseVettingSummary(this))
518523
.put("userCanCreateSummarySnapshot", userCanCreateSummarySnapshot(this))
@@ -521,8 +526,10 @@ JSONObject getPermissionsJson() throws JSONException {
521526
.put("userCanUseVettingParticipation", userCanUseVettingParticipation(this))
522527
.put("userIsAdmin", userIsAdmin(this))
523528
.put("userIsManager", getLevel().canManageSomeUsers())
524-
.put("userIsTC", userIsTC(this))
525-
.put("userIsVetter", userIsVetter(this) && !userIsTC(this))
529+
.put("userIsTC", userIsTCOrStronger(this))
530+
// Caution: userIsVetter really means user is Vetter or Manager, but not TC or
531+
// Admin. It should be renamed to avoid confusion.
532+
.put("userIsVetter", userIsVetterOrStronger(this) && !userIsTCOrStronger(this))
526533
.put("userIsLocked", userIsLocked(this));
527534
}
528535

@@ -1758,8 +1765,8 @@ public static boolean userIsAdmin(User u) {
17581765
return (u != null) && u.getLevel().isAdmin();
17591766
}
17601767

1761-
public static boolean userIsTC(User u) {
1762-
return (u != null) && u.getLevel().isTC();
1768+
public static boolean userIsTCOrStronger(User u) {
1769+
return (u != null) && u.getLevel().isTCOrStronger();
17631770
}
17641771

17651772
public static boolean userIsExactlyManager(User u) {
@@ -1770,12 +1777,12 @@ public static boolean userIsManagerOrStronger(User u) {
17701777
return (u != null) && u.getLevel().isManagerOrStronger();
17711778
}
17721779

1773-
public static boolean userIsVetter(User u) {
1774-
return (u != null) && u.getLevel().isVetter();
1780+
public static boolean userIsVetterOrStronger(User u) {
1781+
return (u != null) && u.getLevel().isVetterOrStronger();
17751782
}
17761783

1777-
public static boolean userIsGuest(User u) {
1778-
return (u != null) && u.getLevel().isGuest();
1784+
public static boolean userIsGuestOrStronger(User u) {
1785+
return (u != null) && u.getLevel().isGuestOrStronger();
17791786
}
17801787

17811788
public static boolean userIsLocked(User u) {
@@ -1945,9 +1952,9 @@ public static boolean userCanAccessForum(User u, CLDRLocale locale) {
19451952
private static Object userCanAccessForumWhy(User u, CLDRLocale locale) {
19461953
if (u == null) return ModifyDenial.DENY_NULL_USER; // no user, no dice
19471954
if (!u.claSigned) return ModifyDenial.DENY_CLA_NOT_SIGNED;
1948-
if (!userIsGuest(u)) return ModifyDenial.DENY_NO_RIGHTS; // at least guest level
1955+
if (!userIsGuestOrStronger(u)) return ModifyDenial.DENY_NO_RIGHTS; // at least guest level
19491956
if (userIsAdmin(u)) return null; // Admin can modify all
1950-
if (userIsTC(u)) return null; // TC can modify all
1957+
if (userIsTCOrStronger(u)) return null; // TC can modify all
19511958
if (SpecialLocales.getType(locale) == SpecialLocales.Type.scratch) {
19521959
// All users can modify the sandbox
19531960
return null;
@@ -1986,7 +1993,7 @@ public static ModifyDenial countUserVoteForLocaleWhy(User u, CLDRLocale locale)
19861993
if (STFactory.isReadOnlyLocale(locale)) return ModifyDenial.DENY_LOCALE_READONLY;
19871994

19881995
// user must have guest level perms
1989-
if (!userIsGuest(u)) return ModifyDenial.DENY_NO_RIGHTS; // at least guest level
1996+
if (!userIsGuestOrStronger(u)) return ModifyDenial.DENY_NO_RIGHTS; // at least guest level
19901997

19911998
// locales that are aliases can't be modified.
19921999
if (sm.isLocaleAliased(locale) != null) {
@@ -2015,7 +2022,7 @@ public static ModifyDenial userCanModifyLocaleWhy(User u, CLDRLocale locale) {
20152022
// We add more restrictions
20162023

20172024
// Admin and TC users can always modify, even in closed state.
2018-
if (userIsAdmin(u) || userIsTC(u)) return null;
2025+
if (userIsTCOrStronger(u)) return null;
20192026

20202027
// Otherwise, if closed, deny
20212028
if (SurveyMain.isPhaseVettingClosed(locale)) return ModifyDenial.DENY_PHASE_CLOSED;

tools/cldr-apps/src/main/java/org/unicode/cldr/web/WebContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ public void setSession() {
14401440
logger.fine("Session Now=" + session + ", user=" + user);
14411441

14421442
// allow in administrator or TC.
1443-
if (!UserRegistry.userIsTC(user)) {
1443+
if (!UserRegistry.userIsTCOrStronger(user)) {
14441444
if ((user != null) && (session == null)) { // user trying to log in-
14451445
if (CookieSession.tooManyUsers()) {
14461446
System.err.println(

0 commit comments

Comments
 (0)