Skip to content

Commit

Permalink
Merge branch 'master' into raspi
Browse files Browse the repository at this point in the history
  • Loading branch information
Romain Grimau committed Nov 25, 2018
2 parents 64953a0 + 628bd46 commit c293393
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 152 deletions.
119 changes: 18 additions & 101 deletions incubator/templates/home.html
Expand Up @@ -5,12 +5,10 @@

{% block content %}
<div class="row">

<div class="col-md-8">
{% if message and message != "" %}
<div class="alert alert-{{message_type}}" role="alert">
{{ message|markdown }}

</div>
{% endif %}

Expand All @@ -37,108 +35,27 @@ <h1>Un hackerspace ?</h1>
</p>

<p>UrLab est un lieu de rencontre pour les étudiants intéressés par la technologie. C’est un lieu où l’on développe ses projets et l’on partage ses connaissances par l’intermédiaire d’ateliers et de conférences.</p>
{% endif %}
<h2>
<span class="fa fa-calendar-o" aria-hidden="true"></span>
Évènements à venir
</h2>

<p>Les évènements de Urlab programmés pour les prochains jours sont :</p>
<div class="col-md-9">
{% if events %}
{% for event in events %}
{% include "event_card.html" %}
{% endfor %}
{% else %}
<p class="text-muted">Il n'y a actuellement pas d'évènements à venir</p>
{% endif %}
<div class="row">
{% include "event.html" %}
</div>
{% endif %}
</div>
<div class="col-md-4 well">
<p>UrLab se trouve sur le campus du Solbosh, à l'ULB et est ouvert à tout le monde.</p>
<iframe width='100%' height='300px' frameBorder='0'
src='https://a.tiles.mapbox.com/v4/c4ptaincrunch.o1n42mc8/attribution,zoompan,zoomwheel,geocoder.html?access_token=pk.eyJ1IjoiYzRwdGFpbmNydW5jaCIsImEiOiJUdWVRSENNIn0.qssi5TBLeBinBsXkZKiI6Q#14/50.812919/4.38443799999999'></iframe>
<p>
<hr/>
{% if space_open %}
<a href="{% url "pamela_list" %}" class="btn btn-success btn-group-justified">
{% bootstrap_icon "ok" %}
C'est ouvert !
</a>
{% else %}
<a href="{% url "pamela_list" %}" class="btn btn-danger btn-group-justified">
{% bootstrap_icon "remove" %}
On est fermé
</a>
{% endif %}
<hr/>
<div class="text-right">
<h3>Social</h3>
<a href="https://twitter.com/UrLabBxl" title="Twitter" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x"></i>
</span>
</a>
<a href="https://www.facebook.com/urlabbxl" title="Facebook" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x"></i>
</span>
</a>
<a href="https://github.com/UrLab" title="GitHub" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-github fa-stack-1x"></i>
</span>
</a>
<a href="http://urlab.be/events/urlab.ics" title="iCal" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-calendar fa-stack-1x"></i>
</span>
</a>
<a href="http://urlab.space" title="SpaceAPI" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-space-shuttle fa-stack-1x"></i>
</span>
</a>
<a href="http://webchat.freenode.net/?channels=urlab" title="IRC" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-slack fa-stack-1x"></i>
</span>
</a>

<h3>Contact</h3>
<h4>Mail
<small>
<a href="mailto:contact@urlab.be">contact@urlab.be</a>
</small>
</h4>
<h4>Chat
<small>
<a target="_blank" href="http://webchat.freenode.net/?channels=urlab">
chat.freenode.org#urlab
</a>
</small>
</h4>
<h4>Adresse
<small>131 av. Buyl, 1050 Bruxelles</small>
</h4>
<h4>Téléphone
<small>02/650.49.67</small>
</h4>
<h3>Probabilités d'ouverture</h3>
{% include "opening_d3.html" %}
<!--
<img src="{% url "openings_graph" %}?weeks=6&width=9&height=3&weekday_django={% now 'w' %}"
alt="Ouverture" style="width: 100%" />
-->
{% if request.user.is_authenticated %}
<div class="col-md-4">
<div class="row">
{% include "event.html" %}
</div>
<div class="row">
{% include "map.html" %}
</div>
</div>
</div>

