wrapper.fhtml: Add `license' relationship to the AGPL link.
[chopwood] / cmd-cgi.py
index 57de66c..f6bbe94 100644 (file)
@@ -58,12 +58,14 @@ def operate(what, op, services, *args, **kw):
 @CGI.subcommand('list', ['cgi-query'], 'List available accounts')
 def cmd_list_cgi():
   CGI.page('list.fhtml',
+           header = dict(pragma = 'no-cache', cache_control = 'no-cache'),
            title = 'Chopwood: accounts list',
            accts = CU.list_accounts(CU.USER),
            nonce = HA.NONCE)
 
 @CGI.subcommand(
   'set', ['cgi'], 'Set password for a collection of services.',
+  methods = ['POST'],
   params = [SC.Arg('first'), SC.Arg('second')],
   rparam = SC.Arg('services'))
 def cmd_set_cgi(first, second, services = []):
@@ -73,6 +75,7 @@ def cmd_set_cgi(first, second, services = []):
 @CGI.subcommand(
   'reset', ['cgi'],
   'Reset passwords for a collection of services.',
+  methods = ['POST'],
   rparam = SC.Arg('services'))
 def cmd_reset_cgi(services = []):
   operate('reset passwords', 'reset', services)
@@ -80,11 +83,20 @@ def cmd_reset_cgi(services = []):
 @CGI.subcommand(
   'clear', ['cgi'],
   'Clear passwords for a collection of services.',
+  methods = ['POST'],
   rparam = SC.Arg('services'))
 def cmd_clear_cgi(services = []):
   operate('clear passwords', 'clear', services)
 
 @CGI.subcommand(
+  'logout', ['cgi'],
+  'Log out of the web interface.',
+  methods = ['POST'])
+def cmd_logout_cgi():
+  CGI.redirect(CGI.action('login', why = 'LOGOUT'),
+               set_cookie = HA.bake_cookie('logged-out'))
+
+@CGI.subcommand(
   'fail', ['cgi-noauth'],
   'Raise an exception, to test the error reporting machinery.',
   opts = [SC.Opt('partial', '-p', '--partial',
@@ -100,6 +112,17 @@ def cmd_fail_cgi(partial = False):
 <p>This is some normal output which will be rudely interrupted.""")
   raise Exception, 'You asked for this.'
 
+@CGI.subcommand(
+  'warn', ['cgi-noauth'],
+  'Raise an exception, to test the error reporting machinery.')
+def cmd_warn_cgi():
+  OUT.header(content_type = 'text/html')
+  OUT.warn("Here's a very important warning.")
+  CGI.format_tmpl(CGI.TMPL['wrapper.fhtml'],
+                  title = "Warning test", warnings = OUT.warnings,
+                  payload = "<h1>Chopwood: warning test</h1>\n"
+                  "<p>There ought to be a warning below.\n")
+
 ###--------------------------------------------------------------------------
 ### Static content.