示例#1
0
def test_get_user():
    i = rint()

    user = User.get_or_create(i, "pete", "bigpete" + (str(i)))
    assert user is not None

    sp = "smallpete%s" % str(i)
    user2 = User.get_or_create(i, "pete", sp)
    assert user == user2

    small_pete = User.get(user_id=i)
    assert small_pete.mention_name == sp

    pete = User.get_by_nick(sp)
    assert pete == small_pete
示例#2
0
def test_get_user():
    i = rint()

    user = User.get_or_create(i, "pete", "bigpete" + (str(i)))
    assert user is not None

    sp = "smallpete%s" % str(i)
    user2 = User.get_or_create(i, "pete", sp)
    assert user == user2

    small_pete = User.get(user_id=i)
    assert small_pete.mention_name == sp

    pete = User.get_by_nick(sp)
    assert pete == small_pete
示例#3
0
    def get_user(self, message):
        connect()
        assert isinstance(message, Message)
        user = message.sender
        # user_id = user.user.split("_")[1]
        # hipchat_user = self.get_hipchat_user(user_id)

        # available on hipchat_user
        user = User.get_or_create(user.hipchat_id, user.name, user.nick)
        return user
示例#4
0
    def summary_view(self, message):
        connect()
        result = []

        for user in User.objects():
            updates = StatusUpdateUserAggregated.objects(user_id=user.user_id).limit(5)
            if not len(updates):
                continue

            template = rendered_template("show_updates.html", {"user": user, "updates": updates})
            self.reply(message, template, html=True)
示例#5
0
    def get_user(self, message):
        connect()
        assert isinstance(message, Message)
        user = message.sender
        # user_id = user.user.split("_")[1]
        # hipchat_user = self.get_hipchat_user(user_id)

        # available on hipchat_user
        user = User.get_or_create(user.hipchat_id,
                                  user.name,
                                  user.nick)
        return user
示例#6
0
    def summary_view(self, message):
        connect()
        result = []

        for user in User.objects():
            updates = StatusUpdateUserAggregated.objects(user_id=user.user_id).limit(5)
            if not len(updates):
                continue

            template = rendered_template("show_updates.html",
                                         {"user":user, "updates":updates})
            self.reply(message, template, html=True)
示例#7
0
    def lsproject(self, message, nick):
        # lists all projects, current user is assumed
        connect()
        if nick:
            nick = nick.strip()
            user = User.get_by_nick(nick)
        else:
            user = self.get_user(message)

        if not user:
            self.reply(message, "Could not find user %s" % nick)
            return

        projects = Project.objects(user_id=user.user_id)

        template = rendered_template("lsproject.html", {"user":user, "projects":projects})
        self.reply(message, template, html=True)
示例#8
0
    def lsproject(self, message, nick):
        # lists all projects, current user is assumed
        connect()
        if nick:
            nick = nick.strip()
            user = User.get_by_nick(nick)
        else:
            user = self.get_user(message)

        if not user:
            self.reply(message, "Could not find user %s" % nick)
            return

        projects = Project.objects(user_id=user.user_id)

        template = rendered_template("lsproject.html", {"user":user, "projects":projects})
        self.reply(message, template, html=True)
示例#9
0
    def show_updates(self, message, nick):
        # shows updates for a single user
        connect()
        try:
            if not nick:
                user = self.get_user(message)
            else:
                user = User.get_by_nick(nick)
        except User.DoesNotExist:
            self.reply(message, "%s does not exist yet." % nick)
            return

        updates = StatusUpdateUserAggregated.objects(user_id=user.user_id).limit(10)

        template = rendered_template("show_updates.html", {"user": user, "updates": updates})

        self.reply(message, template, html=True)
示例#10
0
    def show_updates(self, message, nick):
        # shows updates for a single user
        connect()
        try:
            if not nick:
                user = self.get_user(message)
            else:
                user = User.get_by_nick(nick)
        except User.DoesNotExist:
            self.reply(message, "%s does not exist yet." % nick)
            return


        updates = StatusUpdateUserAggregated.objects(user_id=user.user_id).limit(10)

        template = rendered_template("show_updates.html",
                                     {"user":user, "updates":updates})

        self.reply(message, template, html=True)
示例#11
0
def mkuser():
    i = rint()
    return User.get_or_create(i, "test", "test" + str(i))
示例#12
0
def mkuser():
    i = rint()
    return User.get_or_create(i, "test", "test" + str(i))