appinfo.py
Go to the documentation of this file.
1 #! /usr/bin/env python
2 
3 """
4 usage: %(progname)s [args]
5 """
6 
7 import os, sys, string, time, getopt, re
8 from pyclearsilver.log import *
9 
10 import neo_cgi, neo_util, neo_cs
11 
12 from pyclearsilver import CSPage
13 from pyclearsilver import odb
14 from launchman import app
15 
16 import MBPage
17 import db_webui
18 import webutil
19 
21  def setup(self, hdf):
22  self.db = db_webui.initSchema()
23 
24  def display(self, hdf):
25  webutil.set_tabs(hdf, ["apps", "appinfo"])
26  webutil.grabTopics(hdf, [])
27  taskid = hdf.getValue("Query.taskid", "")
28  doc = app.App(taskid).load_yaml()
29 
30  prefix = "CGI.cur.app"
31  hdf.setValue(prefix + "." + "taskid", taskid)
32  for key, val in doc.items():
33  if type(val) is list:
34  for i in range(0,len(val)):
35  hdf.setValue(prefix + "." + key + "." + str(i), val[i])
36  elif val is not None:
37  hdf.setValue(prefix + "." + key, val)
38  else:
39  hdf.setValue(prefix + "." + key, '')
40 
41  # for favorite apps
42  user_record = self.authdb.users.lookup(self.username)
43  hdf.setValue("CGI.cur.user.favorite_apps", user_record.favorite_apps)
44 
45  if user_record.is_favorite_app(taskid):
46  hdf.setValue("CGI.cur.app.favorite", "1")
47 
48  def Action_Favorites(self, hdf):
49  taskid = hdf.getValue("Query.taskid", "")
50  doc = app.App(taskid).load_yaml()
51 
52  prefix = "CGI.cur.app"
53  hdf.setValue(prefix + "." + "taskid", taskid)
54 
55  # for favorite apps
56  user_record = self.authdb.users.lookup(self.username)
57  if hdf.getValue("Query.set_favorite", "") == "1":
58  user_record.add_favorite_app(taskid)
59  elif hdf.getValue("Query.set_favorite", "") == "0":
60  user_record.remove_favorite_app(taskid)
61 
62  if user_record.is_favorite_app(taskid):
63  hdf.setValue("CGI.cur.favorite", "1")
64 
65  hdf.setValue("Content", "appinfo_favorites.cs")
66 
67 def run(context):
68  return MyPage(context, pagename="appinfo", nologin=False)
69 
70 def main():
71  context = CSPage.Context()
72  run(context).start()
73 
74 if __name__ == "__main__":
75  main()


webui
Author(s): Scott Hassan
autogenerated on Mon Jun 10 2019 15:51:24