Browse Source

Add dataset thumbnails

Matthias Vogelgesang 7 years ago
parent
commit
d61d6df8a2
3 changed files with 38 additions and 0 deletions
  1. 30 0
      migrations/versions/d34c125c98cc_.py
  2. 2 0
      nova/models.py
  3. 6 0
      nova/templates/collection/list.html

+ 30 - 0
migrations/versions/d34c125c98cc_.py

@@ -0,0 +1,30 @@
+"""Add has_thumbnail to Dataset
+
+Revision ID: d34c125c98cc
+Revises: 6867197a0fb9
+Create Date: 2016-09-30 14:36:07.835761
+
+"""
+
+# revision identifiers, used by Alembic.
+revision = 'd34c125c98cc'
+down_revision = '6867197a0fb9'
+
+from alembic import op
+import sqlalchemy as sa
+
+
+def upgrade():
+    ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('datasets', schema=None) as batch_op:
+        batch_op.add_column(sa.Column('has_thumbnail', sa.Boolean(), nullable=True))
+
+    ### end Alembic commands ###
+
+
+def downgrade():
+    ### commands auto generated by Alembic - please adjust! ###
+    with op.batch_alter_table('datasets', schema=None) as batch_op:
+        batch_op.drop_column('has_thumbnail')
+
+    ### end Alembic commands ###

+ 2 - 0
nova/models.py

@@ -87,6 +87,8 @@ class Dataset(db.Model):
     closed = db.Column(db.Boolean, default=False)
     collection_id = db.Column(db.Integer, db.ForeignKey('collections.id'))
 
+    has_thumbnail = db.Column(db.Boolean, default=False)
+
     collection = db.relationship('Collection')
     accesses = db.relationship('Access', cascade='all, delete, delete-orphan')
 

+ 6 - 0
nova/templates/collection/list.html

@@ -13,7 +13,13 @@
 {% for dataset in collection.datasets %}
 <div class="row dataset-pad">
   <div class="col-lg-1">
+    {% if dataset.has_thumbnail %}
+    <img class="img-responsive" src="{{ url_for("show_dataset",
+    name=collection.user.name, collection_name=collection.name,
+    dataset_name=dataset.name, path='.thumb.jpg') }}"/>
+    {% else %}
     <img class="img-responsive" src="https://placeholdit.imgix.net/~text?txtsize=33&txt=%C3%97&w=64&h=64"/>
+    {% endif %}
   </div>
   <div class="col-lg-11">
     <h3 class="dataset-link">