Attention ! Gitlab fournissant maintenant nativement des certificats Let’s Encrypt aux domaines personnalisés des Gitlab Pages, nous avons coupé notre service qui le faisait automatiquement pour vous.

Il est impératif, pour que votre domaine personnalisé continue à avoir un certificat Let’s Encrypt à jour, d’activer la fonctionnalité native dans les paramètres de votre projet. Cette activation remplacera votre certificat actuel par un nouveau certificat Let’s Encrypt géré par Gitlab.

Voir les détails sur https://docs.framasoft.org/fr/gitlab/gitlab-pages-le.html

Commit 96a74be7 authored by Nicolas G.'s avatar Nicolas G.

Nouvel antispam dans la base de donnée (application : antispam)

parent 9625fdc8
# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Nicolas Grandjean <nicolas@microniko.net>
# Copyright (C) 2015 Nicolas Grandjean <nicolas@microniko.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -15,27 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
""" Anti-spam rudimentaire
D'abord la liste des questions puis les réponses respectives
"""
QUESTIONS = [
u'Première question',
u'Seconde question',
u'Trosième question',
u'quatrième question',
u'cinquième question',
]
REPONSES = [
u'Un é',
u'Deux é',
u'Trois é',
u'Quatrième',
u'Cinqième',
]
from django.contrib import admin
# Register your models here.
from models import Questions
admin.site.register(Questions)
# -*- coding: utf-8 -*-
#
# Copyright (C) 2015 Nicolas Grandjean <nicolas@microniko.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from django.db import models
# Create your models here.
from django.utils.translation import gettext_lazy as _
import random
class Questions(models.Model):
question = models.CharField(verbose_name=_("Question"), max_length=100, null=False)
reponse = models.CharField(verbose_name=_("Réponse"), max_length=100, null=False)
def __unicode__ (self):
return self.question
class Meta:
verbose_name=_("Question de l'antispam")
verbose_name_plural=_("Questions de l'antispam")
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
......@@ -60,6 +60,7 @@ INSTALLED_APPS = (
'djgeojson',
# 'django.contrib.gis',
'ponctu',
'antispam',
'ckeditor',
)
......
......@@ -25,16 +25,16 @@ from models import Inscrits
from django.utils.translation import gettext_lazy as _
import random
from AntiSpam import QUESTIONS, REPONSES
from antispam.models import Questions
class InscritsForm(forms.ModelForm):
""" Formulaire d'inscription """
# La liste des questions
aleatoire = random.randint(1,len(QUESTIONS)-1)
print "aleatoire → #" + str(aleatoire)
verification = forms.CharField(required=True,max_length=20, label=QUESTIONS[aleatoire])# + u' → Réponse : '+REPONSES[aleatoire] + u' ID → ' + str(aleatoire))
ident = forms.CharField(initial=str(aleatoire), widget=forms.HiddenInput())
nombre = Questions.objects.all().count() # Nombre de questions dans la base
aleatoire = random.randint(1,nombre) # Un id au hasard
question = Questions.objects.get(pk=aleatoire) # On en choisie une au hasard
verification = forms.CharField(required=True,max_length=20, label=question.question) # Le champ de formulaire avec le libellé de la question
ident = forms.CharField(initial=str(aleatoire), widget=forms.HiddenInput()) # On transmet l'id de la question
class Meta:
model = Inscrits
fields = ('nom', 'prenom', 'asso', 'courriel', 'nb')
......@@ -43,7 +43,7 @@ class InscritsForm(forms.ModelForm):
cleaned_data = super(InscritsForm, self).clean()
verif = cleaned_data.get('verification')
ident = cleaned_data.get('ident')
reponse = REPONSES[int(ident)].encode('utf-8')
reponse = Questions.objects.get(pk=int(ident)).reponse.encode('utf-8')
if verif:
verif = cleaned_data.get('verification').encode('utf-8')
print "verif → " + str(verif)
......
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