Exemplo n.º 1
0
    def post(self, completed, planned, tags, isedit=False, **kwargs):
        loginid = cherrypy.request.loginid

        assert cherrypy.request.method.upper() == 'POST'

        cur = model.get_cursor()

        cur.execute(
            '''SELECT IFNULL(email, userid)
                       FROM users
                       WHERE userid = ?''', (loginid, ))
        email, = cur.fetchone()

        completed = completed or None
        planned = planned or None
        tags = tags or None

        today = util.today().toordinal()
        now = util.now()
        bugs = kwargs_to_buglist(kwargs)

        if isedit:
            cur.execute(
                '''UPDATE posts
                           SET completed = ?, planned = ?, tags = ?, posttime = ?
                           WHERE userid = ?
                             AND postdate = (
                               SELECT lastpostdate FROM (
                                 SELECT MAX(postdate) AS lastpostdate
                                 FROM posts AS p2
                                 WHERE p2.userid = ?
                               ) AS maxq
                             )''',
                (completed, planned, tags, now, loginid, loginid))
        else:
            cur.execute(
                '''INSERT INTO posts
                           (userid, postdate, posttime, completed, planned, tags)
                           VALUES (?, ?, ?, ?, ?, ?)''',
                (loginid, today, now, completed, planned, tags))

        for bug in bugs:
            model.save_bugstatus(cur, loginid, bug, today)
        allteam, sendnow = model.get_userteam_emails(loginid)
        if isinstance(completed, str):
            completed = completed.decode("utf-8")
        if isinstance(planned, str):
            planned = planned.decode("utf-8")
        if isinstance(tags, str):
            tags = tags.decode("utf-8")
        if len(sendnow):
            mail.sendpost(
                email, sendnow,
                model.create_post_with_bugs(
                    (loginid, today, now, completed, planned, tags), None,
                    bugs))

        raise cherrypy.HTTPRedirect(cherrypy.url('/'))
Exemplo n.º 2
0
    def post(self, completed, planned, tags, isedit=False, **kwargs):
        loginid = cherrypy.request.loginid

        assert cherrypy.request.method.upper() == 'POST'

        cur = model.get_cursor()

        cur.execute('''SELECT IFNULL(email, userid)
                       FROM users
                       WHERE userid = ?''',
                    (loginid,))
        email, = cur.fetchone()

        completed = completed or None
        planned = planned or None
        tags = tags or None

        today = util.today().toordinal()
        now = util.now()
        bugs = kwargs_to_buglist(kwargs)

        if isedit:
            cur.execute('''UPDATE posts
                           SET completed = ?, planned = ?, tags = ?, posttime = ?
                           WHERE userid = ?
                             AND postdate = (
                               SELECT lastpostdate FROM (
                                 SELECT MAX(postdate) AS lastpostdate
                                 FROM posts AS p2
                                 WHERE p2.userid = ?
                               ) AS maxq
                             )''',
                        (completed, planned, tags, now, loginid, loginid))
        else:
            cur.execute('''INSERT INTO posts
                           (userid, postdate, posttime, completed, planned, tags)
                           VALUES (?, ?, ?, ?, ?, ?)''',
                        (loginid, today, now, completed, planned, tags))

        for bug in bugs:
            model.save_bugstatus(cur, loginid, bug, today)
        allteam, sendnow = model.get_userteam_emails(loginid)
        if isinstance(completed, str):
            completed = completed.decode("utf-8")
        if isinstance(planned, str):
            planned = planned.decode("utf-8")
        if isinstance(tags, str):
            tags = tags.decode("utf-8")
        if len(sendnow):
            mail.sendpost(email, sendnow,
                          model.create_post_with_bugs((loginid, today, now,
                                completed, planned, tags), None, bugs))

        raise cherrypy.HTTPRedirect(cherrypy.url('/'))
Exemplo n.º 3
0
    def preview(self, completed, planned, tags, **kwargs):
        assert cherrypy.request.method.upper() == 'POST'

        today = util.today().toordinal()
        now = util.now()
        bugs = kwargs_to_buglist(kwargs)
        if isinstance(completed, str):
            completed = completed.decode("utf-8")
        if isinstance(planned, str):
            planned = planned.decode("utf-8")
        if isinstance(tags, str):
            tags = tags.decode("utf-8")
        post = model.create_post_with_bugs(('<preview>', today, now, completed, planned, tags), None, bugs)
        return render('preview.xhtml', post=post)
Exemplo n.º 4
0
    def preview(self, completed, planned, tags, **kwargs):
        assert cherrypy.request.method.upper() == 'POST'

        today = util.today().toordinal()
        now = util.now()
        bugs = kwargs_to_buglist(kwargs)
        if isinstance(completed, str):
            completed = completed.decode("utf-8")
        if isinstance(planned, str):
            planned = planned.decode("utf-8")
        if isinstance(tags, str):
            tags = tags.decode("utf-8")
        post = model.create_post_with_bugs(
            ('<preview>', today, now, completed, planned, tags), None, bugs)
        return render('preview.xhtml', post=post)