Search in sources :

Example 1 with Tag

use of org.mamute.model.Tag in project mamute by caelum.

the class TagsManager method createTags.

private List<Tag> createTags(List<String> splitedTags) {
    ArrayList<Tag> savedTags = new ArrayList<>();
    for (String newTag : splitedTags) {
        Tag tag = new Tag(newTag, "", user.getCurrent());
        tag = tags.saveIfDoesntExists(tag);
        savedTags.add(tag);
    }
    return savedTags;
}
Also used : ArrayList(java.util.ArrayList) Tag(org.mamute.model.Tag)

Example 2 with Tag

use of org.mamute.model.Tag in project mamute by caelum.

the class CreateQuestionTest method should_make_a_question.

@Test
public void should_make_a_question() {
    String title = "My new question about java";
    String description = "just a question that i have about java hahahhaha";
    Tag tag = tag("java");
    UserFlow navigation = login(navigate(), karmaNigga().getEmail());
    navigation = createQuestionWithFlow(navigation, title, description, tag.getName(), false);
    VRaptorTestResult createdQuestion = navigation.followRedirect().execute();
    createdQuestion.wasStatus(200).isValid();
    Question question = createdQuestion.getObject("question");
    Tag questionTag = question.getTags().get(0);
    assertThat(question.getTitle(), equalTo(title));
    assertThat(question.getDescription(), equalTo(description));
    assertThat(questionTag.getName(), equalTo(tag.getName()));
}
Also used : UserFlow(br.com.caelum.vraptor.test.requestflow.UserFlow) Question(org.mamute.model.Question) Tag(org.mamute.model.Tag) VRaptorTestResult(br.com.caelum.vraptor.test.VRaptorTestResult) Test(org.junit.Test)

Example 3 with Tag

use of org.mamute.model.Tag 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 4 with Tag

use of org.mamute.model.Tag in project mamute by caelum.

the class TagController method saveTags.

@Post
@CustomBrutauthRules(ModeratorOnlyRule.class)
public void saveTags(String stringTags) {
    List<String> tagList = splitter.splitTags(stringTags);
    for (String tag : tagList) {
        tags.saveIfDoesntExists(new Tag(tag, "", null));
    }
    result.nothing();
}
Also used : Tag(org.mamute.model.Tag) CustomBrutauthRules(br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules) Post(br.com.caelum.vraptor.Post)

Example 5 with Tag

use of org.mamute.model.Tag in project mamute by caelum.

the class TagPageController method newTagPage.

@Post
@CustomBrutauthRules(ModeratorOnlyRule.class)
public void newTagPage(String tagName, MarkedText about) {
    if (!validator.validateCreationWithTag(tagName))
        return;
    Tag tag = tags.findByName(tagName);
    TagPage tagPage = new TagPage(tag, about);
    if (!validator.validate(tagPage)) {
        validator.onErrorRedirectTo(TagPageController.class).tagPageForm(tagPage.getTagName());
        return;
    }
    tagPages.save(tagPage);
    result.redirectTo(this).showTagPage(tagPage.getTagName());
}
Also used : Tag(org.mamute.model.Tag) TagPage(org.mamute.model.TagPage) CustomBrutauthRules(br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules) Post(br.com.caelum.vraptor.Post)

Aggregations

Tag (org.mamute.model.Tag)21 Question (org.mamute.model.Question)9 Test (org.junit.Test)8 User (org.mamute.model.User)7 Before (org.junit.Before)5 LoggedUser (org.mamute.model.LoggedUser)5 Get (br.com.caelum.vraptor.Get)3 ArrayList (java.util.ArrayList)3 Answer (org.mamute.model.Answer)3 CustomBrutauthRules (br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules)2 Post (br.com.caelum.vraptor.Post)2 InvisibleForUsersRule (org.mamute.dao.InvisibleForUsersRule)2 UserSummaryForTag (org.mamute.dto.UserSummaryForTag)2 Attachment (org.mamute.model.Attachment)2 QuestionInformation (org.mamute.model.QuestionInformation)2 QuestionInformationBuilder (org.mamute.model.QuestionInformationBuilder)2 ReputationEvent (org.mamute.model.ReputationEvent)2 TagPage (org.mamute.model.TagPage)2 Environment (br.com.caelum.vraptor.environment.Environment)1 VRaptorTestResult (br.com.caelum.vraptor.test.VRaptorTestResult)1