Add dashboard_image_url to experiment fixes #122

This commit is contained in:
Jared Kerim 2017-06-29 15:15:03 -04:00 коммит произвёл Jared Kerim
Родитель 2ffb1d2f8b
Коммит 75cb32e3cc
4 изменённых файлов: 32 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-06-29 19:04
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('experiments', '0011_remove_experiment_success_criteria'),
]
operations = [
migrations.AddField(
model_name='experiment',
name='dashboard_image_url',
field=models.URLField(blank=True, null=True),
),
migrations.AlterField(
model_name='experiment',
name='status',
field=models.CharField(choices=[('Not Started', 'Not Started'), ('Started', 'Started'), ('Complete', 'Complete'), ('Rejected', 'Rejected'), ('Invalid', 'Invalid')], default='Not Started', max_length=255),
),
]

Просмотреть файл

@ -44,6 +44,7 @@ class Experiment(models.Model):
start_date = models.DateTimeField(blank=True, null=True)
end_date = models.DateTimeField(blank=True, null=True)
dashboard_url = models.URLField(blank=True, null=True)
dashboard_image_url = models.URLField(blank=True, null=True)
objects = ExperimentManager()

Просмотреть файл

@ -18,6 +18,7 @@ class ExperimentFactory(factory.django.DjangoModelFactory):
objectives = factory.LazyAttribute(lambda o: faker.paragraphs())
analysis = factory.LazyAttribute(lambda o: faker.paragraphs())
dashboard_url = 'http://www.example.com/dashboard'
dashboard_image_url = 'http://www.example.com/dashboard.png'
class Meta:
model = Experiment

Просмотреть файл

@ -3,7 +3,11 @@
{% block content %}
{{ block.super }}
{% if original.dashboard_url %}
{% if original.dashboard_image_url %}
<a target="_blank" href="{{ original.dashboard_url }}">
<img src="{{ original.dashboard_image_url }}" style="width:100%" />
</a>
{% elif original.dashboard_url %}
<iframe src="{{ original.dashboard_url }}" frameborder="0" scrolling="no" width="100%" height="9000px" onload="resizeIframe(this)" />
{% else %}
<h2>Dashboard Unavailable</h2>