Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit 194be54b authored by Sylvain Coulange's avatar Sylvain Coulange
Browse files

redirection après login, lecture audio fin dans player, filtres tableaux...

redirection après login, lecture audio fin dans player, filtres tableaux usersPage.html userInfo.html
parent 33f57dd4
......@@ -159,7 +159,8 @@ MEDIA_URL = '/media/'
CRISPY_TEMPLATE_PACK = 'bootstrap4'
LOGIN_REDIRECT_URL = 'home'
LOGOUT_REDIRECT_URL = '/'
# LOGIN_REDIRECT_URL = 'home'
LOGIN_URL = '/login/'
......
......@@ -27,7 +27,7 @@ from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('register/', user_views.register, name='register'),
path('login/', auth_views.LoginView.as_view(template_name="users/login.html"), name='login'),
path('login/', user_views.loginView, name='login'), #auth_views.LoginView.as_view(template_name="users/login.html"), name='login'),
path('logout/', auth_views.LogoutView.as_view(template_name="users/logout.html"), name='logout'),
path('profile/', user_views.profile, name='profile'),
path('profile/delete', user_views.delete_account, name='delete_account'),
......
......@@ -95,7 +95,7 @@ function changeLigne(el) {
ligneCible = newRep.id
document.querySelectorAll('.ligneCible').forEach((divRep) => { divRep.classList.remove('ligneCible')})
el.classList.add('ligneCible')
saveTrace(`passage ligne ${ligneCible}`)
if (bacasable) { saveTrace(`passage ligne ${ligneCible}`) }
}
function recupPhon(identifiant) {
......@@ -140,6 +140,7 @@ function recupPhon(identifiant) {
var nbmots;
var cptitem = 0;
var currentAudio = ""
var currentAudio_R = "" // audio à lire à la fin, quand réponse correcte
var currentVideo = ""
const rep = document.getElementById('rep')
......@@ -161,6 +162,9 @@ function demarrer() {
document.getElementById('divConsigne').style.display = "block"
document.getElementById('divReponse').style.display = ""
cptitem = 0
if (audio_R == 1) {
document.getElementById('bravo_audio').style.display = "block"
}
saveTrace(`start serie ${serieName}`)
loadNext()
}
......@@ -181,6 +185,10 @@ function loadNext() {
document.getElementById('video').load()
playVideo()
}
if (audio_R == 1) {
// Si lecture audio à la fin, quand réponse correcte
currentAudio_R = mots[cptitem]["audio_R"]
}
cptitem = cptitem+1
document.getElementById('cptitem').innerHTML = cptitem
} else {
......@@ -215,6 +223,7 @@ function checkAnswer() {
if (!erreur) {
playEffect("correct")
setTimeout(playAudio_R(), 2000)
getBravo(mot)
saveTrace('correct')
}
......@@ -266,6 +275,14 @@ function playAudio() {
saveTrace("playAudio")
}
function playAudio_R() {
if( audio_R == 1) {
var audio = new Audio("../../media/audio-uploads/"+currentAudio_R)
audio.play()
saveTrace("playAudio_R")
}
}
// VIDEO
function playVideo() {
document.getElementById('videoPlayer').style.display = "block"
......@@ -363,8 +380,10 @@ if (thisURL.match(/.*pA\/play/) || thisURL.match(/.*pAV\/play/) || thisURL.match
}
// RESTRICTIONS BAC À SABLE -- pas de série de mots
var bacasable = false
if (thisURL.match(/.*serie-bac-a-sable\/play/)) {
console.log('Session Bac À Sable')
bacasable = true
document.getElementById('toBacASable').style.display = "none"
document.getElementById('fenetreDeLancement').style.display = "none"
document.getElementById('divReponse').style.display = ""
......
......@@ -73,7 +73,7 @@ async function playIpa(line="") {
sv_audio.play();
}
saveTrace(`playIpa [${ipa}] ${voix} ${lang} ${document.getElementById('debitParole'+line.toString()).value}`)
saveTrace(`playIpa [${ipa}] ${voix} ${lang} ${document.getElementById('debitParole'+line.toString()).value} rep${line}`)
}
function readResponse(response, line) {
......
......@@ -64,7 +64,7 @@
</ul>
</div>
{% else %}
<a class="nav-item nav-link nav-login p-2" href="{% url 'login' %}">Se connecter</a>
<a class="nav-item nav-link nav-login p-2" href="{% url 'login' %}?next={{request.path}}">Se connecter</a>
{% endif %}
</div>
......
......@@ -14,6 +14,7 @@
var mots = JSON.parse("{{ serieContent.mots | escapejs }}");
var images = JSON.parse("{{ serieContent.imageFin | escapejs }}");
var phono = JSON.parse("{{ serieContent.phonoFin | escapejs }}");
var audio_R = JSON.parse("{{ serieContent.audioFin | escapejs }}");
var video = JSON.parse("{{ serieContent.videoDeb | escapejs }}");
var synthvoc = JSON.parse("{{ serieContent.syntheseVocale | escapejs }}");
var panneauPartiel = JSON.parse("{{ serieContent.panneauPartiel | escapejs }}")
......@@ -30,6 +31,7 @@
console.log("Mots:",mots);
console.log("ImageFin:",images);
console.log("PhonoFin:",phono);
console.log("AudioFin:",audio_R);
console.log("AudioDeb:",audioMode);
console.log("VideoDeb:",videoMode);
console.log("PanneauPartiel:",panneauPartiel);
......@@ -113,6 +115,12 @@
<div class="bravoDivBack" id="bravo" style="display: none;">
<div class="bravoDiv">
<img id="bravo_img" src="http://example.com" style="height:30vh;">
<div id="bravo_audio" onclick="playAudio_R()" style="cursor: pointer; display: none;">
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" fill="#ef8100" class="bi bi-play-circle nobg" viewBox="0 0 16 16">
<path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"/>
<path d="M6.271 5.055a.5.5 0 0 1 .52.038l3.5 2.5a.5.5 0 0 1 0 .814l-3.5 2.5A.5.5 0 0 1 6 10.5v-5a.5.5 0 0 1 .271-.445z"/>
</svg>
</div>
<div id="bravo_text"></div>
<button id="bravo_next" onclick="loadNext()" type="button" class="btn btn-success btn-lg">Continuer</button>
<div id="bravo_end" style="display:none">
......
......@@ -48,7 +48,7 @@
<!-- https://datatables.net/manual/installation -->
<table class="table table-hover" id="tracesTable" data-order='[[ 1, "desc"]]'>
<table class="table table-hover" id="tracesTable" data-order='[[ 0, "desc"]]' data-page-length='50'>
<thead>
<tr>
<th scope="col">Id</th>
......@@ -65,7 +65,7 @@
<th scope="row">{{ trace.id }}</th>
<td>{{ trace.date | date:'Y/m/d e H:i:s' }}</td>
<td>{{ trace.appli }}</td>
<td>{{ trace.content}}</td>
<td>{{ trace.content }}</td>
<td>{{ trace.userIp}}</td>
<td>{{ trace.userAgent}}</td>
</tr>
......
......@@ -11,7 +11,7 @@
<h1>Utilisateurs</h1>
<table class="table table-hover" id="usersTable" data-order='[[ 4, "desc"]]' data-page-length='25'>
<table class="table table-hover" id="usersTable" data-order='[[ 0, "desc"]]' data-page-length='50'>
<thead>
<tr>
<th scope="col">Id</th>
......@@ -24,12 +24,12 @@
</thead>
<tbody>
{% for user in users %}
<tr onclick="document.location = `{% url 'userInfo' user.username %}`;">
<tr onclick="document.location = `{% url 'userInfo' user.username %}`;" style="cursor: pointer;">
<th scope="row">{{ user.id }}</th>
<td>{{ user.username }}</td>
<td>{{ user.first_name }} {{ user.last_name }}</td>
<td><a href="mailto:{{ user.email }}">{{ user.email }}</a></td>
<td>{{ user.last_login | date:'d/m/Y H:m'}}</td>
<td>{{ user.last_login | date:'Y/m/d H:m'}}</td>
<td>
{% for group in user.groups.all %}
{% if group.name == "admin" %}
......
from django import forms
from django.contrib.auth import authenticate
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
from clavier.models import Serie, Mot, Audio, Image
from .models import Profile
class UserLoginForm(forms.Form):
username = forms.CharField()
password = forms.CharField(widget=forms.PasswordInput())
class Meta:
model = User
def clean(self, *args, **kwargs):
username = self.cleaned_data.get('username')
password = self.cleaned_data.get('password')
if username and password:
user = authenticate(username = username, password = password)
if not user:
raise forms.ValidationError("Ce nom d'utilisateur n'existe pas !")
if not user.check_password(password):
raise forms.ValidationError("Ce mot de passe est incorrect !")
return super(UserLoginForm, self).clean(*args, **kwargs)
class UserRegisterForm(UserCreationForm):
email = forms.EmailField(required=True)
......
from django.shortcuts import render, redirect
from django.contrib import messages
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required
from django.core.files.storage import FileSystemStorage
from django.conf import settings
......@@ -8,7 +9,7 @@ from django.core.mail import EmailMessage
from django.template.loader import render_to_string
from django.contrib.auth.models import Group, User
from .forms import UserRegisterForm, CreateSerieForm, UserUpdateForm, ProfileUpdateForm, CreateMot, UploadAudioForm, UploadImageForm
from .forms import UserLoginForm, UserRegisterForm, CreateSerieForm, UserUpdateForm, ProfileUpdateForm, CreateMot, UploadAudioForm, UploadImageForm
from clavier.models import Serie, Mot, Audio
from .models import Trace, SynthVocTrace, SynthVocRecord
from .decorators import unauthenticated_user, allowed_users
......@@ -17,6 +18,30 @@ from user_agents import parse
import json, datetime, csv
import numpy as np
@unauthenticated_user
def loginView(request):
nextPage = request.GET.get('next')
print("NextPage=",nextPage)
form = UserLoginForm(request.POST or None)
if form.is_valid():
username = form.cleaned_data.get('username')
password = form.cleaned_data.get('password')
user = authenticate(request, username = username, password = password)
if user is not None:
login(request, user)
if nextPage:
return redirect(nextPage)
return redirect('/')
context = {
'form': form,
}
return render(request, 'users/login.html', context)
@unauthenticated_user
def register(request):
if request.method == 'POST':
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment