Mercurial > hg > ltpdarepo
changeset 163:b666c4b27e33
Add UUID to obj view. Show {xml,mat} download links only if data is present.
author | Daniele Nicolodi <daniele@grinta.net> |
---|---|
date | Fri, 04 Nov 2011 12:18:10 +0100 |
parents | bfa740644fc9 |
children | 86c23f07c5ae |
files | src/ltpdarepo/admin.py src/ltpdarepo/static/style.css src/ltpdarepo/templates/obj.html src/ltpdarepo/views/browse.py |
diffstat | 4 files changed, 47 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ltpdarepo/admin.py Fri Nov 04 11:46:29 2011 +0100 +++ b/src/ltpdarepo/admin.py Fri Nov 04 12:18:10 2011 +0100 @@ -285,8 +285,9 @@ description = random.choice(sentences) analysis = random.choice(sentences) submitted = datetime.utcnow() - timedelta(days=random.randint(0, nobjs / 10.0)) - - curs.execute("""INSERT INTO objs (uuid) VALUES (%s)""", (str(uuid.uuid4()))) + + curs.execute("""INSERT INTO objs (xml, uuid) VALUES (%s, %s)""", + ('<?xml version="1.0" encoding="UTF-8" standalone="no"?>', str(uuid.uuid4()))) objid = curs.lastrowid curs.execute("""INSERT INTO objmeta ( obj_id, obj_type, name, created, version, ip, hostname, os,
--- a/src/ltpdarepo/static/style.css Fri Nov 04 11:46:29 2011 +0100 +++ b/src/ltpdarepo/static/style.css Fri Nov 04 12:18:10 2011 +0100 @@ -639,19 +639,22 @@ /* object display */ .obj { + font-size: 90%; margin: 1.25em 0em; border-collapse: collapse; + width: 100%; } .obj th { + width: 0; text-align: right; white-space: nowrap; - border-bottom: 1px solid #DDD; + border-bottom: 1px dotted #DDD; padding: 0.2em 0.4em; } .obj td { text-align: left; - border-bottom: 1px solid #DDD; + border-bottom: 1px dotted #DDD; padding: 0.2em 0.4em; }
--- a/src/ltpdarepo/templates/obj.html Fri Nov 04 11:46:29 2011 +0100 +++ b/src/ltpdarepo/templates/obj.html Fri Nov 04 12:18:10 2011 +0100 @@ -6,7 +6,25 @@ {% for field in fields %} <tr><th id="{{ field }}">{{ field }}:</th><td>{{ obj[field] is not none and obj[field] or '' }}</td></tr> {% endfor %} - <tr><th>xml:</th><td><a href="{{ url_for('browse.download', frmt='xml', database=database.id, objid=obj.id) }}">download</a></td></tr> - <tr><th>binary:</th><td><a href="{{ url_for('browse.download', frmt='mat', database=database.id, objid=obj.id) }}">download</a></td></tr> + <tr> + <th>xml:</th> + <td> + {% if obj.xml %} + <a href="{{ url_for('browse.download', frmt='xml', database=database.id, objid=obj.id) }}">download</a> + {% else %} + NA + {% endif %} + </td> + </tr> + <tr> + <th>binary:</th> + <td> + {% if obj.mat %} + <a href="{{ url_for('browse.download', frmt='mat', database=database.id, objid=obj.id) }}">download</a> + {% else %} + NA + {% endif %} + </td> + </tr> </table> {% endblock %}
--- a/src/ltpdarepo/views/browse.py Fri Nov 04 11:46:29 2011 +0100 +++ b/src/ltpdarepo/views/browse.py Fri Nov 04 12:18:10 2011 +0100 @@ -444,6 +444,25 @@ fields = FIELDS + EXTRA + # check for mat representation + curs = g.db.cursor() + curs.execute("""SELECT obj_id FROM `%s`.bobjs WHERE obj_id=%%s""" % database, objid) + row = curs.fetchone() + if row is not None: + obj['mat'] = True + + # check for xml representation + curs = g.db.cursor() + curs.execute("""SELECT xml, uuid FROM `%s`.objs WHERE id=%%s""" % database, objid) + xml, uuid = curs.fetchone() + if xml and xml.startswith('<?xml'): + obj['xml'] = True + + # add uuid + obj['uuid'] = uuid + fields += ('uuid', ) + + # collect additional informations if obj['type'] == 'ao': curs = g.db.cursor(DictCursor) curs.execute("""SELECT data_type AS `data type`,