use of br.com.caelum.vraptor.Get in project mamute by caelum.
the class HistoryController method history.
@SimpleBrutauthRules({ EnvironmentKarmaRule.class })
@EnvironmentAccessLevel(PermissionRules.MODERATE_EDITS)
@Get
public void history() {
ModeratableAndPendingHistory pendingQuestions = informations.pendingByUpdatables(Question.class);
result.include("questions", pendingQuestions);
ModeratableAndPendingHistory pendingAnswers = informations.pendingByUpdatables(Answer.class);
result.include("answers", pendingAnswers);
}
use of br.com.caelum.vraptor.Get in project mamute by caelum.
the class FacebookAuthController method signupViaFacebook.
@Get("/sign-up/facebook/")
public void signupViaFacebook(String code, String state) {
if (code == null) {
includeAsList("mamuteMessages", i18n("error", "error.signup.facebook.unknown"));
redirectTo(SignupController.class).signupForm();
return;
}
Token token = service.getAccessToken(null, new Verifier(code));
SocialAPI facebookAPI = new FacebookAPI(service, token);
boolean success = loginManager.merge(MethodType.FACEBOOK, facebookAPI);
if (!success) {
includeAsList("mamuteMessages", i18n("error", "signup.errors.facebook.invalid_email", state));
result.redirectTo(AuthController.class).loginForm(state);
return;
}
redirectToRightUrl(state);
}
use of br.com.caelum.vraptor.Get in project mamute by caelum.
the class FlagController method topFlagged.
@CustomBrutauthRules(ModeratorOnlyRule.class)
@Get
public void topFlagged() {
List<FlaggableAndFlagCount> flaggedQuestions = flaggables.flaggedButVisible(Question.class);
List<FlaggableAndFlagCount> flaggedAnswers = flaggables.flaggedButVisible(Answer.class);
List<FlaggableAndFlagCount> flaggedComments = flaggables.flaggedButVisible(Comment.class);
List<Question> commentQuestions = new ArrayList<>();
Iterator<FlaggableAndFlagCount> iterator = flaggedComments.iterator();
while (iterator.hasNext()) {
Comment comment = (Comment) iterator.next().getFlaggable();
Question q = questions.fromCommentId(comment.getId());
if (q != null) {
commentQuestions.add(q);
continue;
}
Answer answerFromComment = answers.fromCommentId(comment.getId());
if (answerFromComment != null) {
commentQuestions.add(answerFromComment.getQuestion());
continue;
}
// some flags may be related to news (not questions nor answers)
iterator.remove();
}
result.include("questions", flaggedQuestions);
result.include("answers", flaggedAnswers);
result.include("comments", flaggedComments);
result.include("commentQuestions", commentQuestions);
}
use of br.com.caelum.vraptor.Get in project mamute by caelum.
the class RankingController method tagRank.
@Get
public void tagRank(String tagName) {
Tag tag = tags.findByName(tagName);
if (tag == null) {
result.notFound();
}
result.include("tag", tag);
DateTime after = new DateTime().minusDays(30);
result.include("tag", tag);
result.include("answerersAllTime", reputationEvents.getTopAnswerersSummaryAllTime(tag));
result.include("answerersLastMonth", reputationEvents.getTopAnswerersSummaryAfter(tag, after));
result.include("askersAllTime", reputationEvents.getTopAskersSummaryAllTime(tag));
result.include("askersLastMonth", reputationEvents.getTopAskersSummaryAfter(tag, after));
result.include("usersActive", true);
result.include("noDefaultActive", true);
}
use of br.com.caelum.vraptor.Get in project mamute by caelum.
the class TagPageController method showTagPage.
@Get
public void showTagPage(String tagName) {
TagPage tagPage = tagPages.findByTag(tagName);
result.include(tagPage);
result.include("hasAbout", tags.hasAbout(tagPage.getTag()));
}
Aggregations