Search in sources :

Example 1 with RsFlash

use of org.takes.facets.flash.RsFlash in project wring by yegor256.

the class TkPipeDelete method act.

@Override
public Response act(final Request req) throws IOException {
    final Pipe pipe = this.base.user(new RqUser(req).urn()).pipes().pipe(Long.parseLong(new RqHref.Base(req).href().param("id").iterator().next()));
    final String msg = new XePrint(pipe.asXembly()).text("Pipe #{/pipe/id/text()} deleted");
    pipe.delete();
    return new RsForward(new RsFlash(msg), "/pipes");
}
Also used : RsFlash(org.takes.facets.flash.RsFlash) XePrint(io.wring.model.XePrint) RsForward(org.takes.facets.forward.RsForward) Pipe(io.wring.model.Pipe) Base(io.wring.model.Base)

Example 2 with RsFlash

use of org.takes.facets.flash.RsFlash in project wring by yegor256.

the class TkEventDelete method act.

@Override
public Response act(final Request req) throws IOException {
    final User user = this.base.user(new RqUser(req).urn());
    final Href href = new RqHref.Base(req).href();
    final Event event = user.events().event(href.param("title").iterator().next());
    final String hash = new XePrint(event.asXembly()).text("{/event/md5/text()}");
    if (!hash.equals(href.param("hash").iterator().next())) {
        throw new RsForward(new RsFlash("Reload the page, the event has changed", Level.WARNING));
    }
    final String msg = new XePrint(event.asXembly()).text("Event \"{/event/title/text()}\" deleted");
    event.delete();
    return new RsForward(new RsFlash(msg));
}
Also used : RqHref(org.takes.rq.RqHref) User(io.wring.model.User) RsFlash(org.takes.facets.flash.RsFlash) RqHref(org.takes.rq.RqHref) Href(org.takes.misc.Href) Event(io.wring.model.Event) XePrint(io.wring.model.XePrint) RsForward(org.takes.facets.forward.RsForward)

Example 3 with RsFlash

use of org.takes.facets.flash.RsFlash in project wring by yegor256.

the class TkEventDown method act.

@Override
public Response act(final Request req) throws IOException {
    final User user = this.base.user(new RqUser(req).urn());
    final Event event = user.events().event(new RqHref.Base(req).href().param("title").iterator().next());
    event.vote(-Tv.TEN);
    return new RsForward(new RsFlash("Event down-voted"));
}
Also used : RqHref(org.takes.rq.RqHref) User(io.wring.model.User) RsFlash(org.takes.facets.flash.RsFlash) Event(io.wring.model.Event) RsForward(org.takes.facets.forward.RsForward)

Aggregations

RsFlash (org.takes.facets.flash.RsFlash)3 RsForward (org.takes.facets.forward.RsForward)3 Event (io.wring.model.Event)2 User (io.wring.model.User)2 XePrint (io.wring.model.XePrint)2 RqHref (org.takes.rq.RqHref)2 Base (io.wring.model.Base)1 Pipe (io.wring.model.Pipe)1 Href (org.takes.misc.Href)1