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