Search in sources :

Example 1 with Get

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);
}
Also used : ModeratableAndPendingHistory(org.mamute.model.ModeratableAndPendingHistory) Get(br.com.caelum.vraptor.Get) SimpleBrutauthRules(br.com.caelum.brutauth.auth.annotations.SimpleBrutauthRules)

Example 2 with Get

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);
}
Also used : FacebookAPI(org.mamute.auth.FacebookAPI) Token(org.scribe.model.Token) Verifier(org.scribe.model.Verifier) SocialAPI(org.mamute.auth.SocialAPI) Get(br.com.caelum.vraptor.Get)

Example 3 with Get

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);
}
Also used : Comment(org.mamute.model.Comment) Answer(org.mamute.model.Answer) FlaggableAndFlagCount(org.mamute.dto.FlaggableAndFlagCount) ArrayList(java.util.ArrayList) Question(org.mamute.model.Question) CustomBrutauthRules(br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules) Get(br.com.caelum.vraptor.Get)

Example 4 with Get

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);
}
Also used : Tag(org.mamute.model.Tag) DateTime(org.joda.time.DateTime) Get(br.com.caelum.vraptor.Get)

Example 5 with Get

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()));
}
Also used : TagPage(org.mamute.model.TagPage) Get(br.com.caelum.vraptor.Get)

Aggregations

Get (br.com.caelum.vraptor.Get)17 Path (br.com.caelum.vraptor.Path)5 CustomBrutauthRules (br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules)3 Question (org.mamute.model.Question)3 Tag (org.mamute.model.Tag)3 DateTime (org.joda.time.DateTime)2 SocialAPI (org.mamute.auth.SocialAPI)2 TagPage (org.mamute.model.TagPage)2 Token (org.scribe.model.Token)2 Verifier (org.scribe.model.Verifier)2 Espetaculo (br.com.caelum.agiletickets.models.Espetaculo)1 Sessao (br.com.caelum.agiletickets.models.Sessao)1 SimpleBrutauthRules (br.com.caelum.brutauth.auth.annotations.SimpleBrutauthRules)1 Item (br.com.caelum.example.model.Item)1 ConfigurableHypermediaResource (br.com.caelum.vraptor.restfulie.hypermedia.ConfigurableHypermediaResource)1 Serializer (br.com.caelum.vraptor.serialization.Serializer)1 ArrayList (java.util.ArrayList)1 Statistics (org.hibernate.stat.Statistics)1 FacebookAPI (org.mamute.auth.FacebookAPI)1 GoogleAPI (org.mamute.auth.GoogleAPI)1