{% else %}
<div class="col-md-4">
<div class="row">
{% include "map.html" %}
</div>
</div>
{% endif %}
</div>

<script type="text/javascript">
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Expand Up @@ -20,7 +20,6 @@ ics
django-analytical
django-jsonfield
django-jsonfield-compat
matplotlib
pandas
django-pandas
pip>8.0
Expand Down
27 changes: 0 additions & 27 deletions space/plots.py
Expand Up @@ -78,30 +78,3 @@ def weekday_probs(opts):
ret[i] = 0

return ret


def weekday_plot(ax, opts):
# Init plot
width = int(opts.get('width', 12))
height = int(opts.get('height', 8))
ax.figure(figsize=(width, height))

probs = 100 * weekday_probs(opts)
img = np.repeat([probs], 5, axis=0)
cax = ax.imshow(
img, cmap=ax.cm.RdYlGn, interpolation='none',
vmin=0, vmax=100)
ticks = [0, 25, 50, 75, 100]
cbar = ax.colorbar(cax, ticks=ticks)
cbar.ax.set_yticklabels(['{}%'.format(t) for t in ticks])

# Ticks && grid
ticks = np.arange(0, 24, 2)
ax.xticks(ticks - 0.5, ["%dh" % x for x in ticks])
ax.yticks([])
ax.grid()

# Title
opts['from'] = df.index.min().strftime("%d/%m/%Y")
opts['to'] = df.index.max().strftime("%d/%m/%Y")
ax.title(human_time(opts))
16 changes: 16 additions & 0 deletions space/templates/event.html
@@ -0,0 +1,16 @@
<h2>
<span class="fa fa-calendar-o" aria-hidden="true"></span>
Évènements à venir
</h2>

<p>Les évènements de Urlab programmés pour les prochains jours sont :</p>

<div class={% if not user.is_authenticated %}"col-md-9"{% else %}""{% endif %}>
{% if events %}
{% for event in events %}
{% include "event_card.html" %}
{% endfor %}
{% else %}
<p class="text-muted">Il n'y a actuellement pas d'évènements à venir</p>
{% endif %}
</div>
83 changes: 83 additions & 0 deletions space/templates/map.html
@@ -0,0 +1,83 @@
{% load bootstrap3 %}
{% load formatting %}
{% load humanize %}
<div class="well">
<p>UrLab se trouve sur le campus du Solbosh, à l'ULB et est ouvert à tout le monde.</p>
<iframe width='100%' height='300px' frameBorder='0'
src='https://a.tiles.mapbox.com/v4/c4ptaincrunch.o1n42mc8/attribution,zoompan,zoomwheel,geocoder.html?access_token=pk.eyJ1IjoiYzRwdGFpbmNydW5jaCIsImEiOiJUdWVRSENNIn0.qssi5TBLeBinBsXkZKiI6Q#14/50.812919/4.38443799999999'></iframe>
<p>
<hr/>
{% if space_open %}
<a href="{% url "pamela_list" %}" class="btn btn-success btn-group-justified">
{% bootstrap_icon "ok" %}
C'est ouvert !
</a>
{% else %}
<a href="{% url "pamela_list" %}" class="btn btn-danger btn-group-justified">
{% bootstrap_icon "remove" %}
On est fermé
</a>
{% endif %}
<hr/>
<div class="text-right">
<h3>Social</h3>
<a href="https://twitter.com/UrLabBxl" title="Twitter" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-twitter fa-stack-1x"></i>
</span>
</a>
<a href="https://www.facebook.com/urlabbxl" title="Facebook" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-facebook fa-stack-1x"></i>
</span>
</a>
<a href="https://github.com/UrLab" title="GitHub" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-github fa-stack-1x"></i>
</span>
</a>
<a href="http://urlab.be/events/urlab.ics" title="iCal" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-calendar fa-stack-1x"></i>
</span>
</a>
<a href="http://urlab.space" title="SpaceAPI" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-space-shuttle fa-stack-1x"></i>
</span>
</a>
<a href="http://webchat.freenode.net/?channels=urlab" title="IRC" target="_blank">
<span class="wow fa-stack fa-lg">
<i class="fa fa-square-o fa-stack-2x"></i>
<i class="fa fa-slack fa-stack-1x"></i>
</span>
</a>

