mirror of
https://github.com/GFDRR/sms-lapli.git
synced 2026-11-08 15:26:00 +00:00
Merge pull request #49 from GFDRR/revert-45-master
Revert "Create log that provides a history of all SMS received"
This commit is contained in:
commit
cf0fd66077
14 files changed
+56
-149
No files matched your search
@@ -1,19 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('base', '0012_auto_20151008_2256'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='departement',
|
||||
name='departement',
|
||||
field=models.CharField(choices=[('Ouest', 'OUEST'), ('Nord', 'NORD'), ('Nordouest', 'NORD-OUEST'), ('Nordest', 'NORD-EST'), ('Sud', 'SUD'), ('Sudest', 'SUD-EST'), ('Artibonite', 'ARTIBONITE'), ('Nippes', 'NIPPES'), ('Centre', 'CENTRE'), ('Grandanse', "GRAND'ANSE")], max_length=40, verbose_name='Departement'),
|
||||
),
|
||||
]
|
||||
+1
-7
@@ -29,7 +29,7 @@ class ObservationAdmin(admin.ModelAdmin):
|
||||
#Called my form in the admin and set a column for each fields
|
||||
list_filter = (('valider',))
|
||||
search_fields = ["quantitePluie", "dateDebut", "dateFin", "description"]
|
||||
list_display = ('pk',"idStation", "observer", "timestamp", "dateDebut", "dateFin", "quantitePluie", "log", "description", "valider")
|
||||
list_display = ('pk',"idStation", "observer", "timestamp", "dateDebut", "dateFin", "temperatureMax", "temperatureMin", "quantitePluie", "description", "valider")
|
||||
form = ObservationForm
|
||||
# actions = [validate, unvalidate]
|
||||
actions = ['make_valider', 'make_nonvalider']
|
||||
@@ -89,11 +89,6 @@ class StationObserversAdmin(admin.ModelAdmin):
|
||||
search_fields = ["station"]
|
||||
form = StationObserversForm
|
||||
|
||||
class LogAdmin(admin.ModelAdmin):
|
||||
#Called my form in the admin and set a column for each fields
|
||||
list_display = ("observation", "observer", "quantitePluie", "timestamp")
|
||||
search_fields = ["observation.idStation"]
|
||||
|
||||
# class ObservationTemperatureAdmin(admin.ModelAdmin):
|
||||
#
|
||||
#
|
||||
@@ -108,7 +103,6 @@ admin.site.register(TypeStation, TypeStationAdmin)
|
||||
admin.site.register(Observation, ObservationAdmin)
|
||||
admin.site.register(UniteDeMesure, UniteDeMesureAdmin)
|
||||
admin.site.register(StationObservers, StationObserversAdmin)
|
||||
admin.site.register(Log, LogAdmin)
|
||||
|
||||
# admin.site.register(ObservationTemperature)
|
||||
# admin.site.register(ObservationDirectionVent)
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('base', '0013_auto_20151012_2255'),
|
||||
('hydromet', '0014_auto_20151007_1845'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Log',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, auto_created=True, verbose_name='ID', serialize=False)),
|
||||
('timestamp', models.DateTimeField(auto_now_add=True)),
|
||||
('temperatureMax', models.DecimalField(null=True, max_digits=5, blank=True, verbose_name='Temperature max', decimal_places=3)),
|
||||
('temperatureMin', models.DecimalField(null=True, max_digits=5, blank=True, verbose_name='Temperature min', decimal_places=3)),
|
||||
('quantitePluie', models.DecimalField(decimal_places=2, max_digits=15, blank=True, verbose_name='Quantite de Pluie')),
|
||||
],
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='observation',
|
||||
name='valider',
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='log',
|
||||
name='observation',
|
||||
field=models.ForeignKey(null=True, to='hydromet.Observation', blank=True, default=None),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='log',
|
||||
name='observer',
|
||||
field=models.ForeignKey(to='base.PersonneContact'),
|
||||
),
|
||||
]
|
||||
@@ -48,21 +48,3 @@ class Observation(models.Model):
|
||||
quantitePluie = models.DecimalField(max_digits=15, decimal_places=2, blank=True, verbose_name="Quantite de Pluie")
|
||||
description = models.TextField(max_length=100, blank=True)
|
||||
valider = models.BooleanField(default=False)
|
||||
|
||||
def __str__(self): # __unicode__ on Python 2
|
||||
return self.idStation.nomStation + ' le '+ str(self.dateDebut)
|
||||
|
||||
@property
|
||||
def log(self):
|
||||
return Log.objects.filter(observation=self.pk).count()
|
||||
|
||||
class Log(models.Model):
|
||||
observation = models.ForeignKey(Observation, null=True, blank=True, default = None)
|
||||
observer = models.ForeignKey(PersonneContact)
|
||||
timestamp = models.DateTimeField(auto_now_add=True)
|
||||
temperatureMax = models.DecimalField(max_digits=5, decimal_places=3, null=True, blank=True, verbose_name="Temperature max")
|
||||
temperatureMin = models.DecimalField(max_digits=5, decimal_places=3, null=True, blank=True, verbose_name="Temperature min")
|
||||
quantitePluie = models.DecimalField(max_digits=15, decimal_places=2, blank=True, verbose_name="Quantite de Pluie")
|
||||
|
||||
def __str__(self): # __unicode__ on Python 2
|
||||
return self.observer.nomPersonne + ' ' + self.observer.prenomPersonne
|
||||
+31
-36
@@ -1,32 +1,33 @@
|
||||
from rapidsms.apps.base import AppBase
|
||||
from base.models import * # importing all models from Donnees_de_Base where data about Contacts are stored
|
||||
from base.models import * # importing all models from Donnees_de_Base where data about Contacts are stored
|
||||
from hydromet.models import *
|
||||
from datetime import *
|
||||
import re
|
||||
|
||||
|
||||
def isFloat(val):
|
||||
try:
|
||||
float(val)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
try:
|
||||
float(val)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
|
||||
class SmsGateway(AppBase):
|
||||
def handle(self, msg):
|
||||
|
||||
def handle(self,msg):
|
||||
valid_numbers = [] # An empty list
|
||||
|
||||
for tel in PersonneContact.objects.all():
|
||||
valid_numbers.append(tel.telephonePersonnel) # Getting all personnal Phone
|
||||
valid_numbers.append(tel.telephonePersonnel)# Getting all personnal Phone
|
||||
|
||||
tel = msg.peer.strip("+")
|
||||
if tel not in valid_numbers:
|
||||
# msg.respond('TEst')
|
||||
msg.respond('Not in ' + msg.peer)
|
||||
msg.respond('Not in '+msg.peer)
|
||||
return True # Return false because we don't want to answer an unknow number
|
||||
# We must shut the default messge from the default app in this case
|
||||
else: # If this number is in the list, will work with the text message
|
||||
# We must shut the default messge from the default app in this case
|
||||
else: # If this number is in the list, will work with the text message
|
||||
# if msg.text == "daa":
|
||||
# a = Observation
|
||||
# for asd in a.objects.filter(dateDebut__lte=datetime.now):
|
||||
@@ -41,41 +42,35 @@ class SmsGateway(AppBase):
|
||||
return True
|
||||
|
||||
val_float = float(msg.text)
|
||||
# Ici operation avec les unites disponibles
|
||||
#Ici operation avec les unites disponibles
|
||||
dt = datetime.now()
|
||||
dateFin = str(dt.year) + '-' + str(dt.month) + '-' + str(dt.day)
|
||||
dtD = date.today() - timedelta(days=1)
|
||||
dateDebut = str(dtD.year) + '-' + str(dtD.month) + '-' + str(dtD.day)
|
||||
dateFin = str(dt.year)+'-'+str(dt.month)+'-'+str(dt.day)
|
||||
dtD=date.today() - timedelta(days=1)
|
||||
dateDebut = str(dtD.year)+'-'+str(dtD.month)+'-'+str(dtD.day)
|
||||
|
||||
person = PersonneContact.objects.get(telephonePersonnel=tel)
|
||||
station = StationObservers.objects.get(observer=person).station
|
||||
|
||||
# id de la personne qui a envoye le sms
|
||||
obs_id = PersonneContact.objects.filter(telephonePersonnel=tel).first().id
|
||||
|
||||
observation = Observation.objects.filter(observer=obs_id, dateDebut=dateDebut).order_by('-id').first()
|
||||
if observation:
|
||||
observation.quantitePluie = val_float
|
||||
#id de la personne qui a envoye le sms
|
||||
obs_id = PersonneContact.objects.filter(telephonePersonnel = tel).first().id
|
||||
|
||||
recup_last_value = Observation.objects.filter(observer = obs_id, dateDebut = dateDebut).order_by('-id').first()
|
||||
if recup_last_value:
|
||||
recup_last_value.quantitePluie = val_float
|
||||
recup_last_value.save()
|
||||
info = 'Donnee mise a jour'
|
||||
else:
|
||||
observation = Observation()
|
||||
observation.idStation = station
|
||||
observation.observer = person
|
||||
observation.timestamp = datetime.now()
|
||||
observation.quantitePluie = val_float
|
||||
observation.dateDebut = dateDebut
|
||||
observation.dateFin = dateFin
|
||||
observation.valider = False
|
||||
o = Observation()
|
||||
o.idStation = station
|
||||
o.observer = person
|
||||
o.timestamp = datetime.now()
|
||||
o.quantitePluie = val_float
|
||||
o.dateDebut = dateDebut
|
||||
o.dateFin = dateFin
|
||||
o.valider = False
|
||||
o.save()
|
||||
info = 'Donnee sauvegardee. Merci!'
|
||||
|
||||
|
||||
observation.save()
|
||||
|
||||
log = Log(observation=observation,observer=observation.observer,
|
||||
timestamp=observation.timestamp, quantitePluie=observation.quantitePluie)
|
||||
log.save()
|
||||
|
||||
msg.respond(info)
|
||||
return True
|
||||
else:
|
||||
|
||||
@@ -159,7 +159,6 @@
|
||||
<li><a href="/admin/hydromet/unitedemesure/">Unite de mesures</a>
|
||||
</li>
|
||||
<li><a href="/admin/hydromet/stationobservers/">Station observers</a>
|
||||
<li><a href="/admin/hydromet/log/">Log</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
@@ -11,23 +11,24 @@
|
||||
<section class="jumbotron">
|
||||
<div class="container ">
|
||||
<div class="row">
|
||||
|
||||
<br /><br /><br /><br />
|
||||
<div class="col-lg-12 obj" >
|
||||
<p><img class="" src="{% static "public/img/cnsalogo.png" %}" /></p>
|
||||
<img class="" src="{% static "public/img/cnsalogo.png" %}" />
|
||||
<p>
|
||||
Nous mettons a la disposition du public des donnees fiables sur la quantite de pluie et egalement l'etat de la disponibilite de la nourriture dans le pays.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{% comment %}
|
||||
{% include "public/include/modal_body.html" %}
|
||||
{% include "public/include/modal_body.html" %}
|
||||
{% endcomment %}
|
||||
<center>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<a href="/rapport/pluviometrie" class="btn btn-default btn btn-info btn-lg fullWidth"><span class="glyphicon glyphicon-stats"> </span>Donnees Pluviometrique</a>
|
||||
<a href="/rapport/pluviometrie" class="btn btn-default btn btn-info btn-lg"><span class="glyphicon glyphicon-stats"> </span>Donnees Pluviometrique</a>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<a class="btn btn-default btn-lg fullWidth"><span class="glyphicon glyphicon-tags"> </span>Donnees Prix de marche</a>
|
||||
<a class="btn btn-default btn-lg"><span class="glyphicon glyphicon-tags"> </span>Donnees Prix de marche</a>
|
||||
</div>
|
||||
</center>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
<footer class="footer-basic-centered">
|
||||
|
||||
<p class="footer-company-motto">La securite alimentaire pour tous.</p>
|
||||
|
||||
<p class="footer-links">
|
||||
<a href="#">Accueil</a>
|
||||
·
|
||||
<a href="#">Donnees pluviometrique</a>
|
||||
·
|
||||
<a href="#">Prix du marche</a>
|
||||
</p>
|
||||
|
||||
<p class="footer-company-name">CNSA © 2015</p>
|
||||
|
||||
</footer>
|
||||
@@ -6,16 +6,13 @@
|
||||
<link rel="stylesheet" type="text/css" href="{% static "public/css.css" %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% static "public/demo.css" %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% static "public/footer-basic-centered.css" %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% static "public/leaflet/leaflet.css" %}">
|
||||
<link rel="stylesheet" type="text/css" href="{% static "public/bootstrap/dist/css/bootstrap-theme.min.css" %}">
|
||||
<script src="{% static "public/bootstrap/dist/js/Chart.js" %}"></script>
|
||||
<script src="{% static "public/bootstrap/dist/css/bootstrap-theme.min.css" %}"></script>
|
||||
<script src="{% static "public/jquery/jquery-1.11.3.min.js" %}"></script>
|
||||
<script src="{% static "public/bootstrap/dist/js/bootstrap.min.js" %}"></script>
|
||||
<script src="{% static "public/bootstrap/select/js/bootstrap-select.min.js" %}"></script>
|
||||
<script src="{% static "public/jquery/datamaking.js" %}"></script>
|
||||
<script src="{% static "public/bootstrap/js/graphe.js" %}"></script>
|
||||
<script src="{% static "public/leaflet/leaflet.js" %}"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$("#myTab a").click(function(e){
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
margin-top: 7px;
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
@@ -25,9 +24,8 @@
|
||||
<div id="navbar" class="navbar-collapse collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li class="active"><a href="/">Accueil</a></li>
|
||||
<li><a href="/rapport/pluviometrie/">Pluviométrie</a></li>
|
||||
<li><a href="#">Prix du Marché</a></li>
|
||||
<li><a href="#">FAQ</a></li>
|
||||
<li><a href="/rapport/pluviometrie/">Pluviometrie</a></li>
|
||||
<li><a href="#">Marche</a></li>
|
||||
</ul>
|
||||
<!-- Button HTML (to Trigger Modal) -->
|
||||
<a href="/admin/" class="vcenter btn nav-form btn-success navbar-right">Sign in</a>
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
<html>
|
||||
<head>
|
||||
{% include "public/include/head.html" %}
|
||||
|
||||
<script src="{% static "public/leaflet/leaflet.js" %}"></script>
|
||||
<link rel="stylesheet" type="text/css" href="{% static "public/leaflet/leaflet.css" %}">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -153,15 +153,4 @@ a.list-group-item, button.list-group-item {
|
||||
}
|
||||
.showSubMenuContent{
|
||||
display: block;
|
||||
}
|
||||
|
||||
footer {
|
||||
width: 100%;
|
||||
position: fixed !important;
|
||||
bottom: 0 !important;
|
||||
}
|
||||
|
||||
.fullWidth {
|
||||
display: inline-block;
|
||||
width: 100%;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ header ul li{
|
||||
|
||||
/* In our demo, the footers are fixed to the bottom of the page */
|
||||
|
||||
footer {
|
||||
footer{
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
*/
|
||||
|
||||
$(document).ready(function(){
|
||||
$.get('/rapport/json_rap/',function(data,status){
|
||||
$.get('/rapport/json_rap',function(data,status){
|
||||
//alert(data);
|
||||
//alert(data.table[0].dep)
|
||||
//alert("Je suis")
|
||||
|
||||
Reference in new issue
Block a user