This repository has been archived by the owner on Sep 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Pierre Snell
committed
Nov 13, 2018
1 parent
c3f94e0
commit c1b27da
Showing
15 changed files
with
275 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
from django.contrib import admin | ||
from .models import Surveillance, Eleve | ||
from django.utils.text import Truncator | ||
|
||
# Register your models here. | ||
|
||
class EleveAdmin(admin.ModelAdmin): | ||
list_display = ('idul', 'dateCo', 'apercu_clee') | ||
list_filter = ('idul', 'dateCo',) | ||
date_hierarchy = 'dateCo' | ||
ordering = ('dateCo', ) | ||
search_fields = ('idul', 'dateCo') | ||
|
||
def apercu_clee(self, eleve): | ||
""" | ||
Retourne les 40 premiers caractères du contenu de l'article, | ||
suivi de points de suspension si le texte est plus long. | ||
""" | ||
return Truncator(eleve.clee).chars(40, truncate='...') | ||
|
||
# En-tête de notre colonne | ||
apercu_clee.short_description = 'Aperçu de la clée publique' | ||
|
||
|
||
admin.site.register(Eleve, EleveAdmin) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Generated by Django 2.1.2 on 2018-11-10 23:25 | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Eleve', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('idul', models.CharField(max_length=7)), | ||
('clee', models.IntegerField()), | ||
('secretPartage', models.IntegerField()), | ||
('dateCo', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Date de connection')), | ||
('suspect', models.IntegerField()), | ||
('photo', models.ImageField(upload_to='')), | ||
], | ||
options={ | ||
'verbose_name': 'eleve', | ||
'ordering': ['idul'], | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Generated by Django 2.1.2 on 2018-11-11 19:20 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('ApiExamAI', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Surveillance', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('suspect', models.IntegerField(default=0)), | ||
('photo', models.ImageField(default=None, upload_to='')), | ||
], | ||
options={ | ||
'verbose_name': 'eleve', | ||
'ordering': ['suspect'], | ||
}, | ||
), | ||
migrations.RemoveField( | ||
model_name='eleve', | ||
name='photo', | ||
), | ||
migrations.RemoveField( | ||
model_name='eleve', | ||
name='secretPartage', | ||
), | ||
migrations.RemoveField( | ||
model_name='eleve', | ||
name='suspect', | ||
), | ||
migrations.AlterField( | ||
model_name='eleve', | ||
name='dateCo', | ||
field=models.DateTimeField(auto_now_add=True, verbose_name='Date de connection'), | ||
), | ||
migrations.AddField( | ||
model_name='eleve', | ||
name='surveille', | ||
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.PROTECT, to='ApiExamAI.Surveillance'), | ||
), | ||
] |
17 changes: 17 additions & 0 deletions
17
Serveur/ApiExamAI/migrations/0003_remove_eleve_surveille.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Generated by Django 2.1.2 on 2018-11-12 01:43 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('ApiExamAI', '0002_auto_20181111_1420'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='eleve', | ||
name='surveille', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,39 @@ | ||
from django.db import models | ||
from django.utils import timezone | ||
|
||
# Create your models here. | ||
|
||
class Surveillance(models.Model): | ||
suspect = models.IntegerField(default=0) | ||
photo = models.ImageField(upload_to="photos/", default=None) | ||
|
||
class Meta: | ||
verbose_name = "surveillance" | ||
ordering = ['suspect'] | ||
|
||
def __str__(self): | ||
return self.suspect | ||
|
||
|
||
class Eleve(models.Model): | ||
idul = models.CharField(max_length=7) | ||
clee = models.IntegerField() | ||
dateCo = models.DateTimeField(auto_now_add=True, | ||
verbose_name="Date de connection") | ||
# default=timezone.now, | ||
#surveille = models.OneToOneField(Surveillance, on_delete=models.PROTECT, null=True) | ||
# PROTECT ou CASCADE ou SET_NULL | ||
|
||
class Meta: | ||
verbose_name = "eleve" | ||
ordering = ['idul'] | ||
|
||
def __str__(self): | ||
return self.idul | ||
|
||
|
||
""" | ||
>> > article = Article(titre="Bonjour", auteur="Maxime") | ||
>> > for article in Article.objects.filter(auteur="Maxime"): | ||
>> > Article.objects.filter(titre__contains="crêpe") | ||
>> > Article.objects.filter(date__lt=timezone.now()) | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% extends "base.html"%} | ||
{% block title %} Recherche d'eleve {% endblock title %} | ||
{% block content %} | ||
<h1>Taper dans la barre de recherche pour trouver un eleve</h1> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% extends "base.html"%} | ||
{% block title %} Page d'aide {% endblock title %} | ||
{% block content %} | ||
<h1>Expliquons comment ca marche</h1> | ||
<p> ici </p> | ||
<p> plop </p> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
{% extends "base.html"%} | ||
<h1>Surveillance en cours</h1> | ||
<p>Le {{date}} élève {{ idul }}</p> | ||
{% block title %} Surveillance de {{idul}} en cours {% endblock title %} | ||
{% block content %} | ||
<h1>Surveillance en cours</h1> | ||
<p>Le {{date}} élève {{ idul }}</p> | ||
<p> plop </p> | ||
{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% extends 'base.html' %} | ||
{% block title %} Statistiques {% endblock title %} | ||
{% block content %} Les stats sont affichées ici{% endblock content %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
from django.shortcuts import render | ||
from django.http import HttpResponse | ||
from django.http import Http404 | ||
from django.shortcuts import redirect | ||
from django.http import HttpResponse, Http404 | ||
from django.shortcuts import render, redirect, get_object_or_404 | ||
from datetime import datetime | ||
from Crypto.PublicKey import RSA | ||
from . import models | ||
|
||
|
||
def list_articles(request, year, month): | ||
if month > 12: | ||
#return redirect(view_eleve, idul='PISNE') | ||
return redirect('eleve', idul='PISNE') | ||
#return redirect("https://www.djangoproject.com") | ||
else : | ||
return HttpResponse( | ||
"Vous avez demandé {0} et {1} !".format(year,month)) | ||
|
||
def home(request): | ||
return HttpResponse(""" | ||
<h1>Bienvenue ExamAi !</h1> | ||
<p>Api : getInfos ou plop </p> | ||
""") | ||
|
||
def view_eleve(request, idul): | ||
#return HttpResponse("Vous avez demandé l'eleve {0} !".format(idul)) | ||
|
||
def Acceuil_eleve(request): | ||
return render(request, 'ApiExamAI/Acceuil_eleve.html') | ||
|
||
|
||
def view_eleve(request, idul="AAAAA"): | ||
# return HttpResponse("Vous avez demandé l'eleve {0} !".format(idul)) | ||
date = datetime.now() | ||
#eturn render(request, 'ApiExamAI/eleve.html', date) | ||
# return render(request, 'ApiExamAI/eleve.html', date) | ||
return render(request, 'ApiExamAI/eleve.html', locals()) | ||
|
||
|
||
def stats(request): | ||
return render(request, 'ApiExamAI/stats.html') | ||
|
||
|
||
def Aide(request): | ||
return render(request, 'ApiExamAI/Aide.html') | ||
|
||
|
||
def connection(request, idul): | ||
eleve = models.Eleve(idul=idul) | ||
eleve.clee = RSA.generate(4096).publickey() | ||
#eleve.surveille.suspect = 0 | ||
# public_key.encrypt(TrucQuonVeutSecuriser) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,33 @@ | ||
from pygame import mixer | ||
import speech_recognition as sr | ||
from gtts import gTTS | ||
#quiet the endless 'insecurerequest' warning | ||
# quiet the endless 'insecurerequest' warning | ||
import urllib3 | ||
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) | ||
|
||
from pygame import mixer | ||
mixer.init() | ||
|
||
while (True == True): | ||
# obtain audio from the microphone | ||
r = sr.Recognizer() | ||
with sr.Microphone() as source: | ||
#print("Please wait. Calibrating microphone...") | ||
# listen for 1 second and create the ambient noise energy level | ||
r.adjust_for_ambient_noise(source, duration=1) | ||
print("Say something!") | ||
audio = r.listen(source,phrase_time_limit=5) | ||
# obtain audio from the microphone | ||
r = sr.Recognizer() | ||
with sr.Microphone() as source: | ||
#print("Please wait. Calibrating microphone...") | ||
# listen for 1 second and create the ambient noise energy level | ||
r.adjust_for_ambient_noise(source, duration=1) | ||
print("Say something!") | ||
audio = r.listen(source, phrase_time_limit=5) | ||
|
||
# recognize speech using Sphinx/Google | ||
try: | ||
#response = r.recognize_sphinx(audio) | ||
response = r.recognize_google(audio) | ||
print("I think you said '" + response + "'") | ||
tts = gTTS(text="I think you said "+str(response), lang='en') | ||
tts.save("response.mp3") | ||
mixer.music.load('response.mp3') | ||
mixer.music.play() | ||
|
||
try: | ||
#response = r.recognize_sphinx(audio) | ||
response = r.recognize_google(audio) | ||
print("I think you said '" + response + "'") | ||
tts = gTTS(text="I think you said "+str(response), lang='en') | ||
tts.save("response.mp3") | ||
mixer.music.load('response.mp3') | ||
mixer.music.play() | ||
|
||
except sr.UnknownValueError: | ||
print("Sphinx could not understand audio") | ||
except sr.RequestError as e: | ||
print("Sphinx error; {0}".format(e)) | ||
except sr.UnknownValueError: | ||
print("Sphinx could not understand audio") | ||
except sr.RequestError as e: | ||
print("Sphinx error; {0}".format(e)) |
Oops, something went wrong.