<h3>Contact</h3>
<h4>Mail
<small>
<a href="mailto:contact@urlab.be">contact@urlab.be</a>
</small>
</h4>
<h4>Chat
<small>
<a target="_blank" href="http://webchat.freenode.net/?channels=urlab">
chat.freenode.org#urlab
</a>
</small>
</h4>
<h4>Adresse
<small>131 av. Buyl, 1050 Bruxelles</small>
</h4>
<h4>Téléphone
<small>02/650.49.67</small>
</h4>
<h3>Probabilités d'ouverture</h3>
{% include "opening_d3.html" %}
</div>
</div>
4 changes: 2 additions & 2 deletions space/templates/pamela.html
Expand Up @@ -25,14 +25,14 @@ <h1>Pamela
<div class="col-md-8">
<p>P.A.M.E.L.A. est l'interface permettant de voir qui est actuellement connecté sur le réseau du
Hackerspace.
Ci-dessous les gens actuellements présents :</p>
Ci-dessous les gens actuellement présents :</p>

{% if should_show_pamela %}
{% if stealth_mode %}
<br>
<div class="alert alert-warning" role="alert">
<b>Stealth mode activated !</b> Le hackerspace n'est pas censé être ouvert pour l'instant.<br>
Vous pouvez voir pamela parce que vous êtes détenteur d'une clé mais la plus part des gens ne voient qu'une page vide !
Vous pouvez voir pamela parce que vous êtes détenteur d'une clé mais la plupart des gens ne voient qu'une page vide !
</div>
{% endif %}
<div id="pamela"></div>
Expand Down
3 changes: 1 addition & 2 deletions space/urls.py
Expand Up @@ -2,15 +2,14 @@
from django.contrib.auth.decorators import login_required

from .views import (pamela_list, status_change, DeleteMACView, motd_change,
openings, openings_data, full_pamela, get_user_mac, get_mac_user)
openings_data, full_pamela, get_user_mac, get_mac_user)


urlpatterns = [
url(r'^pamela$', pamela_list, name='pamela_list'),
url(r'^change_status$', status_change, name='change_status'),
url(r'^change_motd$', motd_change, name='change_motd'),
url(r'^remove_mac/(?P<pk>[0-9]+)$', login_required(DeleteMACView.as_view()), name="delete_mac"),
url(r'^openings$', openings, name='openings_graph'),
url(r'^openings_data$', openings_data, name='openings_graph_data'),

url(r'^private_pamela.json$', full_pamela, name='private_pamela'),
Expand Down
21 changes: 2 additions & 19 deletions space/views.py
@@ -1,3 +1,4 @@
from datetime import timedelta
from django.shortcuts import render
from django.contrib import messages
from django.core.urlresolvers import reverse, reverse_lazy
Expand All @@ -12,17 +13,12 @@
from rest_framework import viewsets
from rest_framework.response import Response

import matplotlib as mpl
mpl.use('Agg')
import matplotlib.pyplot as plt
from datetime import timedelta

from .djredis import get_redis, set_space_open, space_is_open
from .models import MacAdress, SpaceStatus, MusicOfTheDay
from .forms import MacAdressForm
from .serializers import PamelaSerializer, SpaceStatusSerializer, MotdSerializer
from .decorators import private_api, one_or_zero
from .plots import weekday_plot, weekday_probs, human_time
from .plots import weekday_probs, human_time
from .helpers import is_stealth_mode, make_empty_pamela, make_pamela, user_should_see_pamela
from users.models import User
from realtime.helpers import publish_space_state
Expand Down Expand Up @@ -224,19 +220,6 @@ def openings_data(request):
})


def openings(request):
opts = {k: request.GET[k] for k in request.GET}

weekday_plot(plt, opts)

# Wrap everything in a django response and clear matplotlib context
response = HttpResponse(content_type="image/png")
plt.savefig(response, format='png', facecolor=(0, 0, 0, 0),
edgecolor='none', bbox_inches='tight', pad_inches=0)
plt.clf()
return response


class PamelaObject(object):
def __init__(self, pamela_dict):
last_updated = timezone.now() - timedelta(seconds=pamela_dict['updated'])
Expand Down

0 comments on commit c293393

Please sign in to comment.