commit
941b64090b
|
@ -0,0 +1,20 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('base', '0013_remove_station_featured'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='station',
|
||||
name='image',
|
||||
field=models.ImageField(upload_to=b'ground_stations', blank=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
|
@ -1,6 +1,7 @@
|
|||
from django.core.validators import MaxValueValidator, MinValueValidator
|
||||
from django.db import models
|
||||
from django.utils.timezone import now
|
||||
from django.conf import settings
|
||||
|
||||
from network.users.models import User
|
||||
|
||||
|
@ -30,7 +31,7 @@ class Station(models.Model):
|
|||
"""Model for SatNOGS ground stations."""
|
||||
owner = models.ForeignKey(User)
|
||||
name = models.CharField(max_length=45)
|
||||
image = models.ImageField(upload_to='ground_stations')
|
||||
image = models.ImageField(upload_to='ground_stations', blank=True)
|
||||
alt = models.PositiveIntegerField(help_text='In meters above ground')
|
||||
lat = models.FloatField(validators=[MaxValueValidator(90),
|
||||
MinValueValidator(-90)])
|
||||
|
@ -45,6 +46,12 @@ class Station(models.Model):
|
|||
online = models.BooleanField(default=False,
|
||||
help_text='Is your Ground Station functional?')
|
||||
|
||||
def get_image(self):
|
||||
if self.image and hasattr(self.image, 'url'):
|
||||
return self.image.url
|
||||
else:
|
||||
return settings.STATION_DEFAULT_IMAGE
|
||||
|
||||
def __unicode__(self):
|
||||
return "%d - %s" % (self.pk, self.name)
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ STATICFILES_FINDERS = (
|
|||
MEDIA_ROOT = path.join(BASE_DIR, 'media')
|
||||
MEDIA_URL = '/media/'
|
||||
CRISPY_TEMPLATE_PACK = 'bootstrap3'
|
||||
STATION_DEFAULT_IMAGE = '/static/images/dish.png'
|
||||
|
||||
# App conf
|
||||
ROOT_URLCONF = 'network.urls'
|
||||
|
|
|
@ -138,6 +138,6 @@
|
|||
}
|
||||
|
||||
.station-edit-image {
|
||||
width: 20px;
|
||||
width: 200px;
|
||||
float: right;
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 7.5 KiB |
|
@ -77,7 +77,7 @@
|
|||
{% endfor %}
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<img src="{{ MEDIA_URL }}{{ station.image }}"
|
||||
<img src="{{ station.get_image }}"
|
||||
class="station-view-image"
|
||||
alt="{{ station.name }}"
|
||||
title="{{ station.name }}">
|
||||
|
|
Loading…
Reference in New Issue