active.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 import nstart
4 import config
5 import os, sys, string, time
6 
7 from pyclearsilver.log import *
8 
9 from pyclearsilver.CSPage import Context
10 import neo_cgi, neo_cs, neo_util
11 from MBPage import MBPage
12 
13 class ActivePage(MBPage):
14  def setup(self, hdf):
15  self.requestURI = hdf.getValue("Query.request", "")
16  if not self.requestURI:
17  self.requestURI = self.default_app_path()
18 
19  def display(self, hdf):
20  pass
21 
22  def __del__(self):
23  if self.authdb:
24  self.authdb.close()
25  self.authdb = None
26 
27  def Action_Display(self, hdf):
28  if hdf.getValue("Query.dismiss_active_warning", "") == "1":
29  user_record = self.authdb.users.lookup(self.username)
30  user_record.dismiss_notice("active_warning")
31  self.display(hdf)
32 
33  def Action_MakeActive(self, hdf):
34  # if one of the following are true, make the user active
35  if (not self.get_active_user()) or self.is_active_user() or hdf.getValue("Query.override", "") == "1":
36  self.make_active_user(hdf)
37  self.ncgi.cookieClear("inactive")
38 
39  # if the dismiss checkbox was checked, store it in the database
40  if hdf.getValue("Query.dismiss_active_warning", "") == "1":
41  user_record = self.authdb.users.lookup(self.username)
42  user_record.dismiss_notice("active_warning")
43 
44  self.redirectUri(self.requestURI)
45  else:
46  # if this user has already dismissed the active warning page, make them active
47  user_record = self.authdb.users.lookup(self.username)
48  if user_record.notice_dismissed("active_warning"):
49  self.make_active_user(hdf)
50  self.ncgi.cookieClear("inactive")
51  self.redirectUri(self.requestURI)
52  else:
53  # redirect to page warning about active user
54  url = self.http + hdf.getValue("HTTP.Host", "") + config.gBaseURL + "active/active_warning.py?request=%s" % (neo_cgi.urlEscape(hdf.getValue("Query.request", "")))
55  self.redirectUri(url)
56 
57 
58  def Action_MakeInactive(self, hdf):
59  self.ncgi.cookieSet("inactive", "1")
60  if self.is_active_user():
61  self.remove_active_user()
62  self.redirectUri(self.requestURI)
63 
64  def Action_DismissNotice(self, hdf):
65  self.pagename = "notice"
66  user_record = self.authdb.users.lookup(self.username)
67  notice = hdf.getValue("Query.notice", "")
68  if notice != "":
69  user_record.dismiss_notice(notice)
70  hdf.setValue("CGI.cur.value", "OK")
71 
72  def Action_NoticeDismissed(self, hdf):
73  self.pagename = "notice"
74  user_record = self.authdb.users.lookup(self.username)
75  notice = hdf.getValue("Query.notice", "")
76  if user_record.notice_dismissed(notice):
77  hdf.setValue("CGI.cur.value", "YES")
78  else:
79  hdf.setValue("CGI.cur.value", "NO")
80 
81 def run(context):
82  page = ActivePage(context, pagename="active", nologin=False)
83  return page
84 
85 def main(context):
86  page = run(context)
87  page.start()
88 
89 
90 if __name__ == "__main__":
91  main(Context())


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