Пример #1
0
 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)
Пример #2
0
 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)
Пример #3
0
 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)
Пример #4
0
 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)
Пример #5
0
    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'))
Пример #6
0
 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)
Пример #7
0
 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)
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
 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)
Пример #11
0
 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)
Пример #12
0
 def get(self):
     sql_response = getCampaigns()
     json = dumpjson({"campaignList": sql_response})
     self.SendJson(json)