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;
}
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()));
}
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);
}
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();
}
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());
}
Aggregations