-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an option to restrict which locales a user can edit (#1004)
This PR adds the option to restrict what locales a user can edit. This way, users that are not that well versed with mojito can't accidentally change the translations for wrong locales. --------- Co-authored-by: Jean Aurambault <[email protected]>
- Loading branch information
Showing
34 changed files
with
655 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
restclient/src/main/java/com/box/l10n/mojito/rest/entity/UserLocale.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.box.l10n.mojito.rest.entity; | ||
|
||
import com.fasterxml.jackson.annotation.JsonBackReference; | ||
|
||
public class UserLocale { | ||
@JsonBackReference private User user; | ||
|
||
private Locale locale; | ||
|
||
public User getUser() { | ||
return user; | ||
} | ||
|
||
public void setUser(User user) { | ||
this.user = user; | ||
} | ||
|
||
public Locale getLocale() { | ||
return locale; | ||
} | ||
|
||
public void setLocale(Locale locale) { | ||
this.locale = locale; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
webapp/src/main/java/com/box/l10n/mojito/entity/security/user/UserLocale.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package com.box.l10n.mojito.entity.security.user; | ||
|
||
import com.box.l10n.mojito.entity.BaseEntity; | ||
import com.box.l10n.mojito.entity.Locale; | ||
import com.box.l10n.mojito.rest.View; | ||
import com.fasterxml.jackson.annotation.JsonBackReference; | ||
import com.fasterxml.jackson.annotation.JsonView; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.ForeignKey; | ||
import jakarta.persistence.Index; | ||
import jakarta.persistence.JoinColumn; | ||
import jakarta.persistence.ManyToOne; | ||
import jakarta.persistence.Table; | ||
import java.io.Serializable; | ||
import org.hibernate.annotations.BatchSize; | ||
|
||
@Entity | ||
@Table( | ||
name = "user_locale", | ||
indexes = { | ||
@Index( | ||
name = "UK__USER_LOCALE__USER_ID__LOCALE_ID", | ||
columnList = "user_id, locale_id", | ||
unique = true) | ||
}) | ||
@BatchSize(size = 1000) | ||
public class UserLocale extends BaseEntity implements Serializable { | ||
|
||
@ManyToOne | ||
@JsonBackReference | ||
@JoinColumn( | ||
name = "user_id", | ||
foreignKey = @ForeignKey(name = "FK__USER_LOCALE__USER__ID"), | ||
nullable = false) | ||
User user; | ||
|
||
@JsonView(View.LocaleSummary.class) | ||
@ManyToOne | ||
@JoinColumn( | ||
name = "locale_id", | ||
foreignKey = @ForeignKey(name = "FK__USER_LOCALE__LOCALE__ID"), | ||
nullable = false) | ||
Locale locale; | ||
|
||
public UserLocale() {} | ||
|
||
public UserLocale(User user, Locale locale) { | ||
this.user = user; | ||
this.locale = locale; | ||
} | ||
|
||
public User getUser() { | ||
return user; | ||
} | ||
|
||
public void setUser(User user) { | ||
this.user = user; | ||
} | ||
|
||
public Locale getLocale() { | ||
return locale; | ||
} | ||
|
||
public void setLocale(Locale locale) { | ||
this.locale = locale; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.