Search in sources :

Example 1 with NewsInformation

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

the class NewsController method newNews.

@Post
@CustomBrutauthRules({ LoggedRule.class, InputRule.class })
public void newNews(String title, MarkedText description) {
    NewsInformation information = new NewsInformation(title, description, currentUser, "new news");
    User author = currentUser.getCurrent();
    News news = new News(information, author);
    result.include("news", news);
    newses.save(news);
    result.redirectTo(this).showNews(news, news.getSluggedTitle());
}
Also used : User(org.mamute.model.User) LoggedUser(org.mamute.model.LoggedUser) News(org.mamute.model.News) NewsInformation(org.mamute.model.NewsInformation) CustomBrutauthRules(br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules) Post(br.com.caelum.vraptor.Post)

Example 2 with NewsInformation

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

the class NewsBuilder method build.

public News build() {
    if (loggedUser == null) {
        loggedUser = new LoggedUser(author, null);
    }
    NewsInformation newsInformation = new NewsInformation(title, description, loggedUser, comment);
    News news = new News(newsInformation, author);
    setId(news, id);
    return news;
}
Also used : News(org.mamute.model.News) NewsInformation(org.mamute.model.NewsInformation) LoggedUser(org.mamute.model.LoggedUser)

Example 3 with NewsInformation

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

the class NewsController method saveEdit.

@Post
@CustomBrutauthRules(EditNewsRule.class)
public void saveEdit(@Load News news, String title, MarkedText description, String comment) {
    Information newInformation = new NewsInformation(title, description, currentUser, comment);
    news.enqueueChange(newInformation, UpdateStatus.NO_NEED_TO_APPROVE);
    result.redirectTo(this).showNews(news, news.getSluggedTitle());
}
Also used : NewsInformation(org.mamute.model.NewsInformation) Information(org.mamute.model.Information) NewsInformation(org.mamute.model.NewsInformation) CustomBrutauthRules(br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules) Post(br.com.caelum.vraptor.Post)

Example 4 with NewsInformation

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

the class NewsDAOTest method saveNews.

private News saveNews(User newsAuthor, boolean approved) {
    NewsInformation newsInformation = newsInformation(newsAuthor);
    News news = new News(newsInformation, newsAuthor);
    if (approved)
        news.approved();
    session.save(newsInformation);
    session.save(news);
    return news;
}
Also used : News(org.mamute.model.News) NewsInformation(org.mamute.model.NewsInformation)

Aggregations

NewsInformation (org.mamute.model.NewsInformation)4 News (org.mamute.model.News)3 CustomBrutauthRules (br.com.caelum.brutauth.auth.annotations.CustomBrutauthRules)2 Post (br.com.caelum.vraptor.Post)2 LoggedUser (org.mamute.model.LoggedUser)2 Information (org.mamute.model.Information)1 User (org.mamute.model.User)1