1
0
Fork 0

Simplify home page

* Use home page only for anonymous users
environments/stage/deployments/82
Nikos Roussos 2018-02-18 22:35:45 +02:00
parent 4fea62c35a
commit e44179104a
No known key found for this signature in database
GPG Key ID: BADFF1767BA7C8E1
6 changed files with 49 additions and 228 deletions

View File

@ -60,21 +60,11 @@ def satellite_position(request, sat_id):
def index(request):
"""View to render index page."""
observations = Observation.objects.all()
try:
featured_station = Station.objects.exclude(status=0).latest('featured_date')
except Station.DoesNotExist:
featured_station = None
if request.user.is_authenticated():
return redirect(reverse('users:view_user', kwargs={"username": request.user.username}))
ctx = {
'latest_observations': observations.filter(end__lt=now()).order_by('-id')[:10],
'scheduled_observations': observations.filter(end__gte=now()),
'featured_station': featured_station,
'mapbox_id': settings.MAPBOX_MAP_ID,
'mapbox_token': settings.MAPBOX_TOKEN
}
return render(request, 'base/home.html', ctx)
return render(request, 'base/home.html', {'mapbox_id': settings.MAPBOX_MAP_ID,
'mapbox_token': settings.MAPBOX_TOKEN})
def custom_404(request):

View File

@ -83,5 +83,8 @@ footer {
}
.navbar-default {
background-color: white;
.home & {
background-color: white;
}
}

View File

