source: cows_wps/trunk/cows_wps/controllers/view.py @ 7095

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows_wps/trunk/cows_wps/controllers/view.py@7095
Revision 7095, 2.3 KB checked in by astephen, 9 years ago (diff)

fixing up jobs page and moving renderer code into renderer package

Line 
1import logging
2
3from pylons import request, response, session, tmpl_context as c
4from pylons.controllers.util import abort, redirect_to
5
6from cows_wps.renderer.ui_renderer import *
7from cows_wps.renderer.proc_config_renderer import *
8from cows_wps.controllers import *
9from cows_wps.lib.ui.proc_config import *
10
11log = logging.getLogger(__name__)
12
13
14class ViewController(BaseController):
15
16    def index(self):
17        """
18        Shows a table of all procs.
19        """
20#        pc = ProcConfig()
21        pcr = ProcConfigRenderer()
22        resp = pcr.renderProcsViewTable()
23
24        renderer = UIPageRenderer()
25#        c.tester = "tester"
26        resp = renderer.render("View available processes",
27                               [("Select your process", resp)])
28        return resp
29
30    def list(self):
31        """
32        Shows a drop-down list of possible procs to choose from.
33        """
34        pc = ProcConfig()
35        procs = pc.getProcList()
36 
37        resp = """      <form action="/view/proc2">
38                <p>Please select a process from the drop-down menu below and press 'GO' to view its detailed description.</p>
39                <select name="proc_id">"""
40     
41        for (proc, long_name) in procs.items():
42            resp += ('                  <option name="%s" value="%s">%s</option>\n' % (proc, proc, long_name))
43
44        resp += """             </select>
45                <input type="submit" value="GO" />
46        </form>"""
47
48        renderer = UIPageRenderer()
49        resp = renderer.render("View available processes",
50                               [("Select your process", resp)])
51
52        return resp
53
54    def proc(self):
55        """
56        Show specific view of process.
57        """
58        proc = str(request.params.get("proc_id", None))
59        if proc == None:
60            return "Please provide an argument proc=&lt;Something&gt;"
61
62#        pc = ProcConfig()
63#        proc_view_html = pc.renderProcConfig(proc)
64        pcr = ProcConfigRenderer()
65        proc_view_html = pcr.renderProcConfig(proc)
66
67        resp = "\n".join(proc_view_html)
68
69        renderer = UIPageRenderer()
70        resp = renderer.render("Process Description for: '%s'" % proc,
71                               [("Process: %s" % proc, resp),
72                                ("Submit a job", '<a href="/submit/form?proc_id=%s">Submit a %s request.</a>' % (proc, proc))])
73        return resp
74       
Note: See TracBrowser for help on using the repository browser.