# HG changeset patch # User Daniele Nicolodi # Date 1320405490 -3600 # Node ID b666c4b27e33987e6bedc9e626fbee8dc3a28671 # Parent bfa740644fc9ec615f89960f48fe89b83a7228c9 Add UUID to obj view. Show {xml,mat} download links only if data is present. diff -r bfa740644fc9 -r b666c4b27e33 src/ltpdarepo/admin.py --- 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)""", + ('', str(uuid.uuid4()))) objid = curs.lastrowid curs.execute("""INSERT INTO objmeta ( obj_id, obj_type, name, created, version, ip, hostname, os, diff -r bfa740644fc9 -r b666c4b27e33 src/ltpdarepo/static/style.css --- 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; } diff -r bfa740644fc9 -r b666c4b27e33 src/ltpdarepo/templates/obj.html --- 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 %} {{ field }}:{{ obj[field] is not none and obj[field] or '' }} {% endfor %} - xml:download - binary:download + + xml: + + {% if obj.xml %} + download + {% else %} + NA + {% endif %} + + + + binary: + + {% if obj.mat %} + download + {% else %} + NA + {% endif %} + + {% endblock %} diff -r bfa740644fc9 -r b666c4b27e33 src/ltpdarepo/views/browse.py --- 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('