From 90f55162a15f43c0cc8ff540463d5590f4ffc99c Mon Sep 17 00:00:00 2001 From: Alex Bogdanovski Date: Wed, 20 Sep 2017 14:27:39 +0300 Subject: [PATCH] fixed broken profile pictures of deleted users, show notice of user object deleted --- .../scoold/controllers/ErrorController.java | 18 +++++++++--------- .../scoold/controllers/ProfileController.java | 2 +- .../java/com/erudika/scoold/core/Feedback.java | 2 -- .../java/com/erudika/scoold/core/Question.java | 2 -- .../com/erudika/scoold/utils/ScooldUtils.java | 8 ++++++++ src/main/resources/templates/feedback.vm | 6 ++++-- src/main/resources/templates/macro.vm | 5 ++++- src/main/resources/templates/profile.vm | 4 ++++ src/main/resources/templates/question.vm | 2 +- src/main/resources/templates/questions.vm | 4 +++- 10 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/erudika/scoold/controllers/ErrorController.java b/src/main/java/com/erudika/scoold/controllers/ErrorController.java index c94e6f06..76adb0b7 100755 --- a/src/main/java/com/erudika/scoold/controllers/ErrorController.java +++ b/src/main/java/com/erudika/scoold/controllers/ErrorController.java @@ -1,12 +1,3 @@ -package com.erudika.scoold.controllers; - -import com.erudika.scoold.utils.ScooldUtils; -import javax.inject.Inject; -import javax.servlet.http.HttpServletRequest; -import org.springframework.stereotype.Controller; -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; /* * Copyright 2013-2017 Erudika. https://erudika.com @@ -25,6 +16,15 @@ * * For issues and patches go to: https://github.com/erudika */ +package com.erudika.scoold.controllers; + +import com.erudika.scoold.utils.ScooldUtils; +import javax.inject.Inject; +import javax.servlet.http.HttpServletRequest; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; /** * diff --git a/src/main/java/com/erudika/scoold/controllers/ProfileController.java b/src/main/java/com/erudika/scoold/controllers/ProfileController.java index af7227ce..dd17c58b 100755 --- a/src/main/java/com/erudika/scoold/controllers/ProfileController.java +++ b/src/main/java/com/erudika/scoold/controllers/ProfileController.java @@ -92,7 +92,7 @@ public String get(@PathVariable(required = false) String id, HttpServletRequest model.addAttribute("isMyProfile", isMyProfile); model.addAttribute("badgesCount", showUser.getBadgesMap().size()); model.addAttribute("canEdit", isMyProfile || canEditProfile(authUser, id)); - model.addAttribute("gravatarPicture", utils.getGravatar(showUser.getUser().getEmail())); + model.addAttribute("gravatarPicture", utils.getGravatar(showUser)); model.addAttribute("itemcount1", itemcount1); model.addAttribute("itemcount2", itemcount2); model.addAttribute("questionslist", questionslist); diff --git a/src/main/java/com/erudika/scoold/core/Feedback.java b/src/main/java/com/erudika/scoold/core/Feedback.java index f7be46ed..3f01bd7c 100755 --- a/src/main/java/com/erudika/scoold/core/Feedback.java +++ b/src/main/java/com/erudika/scoold/core/Feedback.java @@ -17,8 +17,6 @@ */ package com.erudika.scoold.core; -import java.io.Serializable; - /** * * @author Alex Bogdanovski [alex@erudika.com] diff --git a/src/main/java/com/erudika/scoold/core/Question.java b/src/main/java/com/erudika/scoold/core/Question.java index 093f0a3d..e75b2726 100755 --- a/src/main/java/com/erudika/scoold/core/Question.java +++ b/src/main/java/com/erudika/scoold/core/Question.java @@ -17,8 +17,6 @@ */ package com.erudika.scoold.core; -import java.io.Serializable; - /** * * @author Alex Bogdanovski [alex@erudika.com] diff --git a/src/main/java/com/erudika/scoold/utils/ScooldUtils.java b/src/main/java/com/erudika/scoold/utils/ScooldUtils.java index 0dd89084..77eceb99 100755 --- a/src/main/java/com/erudika/scoold/utils/ScooldUtils.java +++ b/src/main/java/com/erudika/scoold/utils/ScooldUtils.java @@ -326,6 +326,14 @@ public String getGravatar(String email) { return "https://www.gravatar.com/avatar/" + Utils.md5(email) + "?size=400&d=retro"; } + public String getGravatar(Profile profile) { + if (profile == null || profile.getUser() == null) { + return "https://www.gravatar.com/avatar?d=retro&size=400"; + } else { + return getGravatar(profile.getUser().getEmail()); + } + } + public void clearSession(HttpServletRequest req, HttpServletResponse res) { if (req != null) { HttpSession session = req.getSession(false); diff --git a/src/main/resources/templates/feedback.vm b/src/main/resources/templates/feedback.vm index 803a8949..da5faeb6 100755 --- a/src/main/resources/templates/feedback.vm +++ b/src/main/resources/templates/feedback.vm @@ -29,7 +29,9 @@ - #getmessagebox("red white-text" $error.get("tags")) +
+ #getmessagebox("red white-text" $error.get("tags")) +