def make_participant(self, username, **kw): # At this point wireup.db() has been called, but not ... wireup.username_restrictions(self.client.website) participant = Participant.with_random_username() participant.change_username(username) if 'elsewhere' in kw or 'claimed_time' in kw: username = participant.username platform = kw.pop('elsewhere', 'github') self.seq += 1 self.db.run(""" INSERT INTO elsewhere (platform, user_id, user_name, participant) VALUES (%s,%s,%s,%s) """, (platform, self.seq, username, username)) # brute force update for use in testing for k,v in kw.items(): if k == 'claimed_time': if v == 'now': v = datetime.datetime.now(pytz.utc) self.db.run("UPDATE participants SET {}=%s WHERE username=%s" \ .format(k), (v, participant.username)) participant.set_attributes(**kw) return participant
def make_participant(self, username, **kw): # At this point wireup.db() has been called, but not ... wireup.username_restrictions(self.client.website) participant = Participant.with_random_username() participant.change_username(username) if 'elsewhere' in kw or 'claimed_time' in kw: username = participant.username platform = kw.pop('elsewhere', 'github') self.seq += 1 self.db.run( """ INSERT INTO elsewhere (platform, user_id, user_name, participant) VALUES (%s,%s,%s,%s) """, (platform, self.seq, username, username)) # brute force update for use in testing for k, v in kw.items(): if k == 'claimed_time': if v == 'now': v = datetime.datetime.now(pytz.utc) self.db.run("UPDATE participants SET {}=%s WHERE username=%s" \ .format(k), (v, participant.username)) participant.set_attributes(**kw) return participant
def make_participant(self, username, **kw): # At this point wireup.db() has been called, but not ... wireup.username_restrictions(self.client.website) participant = Participant.with_random_username() participant.change_username(username) return self.update_participant(participant, **kw)
def make_participant(self, username, **kw): # At this point wireup.db() has been called, but not ... wireup.username_restrictions(self.client.website) participant = Participant.with_random_username() participant.change_username(username) if 'elsewhere' in kw or 'claimed_time' in kw: username = participant.username platform = kw.pop('elsewhere', 'github') self.seq += 1 self.db.run( """ INSERT INTO elsewhere (platform, user_id, user_name, participant) VALUES (%s,%s,%s,%s) """, (platform, self.seq, username, username)) # Update participant if kw: if kw.get('claimed_time') == 'now': kw['claimed_time'] = utcnow() cols, vals = zip(*kw.items()) cols = ', '.join(cols) placeholders = ', '.join(['%s'] * len(vals)) participant = self.db.one( """ UPDATE participants SET ({0}) = ({1}) WHERE username=%s RETURNING participants.*::participants """.format(cols, placeholders), vals + (participant.username, )) return participant
def make_participant(self, username, **kw): # At this point wireup.db() has been called, but not ... wireup.username_restrictions(self.client.website) participant = Participant.with_random_username() participant.change_username(username) if 'elsewhere' in kw or 'claimed_time' in kw: username = participant.username platform = kw.pop('elsewhere', 'github') self.seq += 1 self.db.run(""" INSERT INTO elsewhere (platform, user_id, user_name, participant) VALUES (%s,%s,%s,%s) """, (platform, self.seq, username, username)) # Update participant if kw: if kw.get('claimed_time') == 'now': kw['claimed_time'] = utcnow() cols, vals = zip(*kw.items()) cols = ', '.join(cols) placeholders = ', '.join(['%s']*len(vals)) participant = self.db.one(""" UPDATE participants SET ({0}) = ({1}) WHERE username=%s RETURNING participants.*::participants """.format(cols, placeholders), vals+(participant.username,)) return participant
def make_participant(self, username, **kw): participant = Participant.with_random_username() participant.change_username(username) # brute force update for use in testing for k,v in kw.items(): if k == 'claimed_time': if v == 'now': v = datetime.datetime.now(pytz.utc) self.db.run("UPDATE participants SET {}=%s WHERE username=%s" \ .format(k), (v, participant.username)) participant.set_attributes(**kw) return participant
def make_participant(self, username, **kw): participant = Participant.with_random_username() participant.change_username(username) # brute force update for use in testing for k, v in kw.items(): if k == 'claimed_time': if v == 'now': v = datetime.datetime.now(pytz.utc) self.db.run("UPDATE participants SET {}=%s WHERE username=%s" \ .format(k), (v, participant.username)) participant.set_attributes(**kw) return participant