/shabti/templates/authplus/+package+/templates/miruku.mako
Mako | 171 lines | 167 code | 4 blank | 0 comment | 16 complexity | d3b993e3327a54393ec3610683b36a34 MD5 | raw file
1# -*- coding: utf-8 -*-
2# Miruku information
3<%! from datetime import datetime %>
4<%inherit file="layout.mako"/>
5<%def name="header()">
6<title>${c.title if hasattr(c, 'title') and \
7 c.title else 'Miruku info'|n}</title>
8</%def>
9
10<%def name="body()">
11<style type="text/css">
12h1 {margin-left: 1em; margin-bottom:0; font-size:130%;}
13h1 span.opt {color: #22c;}
14h1 span.name {color: #f33;}
15table.minfo {width:100%; padding:1em; border:1px solid #aaa;}
16div.meta { font-size: 100%; font-family: monospace;
17 padding: 0.33em 1em; border: 1px solid #bbb;
18 min-height: 5em; margin: 1.66em;}
19tr.colh { font-weight: bold; background: #ccc;}
20tr.row { background: #eee }
21tr.row td a {text-decoration: none;}
22td.bool {align: center;}
23div.metadlabel {float: left; color: #a66; width:25%;}
24div.metadval {float: right; font-style:italic;
25 color: #0c0; width:75%;}
26span.tname {color:#22c;}
27span.accept {height:16px; width:24px;
28 /* Do replace this link with one of your own */
29 background: url(
30 'http://www.famfamfam.com/lab/icons/silk/icons/accept.png'
31 ) no-repeat;}
32span.delete {height:16px; width:24px;
33 /* Do replace this link with one of your own */
34 background: url(
35 'http://www.famfamfam.com/lab/icons/silk/icons/delete.png'
36 ) no-repeat;}
37span.delete em, span.accept em {visibility: hidden; font-size:140%;}
38div#snavd {border:1px solid #bbb;padding:0;
39 margin:1em 1.66em 0 1.66em;
40 min-height:1.33em;}
41div#info {margin:-2em 0.5em 0.5em 0.5em; padding: 1em;}
42div.inpctl {float:left;margin-left:2em;}
43</style>
44<h1>Miruku report on action:
45 <span class="opt">${c.opt}</span> on metadata for
46 <span class="name">${c.name|n}</span></h1>
47<div id="snavd">
48 <div class="inpctl">
49 <form name="info" id="info"
50 action="${h.url('miruku_report', opt='info')}"
51 method="post">
52 <input class="butt info" type="submit" value="info"/></form>
53 </div>
54 <div class="inpctl" style="margin-left:2em">
55 <form name="check" id="check"
56 action="${h.url('miruku_report', opt='check')}"
57 method="post">
58 <input class="butt check" type="submit" value="check"/></form>
59 </div>
60 <div class="inpctl" style="margin-left:4em">
61 <form name="upgrade" id="upgrade"
62 action="${h.url('miruku_report', opt='upgrade')}"
63 method="post"
64 onsubmit="javascript:return(confirm('Really upgrade the database?'))"
65 ><input class="butt upgrade" type="submit" value="upgrade"/></form>
66 </div>
67 <div class="inpctl" style="margin-left:2em">
68 <form name="create" id="create"
69 action="${h.url('miruku_report', opt='create')}"
70 method="post"
71 onsubmit="javascript:return(confirm('Really create new metadata?'));"
72 ><input class="butt create" type="submit" value="create"/></form>
73 </div>
74 <div class="inpctl" style="margin-left:4em">
75 <form name="drop" id="drop"
76 action="${h.url('miruku_report', opt='drop')}"
77 method="post"
78 onsubmit="javascript:return(confirm('Really drop the metadata?'));"
79 ><input class="butt dropassoc" type="submit" value="drop association"/></form>
80 </div>
81 <div class="inpctl" style="margin-left:2em">
82 <form name="dropall" id="dropall"
83 action="${h.url('miruku_report', opt='dropall')}"
84 method="post"
85 onsubmit="javascript:return(confirm('Really drop all the tables?'));"
86 ><input class="butt drop" type="submit" value="drop all tables"/></form>
87 </div>
88</div>
89<div style="margin-left:2em">
90<div class="metadlabel">SQLA/elixir/migrate:</div>
91<div class="metadval">${c.versions}</div>
92</div>
93% if not c.content:
94 <div class="meta">
95 <h3>The database is not associated with miruku.</h3>
96 <p>Please run the "miruku create" command first.</p>
97 </div>
98% elif isinstance(c.content, basestring):
99 <div class="meta">
100 <p>${c.content.replace("`",'"')|n}</p>
101 </div>
102% elif isinstance(c.content, list):
103 <div class="meta">
104 <div style="margin: 0.5em; padding: 1em;">
105 % for i in c.content:
106 <p>${i.replace("`",'"')|n}</p>
107 % endfor
108 </div>
109 </div>
110% else:
111 <div class="meta">
112 <div>
113 % for idx, i in enumerate(zip(['Metadata name','Persistence URL', \
114 'Created on','Last updated'], c.content[c.name][0])):
115 <div class="metadlabel">${i[0]}:</div>
116 <div class="metadval">
117 ${i[1].strftime("%a, %b %d %Y %H:%M:%S") \
118 if isinstance(i[1], datetime) else i[1]|n}</div>
119 % if idx == 1:
120 </div>
121 <div>
122 % endif
123 % endfor
124 </div>
125 </div>
126 <div id="info">
127 % for i in sorted(c.content[c.name][1:]):
128 <h3>Table: <span class="tname">
129 % if i[0].find('__') == -1:
130 <a href="/admin/${i[0].capitalize()}/models">${i[0].capitalize()}</a>
131 % else:
132 ${i[0]}
133 % endif
134 </span></h3>
135 <table class="minfo">
136 <tr class="colh">
137 % for idx, j in enumerate(['Column Name', 'Type', \
138 'Primary Key?', 'Nullable?', \
139 'Index?']):
140 <td style="width:20%"
141 ${'align="center"' if idx > 1 else ''|n}
142 >${j}</td>
143 % endfor
144 </tr>
145 % for j in i[1]:
146 <tr class="row">
147 % for idx, k in enumerate(j):
148 <td ${'align="center"' if k in ['True', 'False'] else ''|n}
149 >${'<span class="%s"><em>t/f</em></span>' % \
150 dict(True='accept',False='delete').get(k,'help') \
151 if k in ['True', 'False'] \
152 else '<a href="http://www.sqlalchemy.org/' + \
153 'docs/reference/sqlalchemy/types.html'+\
154 '#sqlalchemy.types.%s">%s</a>' % \
155 (k, k) if idx else k \
156 |n}</td>
157 % endfor
158 </tr>
159 % endfor
160 </table>
161 % endfor
162 </div>
163% endif
164</%def>
165
166<%def name="lhcolumn()">
167</%def>
168
169<%def name="rhcolumn()">
170</%def>
171