@ -15,8 +15,12 @@
.call2action {
height: 80px;
margin-top: 70vh;
margin-bottom: 15vh;
position: absolute;
bottom: 20vh;
left: 50%;
transform: translateX(-50%);
width: 700px;
max-width: 100%;
}
.call2action h3 {

View File

@ -20,7 +20,7 @@
</head>
<body>
<body {% block body-class %}{% endblock %}>
{{ stage_notice }}
{% block prenav-content %}{% endblock %}
@ -110,24 +110,26 @@
{% block modal %}{% endblock modal %}
<footer>
<div class="container">
<hr>
<div class="row">
<div class="col-md-6">
<span class="glyphicon glyphicon-copyright-mark" aria-hidden="true"></span> 2014<span id="copy"></span>
<a href="https://libre.space/" target="_blank">Libre Space Foundation</a>.<br>
<span class="glyphicon glyphicon-cloud" aria-hidden="true"></span>
Observation data are freely distributed under the
<a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank">CC BY-SA</a> license.
</div>
<div class="col-md-6 text-right footer-options">
<a href="https://satnogs.org/" target="_blank">SatNOGS</a> |
<a href="#top">Back to top</a>
{% block footer %}
<footer>
<div class="container">
<hr>
<div class="row">
<div class="col-md-6">
<span class="glyphicon glyphicon-copyright-mark" aria-hidden="true"></span> 2014<span id="copy"></span>
<a href="https://libre.space/" target="_blank">Libre Space Foundation</a>.<br>
<span class="glyphicon glyphicon-cloud" aria-hidden="true"></span>
Observation data are freely distributed under the
<a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank">CC BY-SA</a> license.
</div>
<div class="col-md-6 text-right footer-options">
<a href="https://satnogs.org/" target="_blank">SatNOGS</a> |
<a href="#top">Back to top</a>
</div>
</div>
</div>
</div>
</footer>
</footer>
{% endblock %}
{% compress js %}
<script src="{% static 'lib/jquery/dist/jquery.min.js' %}"></script>

View File

@ -9,205 +9,27 @@
<link rel="stylesheet" href="{% static 'lib/mapbox-gl/dist/mapbox-gl.css' %}">
{% endblock css %}
{% block body-class %}class="home"{% endblock %}
{% block prenav-content %}
<div id="map" data-mapboxid="{{ mapbox_id }}" data-mapboxtoken="{{ mapbox_token }}" data-stations="{% url 'base:stations_all' %}"></div>
{% endblock prenav-content %}
{% block content %}
<div class="row call2action">
{% if not request.user.is_authenticated %}
<div class="col-md-8 col-md-offset-2 panel panel-default">
<h3 class="text-center">
Crowd-sourced satellite operations
<button type="button"
class="btn btn-primary"
data-toggle="modal"
data-target="#joinModal">
Join us!
</button>
</h3>
</div>
{% endif %}
</div>
<div class="row home">
{% if featured_station %}
<div class="col-md-4">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Featured Ground Station</h3>
</div>
<div class="panel-body">
<div class="text-center">
<img src="{{ featured_station.get_image }}"
class="img-gs-front"
alt="{{ featured_station.name }}"
title="{{ featured_station.name }}">
<h3>
<a href="{% url 'base:station_view' id=featured_station.id %}">
{{ featured_station.name }}
</a>
</h3>
</div>
<div class="caption">
<div class="front-line">
<span class="label label-default">Owner</span>
<span class="front-data">
<a href="{% url 'users:view_user' username=featured_station.owner.username %}">
{{ featured_station.owner.displayname }}
</a>
</span>
</div>
<div class="front-line">
<span class="label label-default">Coordinates</span>
<span class="front-data">
{{ featured_station.lat|floatformat:-3 }}°, {{ featured_station.lng|floatformat:-3 }}°
</span>
</div>
<div class="front-line">
<span class="label label-default">Antennas</span>
<span class="front-data">
{% for antenna in featured_station.antenna.all %}
{{antenna.band}} {{ antenna.antenna_type }}{% if forloop.last %}{% else %},{% endif %}
{% endfor %}
</span>
</div>
{% if featured_station.success_rate %}
<div class="front-line">
<span class="label label-default">Success Rate</span>
<span class="front-data">
<div class="progress" title="{{ featured_station.success_rate }}%">
<div class="progress-bar progress-bar-success" data-success-rate="{{ featured_station.success_rate }}">
<span class="sr-only">{{ featured_station.success_rate }}% Complete (success)</span>
</div>
<div class="progress-bar progress-bar-danger" data-percentagerest="{{ featured_station.success_rate|percentagerest }}">
<span class="sr-only">{{ featured_station.success_rate|percentagerest }}% Complete (danger)</span>
</div>
</div>
</span>
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endif %}
<div class="{% if featured_station %}col-md-8{% else %}col-md-12{% endif %}">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Latest Activity</h3>
</div>
<div class="panel-body">
<ul class="nav nav-tabs" role="tablist">
<li class="active">
<a href="#latest" class="toggle" role="tab" data-toggle="tab">Latest Observations</a>
</li>
<li>
<a href="#scheduled" class="toggle" role="tab" data-toggle="tab">Scheduled Observations</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="latest">
<table class="table table-hover">
<thead>
<th>ID</th>
<th>Satellite</th>
<th>Frequency</th>
<th>Encoding</th>
<th>Timeframe</th>
<th>Station</th>
</thead>
<tbody>
{% for observation in latest_observations.all %}
<tr>
<td>
<a href="{% url 'base:observation_view' id=observation.id %}">
{% if observation.is_vetted %}
<span class="label label-{{observation.vetted_status }}">{{ observation.id }}</span>
{% elif observation.is_future %}
<span class="label label-future">{{ observation.id }}</span>
{% else %}
<span class="label label-unknown">{{ observation.id }}</span>
{% endif %}
</a>
</td>
<td>
<a href="#" data-toggle="modal" data-target="#SatelliteModal" data-id="{{ observation.satellite.norad_cat_id }}">
{{ observation.satellite.name }}
</a>
</td>
<td>{{ observation.transmitter.downlink_low|frq }}</td>
<td>{{ observation.transmitter.mode|default:"-" }}</td>
<td>
<span class="datetime-date">{{ observation.start|date:"Y-m-d" }}</span>
<span class="datetime-time">{{ observation.start|date:"H:i:s" }}</span><br>
<span class="datetime-date">{{ observation.end|date:"Y-m-d" }}</span>
<span class="datetime-time">{{ observation.end|date:"H:i:s" }}</span>
</td>
<td>
{% if observation.ground_station %}
<a href="{% url 'base:station_view' id=observation.ground_station.id %}">
{{ observation.ground_station }}
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="tab-pane" id="scheduled">
<table class="table table-hover">
<thead>
<th>ID</th>
<th>Satellite</th>
<th>Frequency</th>
<th>Encoding</th>
<th>Timeframe</th>
<th>Station</th>
</thead>
<tbody>
{% for observation in scheduled_observations.all %}
<tr>
<td>
<a href="{% url 'base:observation_view' id=observation.id %}">
<span class="label label-info">
{{ observation.id }}
</span>
</a>
</td>
<td>
<a href="#" data-toggle="modal" data-target="#SatelliteModal" data-id="{{ observation.satellite.norad_cat_id }}">
{{ observation.satellite.name }}
</a>
</td>
<td>{{ observation.transmitter.downlink_low|frq }}</td>
<td>{{ observation.transmitter.mode }}</td>
<td>
<span class="datetime-date">{{ observation.start|date:"Y-m-d" }}</span>
<span class="datetime-time">{{ observation.start|date:"H:i:s" }}</span><br>
<span class="datetime-date">{{ observation.end|date:"Y-m-d" }}</span>
<span class="datetime-time">{{ observation.end|date:"H:i:s" }}</span>
</td>
<td>
{% if observation.ground_station %}
<a href="{% url 'base:station_view' id=observation.ground_station.id %}">
{{ observation.ground_station }}
</a>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="call2action">
<div class="panel panel-default">
<h3 class="text-center">
Crowd-sourced satellite operations
<button type="button"
class="btn btn-primary"
data-toggle="modal"
data-target="#joinModal">
Join us!
</button>
</h3>
</div>
</div>
<!-- Join Modal -->
<div class="modal fade" id="joinModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
@ -247,11 +69,11 @@
</div>
</div>
</div>
{% include 'includes/satellite.html' %}
{% endblock content %}
{% block footer %}{% endblock %}
{% block javascript %}
<script src="{% static 'lib/mapbox-gl/dist/mapbox-gl.js' %}"></script>
<script src="{% static 'js/home.js' %}"></script>
<script src="{% static 'js/satellite.js' %}"></script>
<script src="{% static 'js/map.js' %}"></script>
{% endblock %}