Package models

Examples of models.Vote


        else
        {
            List<ModuleVersion> moduleVersions = ModuleVersion.findByModule(module);
            User user = currentUser();
            Rate rate = null;
            Vote vote = null;

            if (user != null)
            {
                rate = CollectionUtils.filterFirst(user.rates,
                                                   new Filter<Rate>()
View Full Code Here


            result = notFound("Module not found: " + moduleKey);
        }
        else
        {
            User user = currentUser();
            Vote vote = CollectionUtils.filterFirst(user.votes,
                                                    new Filter<Vote>()
                                                    {
                                                        @Override
                                                        public boolean isAcceptable(Vote vote)
                                                        {
                                                            return vote.playModule.id.equals(module.id);
                                                        }
                                                    });
            if (vote != null)
            {
                if (vote.voteType == Vote.VoteType.DOWN)
                {
                    --module.downVoteCount;
                    ++module.upVoteCount;
                    vote.voteType = Vote.VoteType.UP;
                    vote.save();
                    module.save();
                }
                else
                {
                    Logger.info(String.format("User [%s] tried to upvote module [%s] but vote already existed",
                                              user.userName,
                                              module.key));
                }
            }
            else
            {
                vote = new Vote();
                vote.playModule = module;
                vote.voteType = Vote.VoteType.UP;
                // support for public voting comes later
                vote.publicVote = false;
                user.votes.add(vote);
View Full Code Here

            result = notFound("Module not found: " + moduleKey);
        }
        else
        {
            User user = currentUser();
            Vote vote = CollectionUtils.filterFirst(user.votes,
                                                    new Filter<Vote>()
                                                    {
                                                        @Override
                                                        public boolean isAcceptable(Vote vote)
                                                        {
                                                            return vote.playModule.id.equals(module.id);
                                                        }
                                                    });
            if (vote != null)
            {
                if (vote.voteType == Vote.VoteType.UP)
                {
                    --module.upVoteCount;
                    ++module.downVoteCount;
                    vote.voteType = Vote.VoteType.DOWN;
                    vote.save();
                    module.save();
                }
                else
                {
                    Logger.info(String.format("User [%s] tried to downvote module [%s] but vote already existed",
                                              user.userName,
                                              module.key));
                }
            }
            else
            {
                vote = new Vote();
                vote.playModule = module;
                vote.voteType = Vote.VoteType.DOWN;
                // support for public voting comes later
                vote.publicVote = false;
                user.votes.add(vote);
View Full Code Here

            User user = (User) deadboltHandler.getRoleHolder(ctx);
            if (user != null)
            {
                for (Iterator<Vote> iterator = user.votes.iterator(); allowed && iterator.hasNext(); )
                {
                    Vote vote = iterator.next();
                    allowed = !meta.equals(vote.playModule.key);
                }
            }
        }
        return allowed;
View Full Code Here

        return new LightningTalk().save();
    }

    private void vote(LightningTalk lt, Member m, int nb) {
        for (int i = 0; i < nb; i++) {
            new Vote(lt, member, true).save();
        }
    }
View Full Code Here

        Session talk = Session.findById(talkId);
        Member member = Member.findByLogin(Security.connected());
        if (member != null && talk != null) {
            // Can't vote on a passed event
            if (talk.event.isCurrent()) {
                Vote vote = Vote.findVote(talk, member);
                if (vote != null) {
                    vote.value = !value;
                } else {
                    vote = new Vote(talk, member, !value);
                }
                vote.save();
                return Vote.findNumberOfVotesBySession(talk);
            }
        }
        return -1;
    }
View Full Code Here

        // No activity for the talk
        assertEquals(0, Activity.count("session = ?", lt));
        assertNull(Activity.find("session = ?", lt).first());
       
        // new negative vote pour the lt
        Vote v = new Vote(lt, member, false).save();
       
        // Stille no activity for the talk
        assertEquals(0, Activity.count("session = ?", lt));
        assertNull(Activity.find("session = ?", lt).first());
       
        // Positive vote
        v.value = true;
        v.save();
       
        // One activity for the session
        assertEquals(1, Activity.count("session = ?", lt));
        Activity a = Activity.find("session = ?", lt).first();
        assertActivity(a);
View Full Code Here

TOP

Related Classes of models.Vote

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.