def insert_record_into(self, tread, record, board=get_simple_board()): '''NEED FULL LEGIT RECORD!!! USE ALL PARAMETRS IN GET_SIMPLE_RECORD!!!''' its_records = "records" + board.records_name its_treads = "treads" + board.treads_name self.conection.execute( """ INSERT INTO %s (name, email, title, post, image, tread_id) VALUES (:name, :email, :title, :post, :image, :tread_id) """ % (its_records, ), { "name": record.name, "email": record.email, "title": record.title, "post": record.post, "image": record.image, "tread_id": tread.id }) if record.email != "sage": # update time of last adding self.conection.execute( """ UPDATE %s SET last_time = :timestamp WHERE id = :id """ % (its_treads, ), { "timestamp": now_timestamp(), "id": tread.id }) self.conection.commit()
def b(request): template = Template('b.html') test = models.Model() tread = models.Tread(1, now_timestamp()) testlist = test.get_all_records_from(tread) context = Context({'lol': testlist}) result = template.render(context) return HttpResponse(result)
def add_new_tread_to_board_by_record(self, record=get_simple_record(), board=get_simple_board()): '''NEED FULL LEGIT RECORD!!! USE ALL PARAMETRS IN GET_SIMPLE_RECORD!!!''' its_records = "records" + board.records_name its_treads = "treads" + board.treads_name self.conection.execute( """ INSERT INTO %s (name, email, title, post, image, tread_id) VALUES (:name, :email, :title, :post, :image, :tread_id) """ % (its_records, ), { "name": record.name, "email": record.email, "title": record.title, "post": record.post, "image": record.image, "tread_id": record.id }) self.conection.commit() self.cur.execute(''' SELECT * FROM %s ORDER BY id DESC LIMIT 1 ''' % (its_records)) record = self._tuple_to_obj(self.cur.fetchone(), Record) self.conection.execute( """ INSERT INTO %s (id, last_time) VALUES (:id, :last_time) """ % (its_treads, ), { "id": record.id, "last_time": now_timestamp() }) self.conection.commit() self.cur.execute(''' SELECT * FROM %s ORDER BY id DESC LIMIT 1 ''' % (its_treads)) tread = self._tuple_to_obj(self.cur.fetchone(), Tread) self.conection.execute( """ UPDATE %s SET tread_id = :tread_id WHERE id = :id """ % (its_records, ), { "tread_id": tread.id, "id": record.id }) self.conection.commit()
def __init__(self, T_id = 1, timestamp = now_timestamp(), name = "Anonymous", email = "", title = "", post = "", image = "", tread_id = 1): self.id = T_id self.timestamp = timestamp self.name = name self.email = email self.title = title self.post = post self.image = image self.tread_id = tread_id
def insert_record_into(self, tread, record, board = get_simple_board()): '''NEED FULL LEGIT RECORD!!! USE ALL PARAMETRS IN GET_SIMPLE_RECORD!!!''' its_records = "records" + board.records_name its_treads = "treads" + board.treads_name self.conection.execute(""" INSERT INTO %s (name, email, title, post, image, tread_id) VALUES (:name, :email, :title, :post, :image, :tread_id) """ % (its_records,), {"name": record.name, "email": record.email, "title": record.title, "post": record.post, "image": record.image, "tread_id": tread.id}) if record.email!="sage": # update time of last adding self.conection.execute(""" UPDATE %s SET last_time = :timestamp WHERE id = :id """ % (its_treads,), {"timestamp": now_timestamp(), "id": tread.id}) self.conection.commit()
def add_new_tread_to_board_by_record(self, record = get_simple_record(), board = get_simple_board()): '''NEED FULL LEGIT RECORD!!! USE ALL PARAMETRS IN GET_SIMPLE_RECORD!!!''' its_records = "records" + board.records_name its_treads = "treads" + board.treads_name self.conection.execute(""" INSERT INTO %s (name, email, title, post, image, tread_id) VALUES (:name, :email, :title, :post, :image, :tread_id) """ % (its_records,), {"name": record.name, "email": record.email, "title": record.title, "post": record.post, "image": record.image, "tread_id": record.id}) self.conection.commit() self.cur.execute(''' SELECT * FROM %s ORDER BY id DESC LIMIT 1 ''' % (its_records)) record = self._tuple_to_obj(self.cur.fetchone(), Record) self.conection.execute(""" INSERT INTO %s (id, last_time) VALUES (:id, :last_time) """ % (its_treads,), {"id": record.id, "last_time": now_timestamp()}) self.conection.commit() self.cur.execute(''' SELECT * FROM %s ORDER BY id DESC LIMIT 1 ''' % (its_treads)) tread = self._tuple_to_obj(self.cur.fetchone(), Tread) self.conection.execute(""" UPDATE %s SET tread_id = :tread_id WHERE id = :id """ % (its_records,), {"tread_id": tread.id, "id": record.id}) self.conection.commit()
def get_simple_tread(last_time = now_timestamp()): return Tread(1, last_time)