Search in sources :

Example 36 with Profile

use of com.erudika.scoold.core.Profile in project scoold by Erudika.

the class AdminController method toggleWebhook.

@PostMapping("/toggle-webhook")
public String toggleWebhook(@RequestParam String id, HttpServletRequest req, HttpServletResponse res) {
    Profile authUser = utils.getAuthUser(req);
    if (!StringUtils.isBlank(id) && utils.isAdmin(authUser) && utils.isWebhooksEnabled()) {
        Webhook webhook = pc.read(id);
        if (webhook != null) {
            webhook.setActive(!webhook.getActive());
            pc.update(webhook);
        }
    }
    if (utils.isAjaxRequest(req)) {
        res.setStatus(200);
        return "base";
    } else {
        return "redirect:" + ADMINLINK;
    }
}
Also used : Webhook(com.erudika.para.core.Webhook) Profile(com.erudika.scoold.core.Profile) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 37 with Profile

use of com.erudika.scoold.core.Profile in project scoold by Erudika.

the class DefaultAvatarRepositoryTest method getLink_should_return_always_default_avatar.

@Test
public void getLink_should_return_always_default_avatar() {
    Profile profile = new Profile();
    assertEquals(ScooldUtils.getDefaultAvatar(), repository.getLink(profile, AvatarFormat.Profile));
    assertEquals(repository.getLink(new Profile(), AvatarFormat.Square32), repository.getLink(new Profile(), AvatarFormat.Profile));
}
Also used : Profile(com.erudika.scoold.core.Profile) Test(org.junit.Test)

Example 38 with Profile

use of com.erudika.scoold.core.Profile in project scoold by Erudika.

the class DefaultAvatarRepositoryTest method store_should_nothing.

@Test
public void store_should_nothing() {
    Profile profile = new Profile();
    boolean result = repository.store(profile, "https://avatar");
    assertEquals(ScooldUtils.getDefaultAvatar(), profile.getPicture());
    assertEquals(true, result);
}
Also used : Profile(com.erudika.scoold.core.Profile) Test(org.junit.Test)

Example 39 with Profile

use of com.erudika.scoold.core.Profile in project scoold by Erudika.

the class GravatarAvatarRepositoryTest method setUp.

@Before
public void setUp() {
    this.profile = new Profile();
    this.profile.setUser(new User());
    this.defaultRepository = new DefaultAvatarRepository();
    this.gravatarGenerator = new GravatarAvatarGenerator();
    this.repository = new GravatarAvatarRepository(gravatarGenerator, defaultRepository);
}
Also used : User(com.erudika.para.core.User) Profile(com.erudika.scoold.core.Profile) Before(org.junit.Before)

Example 40 with Profile

use of com.erudika.scoold.core.Profile in project scoold by Erudika.

the class SettingsController method post.

@PostMapping
public String post(@RequestParam(required = false) String tags, @RequestParam(required = false) String latlng, @RequestParam(required = false) String replyEmailsOn, @RequestParam(required = false) String commentEmailsOn, HttpServletRequest req) {
    if (utils.isAuthenticated(req)) {
        Profile authUser = utils.getAuthUser(req);
        if (!StringUtils.isBlank(tags)) {
            Set<String> ts = new LinkedHashSet<String>();
            for (String tag : tags.split(",")) {
                if (!StringUtils.isBlank(tag) && ts.size() <= MAX_FAV_TAGS) {
                    ts.add(tag);
                }
            }
            authUser.setFavtags(new LinkedList<String>(ts));
        }
        if (!StringUtils.isBlank(latlng)) {
            authUser.setLatlng(latlng);
        }
        authUser.setReplyEmailsEnabled(Boolean.valueOf(replyEmailsOn));
        authUser.setCommentEmailsEnabled(Boolean.valueOf(commentEmailsOn));
        authUser.update();
    }
    return "redirect:" + settingslink;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Profile(com.erudika.scoold.core.Profile) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Aggregations

Profile (com.erudika.scoold.core.Profile)85 PostMapping (org.springframework.web.bind.annotation.PostMapping)47 Post (com.erudika.scoold.core.Post)29 ParaObject (com.erudika.para.core.ParaObject)25 User (com.erudika.para.core.User)19 Pager (com.erudika.para.core.utils.Pager)19 HashMap (java.util.HashMap)15 LinkedHashMap (java.util.LinkedHashMap)15 Question (com.erudika.scoold.core.Question)13 Reply (com.erudika.scoold.core.Reply)13 Report (com.erudika.scoold.core.Report)11 IOException (java.io.IOException)11 List (java.util.List)11 Map (java.util.Map)11 UnapprovedReply (com.erudika.scoold.core.UnapprovedReply)10 GetMapping (org.springframework.web.bind.annotation.GetMapping)10 Sysprop (com.erudika.para.core.Sysprop)9 Config (com.erudika.para.core.utils.Config)9 Utils (com.erudika.para.core.utils.Utils)9 Comment (com.erudika.scoold.core.Comment)9