示例#1
0
文件: h_new.py 项目: azmun/webbot
 def getWithUser(self):
     committeeId = self.wbUser.getCommittee()
     if committeeId == None:
         self.response.out.write('<html><body><p>Internal error: no committee.</p></body></html>')
         return
     committee = dblayer.getCommitteeHusk(committeeId)
     abbr = committee["abbreviationEnglish"] if committee["language"] == ENGLISH else committee["abbreviationSpanish"]
     committeeOptions = '<option value="%d">%s</option>' % (committeeId, abbr)
     topics = dblayer.getCommitteeTopics(committeeId)
     indexOptions = {tup[2]: self.getTopicIndexOptions(tup[2], committeeId) for tup in topics}
     indexOptionsStr = json.dumps(indexOptions)
     path = os.path.join(os.path.dirname(__file__), 'new_resolution.html')
     if committee["language"] == ENGLISH:
         topicNames = [t[0] for t in topics]
     else:
         topicNames = [t[1] for t in topics]
     topicIndices = [t[2] for t in topics]
     topicOptions = string.join(['<option value="%d">%d) %s</option>' % (idx, idx, val) for val, idx in zip(topicNames, topicIndices)])
     if len(indexOptions) > 0:
         firstTopicIndexOptions = indexOptions[topics[0][2]]
     else:
         firstTopicIndexOptions = ''
     self.response.out.write(template.render(path,
         {
             "firstTopicIndexOptions": firstTopicIndexOptions,
             "committeeOptions": committeeOptions,
             "indexOptions": indexOptionsStr,
             "topicOptions": topicOptions
         }))
示例#2
0
 def getWithUser(self):
     committeeId = self.wbUser.getCommittee()
     if committeeId == None:
         self.response.out.write("<html><body><p>Internal error: no committee.</p></body></html>")
         return
     currentTopics = [
         {"index": row[2], "englishName": row[0], "spanishName": row[1]}
         for row in dblayer.getCommitteeTopics(committeeId)
     ]
     languageName = Enums.Reverse["language"][dblayer.getCommitteeLanguage(committeeId)]
     path = os.path.join(os.path.dirname(__file__), "new_topic.html")
     self.response.out.write(
         template.render(
             path, {"languageName": json.dumps(languageName), "currentTopics": json.dumps(currentTopics)}
         )
     )