Ejemplo n.º 1
0
 def insert_acks(self, user, acks, haiku):
     ack_time = Util.adjust_ack_ts(datetime.datetime.now(pytz.utc))
     conn = Util.get_db_conn()
     cur = conn.cursor()
     for ack in acks:
         cur.execute(
             "INSERT INTO ack (msg, inserted_at, user_email) VALUES (%s, %s, %s)",
             (ack, ack_time, user))
     haiku = haiku.rstrip()
     if len(haiku) > 0:
         cur.execute(
             "INSERT INTO ack (msg, inserted_at, user_email) VALUES (%s, %s, %s)",
             (haiku, ack_time, user))
     conn.commit()
     cur.close()
     conn.close()
Ejemplo n.º 2
0
    def do_get(self, handler):
        handler.send_response(200)
        handler.send_header('Content-type', 'text/html')
        handler.end_headers()

        self.common_headers(handler.wfile)
        self.write(handler.wfile, "<body>")
        user_email = Auth.get_user_email(handler)
        self.menu_bar(handler.wfile)

        num_acks, bounty = self.just_inserted(handler)
        if num_acks != 0:
            self.ack_butterbar(handler.wfile,
                               '%d peer ack(s) saved :thumb-up:' % (num_acks))
        elif bounty:
            self.ack_butterbar(handler.wfile, 'bounty saved :thumb-up:')

        now = datetime.datetime.now(pytz.utc)
        adjusted = Util.adjust_ack_ts(now)
        self.report_header(
            handler.wfile,
            Util.report(adjusted, slack=False),
            generate_links=False,
            msg="Sending acks for week:",
        )

        self.generate_bounty_pane(handler.wfile)

        msg = """
            <p1>How did they poke their head above the Roach's high expectations this week?
            <p>
            <form action=/ack method=post accept-charset="UTF-8">
                <fieldset id="fieldset" disabled="true">
                    One ack per line:<br><textarea name=ack rows="10" cols="80"></textarea>
                    <p>
                    Haiku (one multi-line ack):<br><textarea name=haiku rows="4" cols="80"></textarea><br>
                    <input type=submit><br>
                </fieldset>

                <fieldset id="fieldset-eng-updates" disabled="true">
                    Engineering updates: <img src="question-mark.png" height="16px" title="Suggest eng updates to Peter. Brag about your PR, your friend's PR, shout about a scary issue.">
                    <br><textarea name=eng-updates rows="4" cols="80"></textarea><br>
                    <input type=submit><br>
                </fieldset>
            </form>
        """
        self.write(handler.wfile, msg)

        self.write(handler.wfile, "<p>Suggested eng updates:<br>")
        userID = Auth.get_user_email(handler)
        if userID is None:
            self.write(handler.wfile, "Not logged in")
        else:
            self.write(handler.wfile, "\n<table>\n")
            now = datetime.datetime.now(pytz.utc)
            report = Util.report(now)
            eng_updates = DB.get_eng_updates(report, None)
            for update in eng_updates:
                self.render_eng_update(handler.wfile, update)
            self.write(handler.wfile, "\n</table>\n")
        self.write(handler.wfile, "\n</body></html>\n")