def get(self): table_name = "pdops.action_citation" sql_query = "SELECT * FROM " + table_name + " where mp_id > '1'" sql_cursor = getDatabaseCursor() sql_response = sql_cursor.executefetchall(sql_query) json = dumpjson({"politicianActionCitation": sql_response}) self.SendJson(json)
def get(self): table_name = "pdops.org" sql_query = "SELECT org_id,name,category_ids,org_pic, description, exclude_googlemap FROM " + table_name + " where featured like '%1%' order by name" sql_cursor = getDatabaseCursor() sql_response = sql_cursor.executefetchall(sql_query) json = dumpjson({"brandList": sql_response}) self.SendJson(json)
def get(self): table_name = "pdops.author" sql_query = "SELECT * FROM " + table_name + " where category_id ='1'" sql_cursor = getDatabaseCursor() sql_response = sql_cursor.executefetchall(sql_query) json = dumpjson({"politicianList": sql_response}) self.SendJson(json)
def get(self): table_name = "pdops.org" sql_query = "SELECT * FROM pdops.org_location" sql_cursor = getDatabaseCursor() sql_response = sql_cursor.executefetchall(sql_query) json = dumpjson({"brandLocation": sql_response}) self.SendJson(json)
def put(self): link = self.requestParam('link') author = self.requestParam('author') position = self.requestParam('position') note = self.requestParam('note') if not position is None: position = int(position) positions = [ model.ArticlePosition(topic=self.requesttopickey, axis=self.requestaxiskey, position=position), ] suggestion = model.Suggest(link=link, author=author, positions=positions, note=note, time=datetime.now()) visitor = self.getVisitor() visitor.articlesuggests.append(suggestion) visitor.put() msg = suggestion.to_dict() msg['visitorid'] = self.visitorkey.id() q = taskqueue.Queue('suggestion-queue') q.add( taskqueue.Task(name="suggest-" + str(self.visitorkey.id()), payload=dumpjson(msg), method='PULL'))
def get(self): authorid = int(self.request.params.get('author_id', None)) res = getDatabaseCursor() r = res.executefetchone( "SELECT least(count(*)/40,1.0) as pctcomplete from (select distinct statement_id FROM pdops.incoming_author_reactions where author_id=%s) as a" % authorid) json = dumpjson({"reactionstats": r}) self.SendJson(json)
def get(self): entitytype = self.request.params.get('citationFor', None) referenceId = int(self.request.params.get('id', None)) statment_citation_json = getCitationForEntityByStatementId( entitytype, referenceId) logging.info("statment_citation_json = %s", statment_citation_json) json_string = dumpjson( {"statmentCitationJson": statment_citation_json}) self.SendJson(json_string)
def get(self): opaquelink = self.requestParam("opaquelink") logging.info("Opaque link is %s" % opaquelink) partyid = getlink(opaquelink, "ppc2015", "party") res = getDatabaseCursor() r = res.executefetchall( "select * from incoming_party_reactions where party_id = %s" % partyid) json = dumpjson({"reactions": r}) self.SendJson(json)
def get(self): opaquelink = self.requestParam("opaquelink") logging.info("Opaque link is %s" % opaquelink) authorid = getlink(opaquelink, "ppc2015", "author") res = getDatabaseCursor() statements = res.executefetchall( "select statement from incoming_author_statements where author_id = %s" % authorid) if len(statements) == 0: return json = dumpjson(statements[-1]) self.SendJson(json)
def get(self): comment_list = [] sql_response = getCommentsCitations() for comment in sql_response: if "visitor_id" in comment: visitor_obj = model.Visitor.get_by_id(comment['visitor_id']) if visitor_obj: comment["name"] = visitor_obj.name else: comment["name"] = "-" comment_list.append(comment) json = dumpjson({"commentList": comment_list}) self.SendJson(json)
def post(self): reaction = int(self.requestParam("reaction")) statementid = self.requestParam("statementid") comment = str(self.requestParam("comment")) visitorid = self.session.get("visitorid", None) source = "PositionDial comment" comment_date = datetime.now().strftime("%Y-%m-%d %H:%M:%S") sql_query = "INSERT INTO pdops.reaction_citation (reaction, statement_id, visitor_id, origin, citation, made_date) VALUES (%s,%s,%s,\'%s\',\'%s\',\'%s\')" % ( reaction, statementid, visitorid, source, comment, comment_date) logging.info(sql_query) sql_cursor = getDatabaseCursor() sql_response = sql_cursor.executefetchall(sql_query) logging.info("sql_response = %s", sql_response) json = dumpjson({"success": True}) self.SendJson(json, expiry=1)
def get(self): sql_response = getCampaigns() json = dumpjson({"campaignList": sql_response}) self.SendJson(json)