use of com.erudika.scoold.core.Feedback in project scoold by Erudika.
the class SearchController method get.
@GetMapping({ "/search/{type}/{query}", "/search" })
public String get(@PathVariable(required = false) String type, @PathVariable(required = false) String query, @RequestParam(required = false) String q, HttpServletRequest req, Model model) {
List<Profile> userlist = new ArrayList<Profile>();
List<Post> questionlist = new ArrayList<Post>();
List<Post> answerlist = new ArrayList<Post>();
List<Post> feedbacklist = new ArrayList<Post>();
Pager itemcount = utils.getPager("page", req);
String queryString = StringUtils.isBlank(q) ? query : q;
if ("questions".equals(type)) {
questionlist = pc.findQuery(Utils.type(Question.class), queryString, itemcount);
} else if ("answers".equals(type)) {
answerlist = pc.findQuery(Utils.type(Reply.class), queryString, itemcount);
} else if ("feedback".equals(type)) {
feedbacklist = pc.findQuery(Utils.type(Feedback.class), queryString, itemcount);
} else if ("people".equals(type)) {
userlist = pc.findQuery(Utils.type(Profile.class), queryString, itemcount);
} else {
questionlist = pc.findQuery(Utils.type(Question.class), queryString);
answerlist = pc.findQuery(Utils.type(Reply.class), queryString);
feedbacklist = pc.findQuery(Utils.type(Feedback.class), queryString);
userlist = pc.findQuery(Utils.type(Profile.class), queryString);
}
ArrayList<Post> list = new ArrayList<Post>();
list.addAll(questionlist);
list.addAll(answerlist);
list.addAll(feedbacklist);
utils.fetchProfiles(list);
model.addAttribute("path", "search.vm");
model.addAttribute("title", utils.getLang(req).get("search.title"));
model.addAttribute("searchSelected", "navbtn-hover");
model.addAttribute("showParam", type);
model.addAttribute("searchQuery", queryString);
model.addAttribute("itemcount", itemcount);
model.addAttribute("userlist", userlist);
model.addAttribute("questionlist", questionlist);
model.addAttribute("answerlist", answerlist);
model.addAttribute("feedbacklist", feedbacklist);
return "base";
}
use of com.erudika.scoold.core.Feedback in project scoold by Erudika.
the class FeedbackController method createAjax.
@PostMapping
public String createAjax(HttpServletRequest req, Model model) {
model.addAttribute("path", "feedback.vm");
if (utils.isAuthenticated(req)) {
Profile authUser = utils.getAuthUser(req);
Post post = utils.populate(req, new Feedback(), "title", "body", "tags|,");
Map<String, String> error = utils.validate(post);
if (error.isEmpty()) {
post.setCreatorid(authUser.getId());
post.create();
authUser.setLastseen(System.currentTimeMillis());
return "redirect:" + feedbacklink;
} else {
model.addAttribute("error", error);
return "base";
}
}
return "redirect:" + feedbacklink;
}
use of com.erudika.scoold.core.Feedback in project scoold by Erudika.
the class FeedbackController method getById.
@GetMapping({ "/{id}", "/{id}/{title}" })
public String getById(@PathVariable String id, @PathVariable(required = false) String title, HttpServletRequest req, Model model) {
Feedback showPost = pc.read(id);
if (showPost == null) {
return "redirect:" + feedbacklink;
}
Pager itemcount = utils.getPager("page", req);
model.addAttribute("path", "feedback.vm");
model.addAttribute("title", utils.getLang(req).get("feedback.title") + " - " + showPost.getTitle());
model.addAttribute("description", Utils.abbreviate(Utils.stripAndTrim(showPost.getBody(), " "), 195));
model.addAttribute("showPost", showPost);
model.addAttribute("answerslist", showPost.getAnswers(itemcount));
model.addAttribute("itemcount", itemcount);
return "base";
}
Aggregations