Search in sources :

Example 1 with TagPage

use of org.mamute.model.TagPage 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)

Example 2 with TagPage

use of org.mamute.model.TagPage 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)

Example 3 with TagPage

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

the class TagPageController method editTagPage.

@Post
@CustomBrutauthRules(ModeratorOnlyRule.class)
public void editTagPage(String tagName, MarkedText about) {
    TagPage tagPage = tagPages.findByTag(tagName);
    tagPage.setAbout(about);
    if (!validator.validate(tagPage)) {
        validator.onErrorRedirectTo(TagPageController.class).editTagPageForm(tagPage.getTagName());
        return;
    }
    result.redirectTo(this).showTagPage(tagPage.getTagName());
}
Also used : TagPage(org.mamute.model.TagPage) CustomBrutauthRules(br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules) Post(br.com.caelum.vraptor.Post)

Example 4 with TagPage

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

the class TagPageController method editTagPageForm.

@Get
@CustomBrutauthRules(ModeratorOnlyRule.class)
public void editTagPageForm(String tagName) {
    TagPage tagPage = tagPages.findByTag(tagName);
    result.include("tagPage", tagPage);
}
Also used : TagPage(org.mamute.model.TagPage) CustomBrutauthRules(br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules) Get(br.com.caelum.vraptor.Get)

Example 5 with TagPage

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

the class TagPageDAOTest method should_get_tag_page_by_tag.

@Test
public void should_get_tag_page_by_tag() {
    TagPageDAO tagPages = new TagPageDAO(session);
    Tag java = tag("java");
    session.save(java);
    tagPages.save(new TagPage(java, notMarked("aboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutaboutabout")));
    TagPage javaPage = tagPages.findByTag(java.getName());
    assertEquals(java.getName(), javaPage.getTagName());
}
Also used : TagPageDAO(org.mamute.dao.TagPageDAO) Tag(org.mamute.model.Tag) TagPage(org.mamute.model.TagPage) Test(org.junit.Test)

Aggregations

TagPage (org.mamute.model.TagPage)5 CustomBrutauthRules (br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules)3 Get (br.com.caelum.vraptor.Get)2 Post (br.com.caelum.vraptor.Post)2 Tag (org.mamute.model.Tag)2 Test (org.junit.Test)1 TagPageDAO (org.mamute.dao.TagPageDAO)1