Skip to content

Commit

Permalink
Merge pull request #66 from patou/force_anonymous
Browse files Browse the repository at this point in the history
Force anonymous
  • Loading branch information
manudss authored Jun 27, 2018
2 parents 7f76252 + 8dc720d commit 54f4f71
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ public class WishListDto {
private Date date; // date of the event
private SharingPrivacyType privacy; // Option for sharing privacy of the all list.



private boolean forceAnonymus = false; // To force display list as anonymous. for owner it will show the list as anonyme.

private WishListState state;

private Boolean canSuggest;
Expand Down Expand Up @@ -128,5 +132,14 @@ public Boolean getCanSuggest() {

public void setCanSuggest(Boolean canSuggest) {
this.canSuggest = canSuggest;
}
}

public boolean isForceAnonymus() {
return forceAnonymus;
}

public void setForceAnonymus(boolean forceAnonymus) {
this.forceAnonymus = forceAnonymus;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public class WishList {
private SharingPrivacyType privacy; // Option for sharing privacy of the all list.


private boolean forceAnonymus = false; // To force display list as anonymous. for owner it will show the list as anonyme.


public WishList() {
this.privacy = SharingPrivacyType.PRIVATE;
}
Expand Down Expand Up @@ -85,6 +88,9 @@ public WishList(WishListDto dto) {
setType( dto.getType());
setDate( dto.getDate());
setPrivacy( dto.getPrivacy());

setForceAnonymus(dto.isForceAnonymus());

}

public WishListDto toDto() {
Expand All @@ -97,6 +103,7 @@ public WishListDto toDto() {
dto.setDate( getDate());
dto.setPrivacy( getPrivacy());
dto.setOwner(false);
dto.setForceAnonymus(isForceAnonymus());
return dto;
}

Expand Down Expand Up @@ -181,4 +188,13 @@ public void addUser(AppUser user) {
if (users == null) users = new ArrayList<>();
users.add(new UserShare(user.getEmail(), UserShareType.SHARED));
}


public boolean isForceAnonymus() {
return forceAnonymus;
}

public void setForceAnonymus(boolean forceAnonymus) {
this.forceAnonymus = forceAnonymus;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,11 @@ static WishOptionType computeWishOptionsType(AppUser user, WishList list) {
WishListState state = computeWishListState(user, list);
switch (state) {
case OWNER:
if (list.isForceAnonymus()) {
return WishOptionType.ANONYMOUS;
}
//Si une options est définie dans la liste, alors c'est l'option par défaut
if (list.getPrivacy() != null) {
else if (list.getPrivacy() != null) {
switch (list.getPrivacy()) {
case PRIVATE:
return WishOptionType.HIDDEN;
Expand Down Expand Up @@ -316,8 +319,18 @@ static WishDto cleanWish(WishDto wish, WishOptionType type) {
}
break;
case ANONYMOUS:
wish.setUserTake(null);
wish.setGiven(wish.getAllreadyGiven());
if (wish.getUserTake() == null || wish.getUserTake().isEmpty()) {
wish.setUserTake(null);
wish.setGiven(wish.getAllreadyGiven());
} else {
PersonParticipantDto anymous = new PersonParticipantDto("", "anonyme", "", "");
ArrayList<PersonParticipantDto> userTake = new ArrayList<>();
userTake.add(anymous);
wish.setUserTake(userTake);
wish.setGiven(true);
}


if (!ListUtils.isNullOrEmpty(wish.getComments())) {
wish.setComments(wish.getComments().stream().filter(comment -> comment.getType() == CommentType.PUBLIC).collect(toList()));
}
Expand Down
1 change: 1 addition & 0 deletions liste-envies-war/src/main/webapp/js/lang/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
"PUBLIC": "La liste peut être affiché sans être connecté par toute personne connaissant le lien. Il est nécessaire de se connecter pour interagir avec, et voir si une envie est prise. <br/> Toutes les personnes connectés (bénéficiaires compris) voient qui donne une envie.",
"DEFAULT": "Selectionnez la visibilité de la liste"
},
"FORCE_ANONYMOUS": "Afficher de manière anonyme si l'envies est déjà offerte.",
"DATE": "Date de l'événement",
"DATE_INFO": "Pour afficher un compte à rebours jusqu'à l'événement"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@
<span ng-switch-default translate=".DESCRIPTION.DEFAULT">...</span>
</div>
</div>
<div class="form-group">


<label ><input type="checkbox" id="force-anonymous" ng-model="w.wishList.forceAnonymus"> <span translate=".FORCE_ANONYMOUS"></span></label>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void cleanWishAnonyme() {

WishDto cleaned = WishRules.cleanWish(wish, WishOptionType.ANONYMOUS);

assertThat(cleaned.getUserTake()).isNull();
assertThat(cleaned.getUserTake()).hasSize(1);
assertThat(cleaned.getComments()).hasSize(1).onProperty("text").contains("Public");
}

Expand Down

0 comments on commit 54f4f71

Please sign in to comment.