diff --git a/decide/decide/settings.py b/decide/decide/settings.py index c4078dff22..1d22b67324 100644 --- a/decide/decide/settings.py +++ b/decide/decide/settings.py @@ -70,12 +70,7 @@ 'voting', ] -BASEURL = 'https://decide-penyagolosa.herokuapp.com/' - -APIS = {} - -import django_heroku -django_heroku.settings(locals()) +BASEURL = 'http://localhost:8000' MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', diff --git a/decide/voting/migrations/0007_merge_20220103_1820.py b/decide/voting/migrations/0007_merge_20220103_1820.py new file mode 100644 index 0000000000..531055423a --- /dev/null +++ b/decide/voting/migrations/0007_merge_20220103_1820.py @@ -0,0 +1,14 @@ +# Generated by Django 2.0 on 2022-01-03 18:20 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('voting', '0006_auto_20211220_2225'), + ('voting', '0006_alter_voting_postproc_alter_voting_tally'), + ] + + operations = [ + ] diff --git a/decide/voting/models.py b/decide/voting/models.py index ee9e5d8560..4e03a4ec1d 100644 --- a/decide/voting/models.py +++ b/decide/voting/models.py @@ -4,7 +4,6 @@ from django.contrib.postgres.fields import JSONField from django.db.models.signals import post_save from django.dispatch import receiver -from django.core.validators import MinValueValidator, MaxValueValidator from base import mods from base.models import Auth, Key diff --git a/decide/voting/serializers.py b/decide/voting/serializers.py index 16480be4f7..c1d1144a3e 100644 --- a/decide/voting/serializers.py +++ b/decide/voting/serializers.py @@ -1,6 +1,4 @@ from rest_framework import serializers -from . import validators -from .models import Question, QuestionOption, Voting from base.serializers import KeySerializer, AuthSerializer @@ -15,7 +13,7 @@ class Meta: class QuestionSerializer(serializers.HyperlinkedModelSerializer): options = QuestionOptionSerializer(many=True) def validate_desc(self, data): - if(validators.lofensivo(data['desc'])): + if(lofensivo(data['desc'])): raise serializers.ValidationError("Se ha detectado lenguaje ofensivo") return data class Meta: @@ -25,7 +23,7 @@ class Meta: class VotingSerializer(serializers.HyperlinkedModelSerializer): question = QuestionSerializer(many=False) - validators.lofensivo(question.Meta.fields[1]) + lofensivo(question.Meta.fields[1]) pub_key = KeySerializer() auths = AuthSerializer(many=True) diff --git a/decide/voting/tests.py b/decide/voting/tests.py index bbb35457e5..c5845a2b30 100644 --- a/decide/voting/tests.py +++ b/decide/voting/tests.py @@ -6,7 +6,7 @@ from django.test import TestCase from rest_framework.test import APIClient from rest_framework.test import APITestCase - +from django.core.exceptions import ValidationError from base import mods from base.tests import BaseTestCase from census.models import Census @@ -123,8 +123,6 @@ def test_complete_voting(self): for q in v.postproc: self.assertEqual(tally.get(q["number"], 0), q["votes"]) - - def test_create_voting_from_api(self): data = {'name': 'Example'} response = self.client.post('/voting/', data, format='json') diff --git a/decide/voting/validators.py b/decide/voting/validators.py index d33c040228..fa63aef7e0 100644 --- a/decide/voting/validators.py +++ b/decide/voting/validators.py @@ -1,10 +1,10 @@ + import unicodedata def lofensivo(value): lsofensiva = ["caca", "pedo", "pis", "pilila", "ceporro", "tonto", "imbecil", "estupido", "idiota"] - if("¿" in value): value=value.replace("¿", "") if("?" in value): @@ -23,8 +23,11 @@ def lofensivo(value): trans_tab = dict.fromkeys(map(ord, u'\u0301\u0308'), None) value = unicodedata.normalize('NFKC', unicodedata.normalize('NFKD', value).translate(trans_tab)) palabras = value.split() - + porcentaje= 20 / 100 + + + numero= Percentage.objects.last() cont = 0 res= False diff --git a/requirements.txt b/requirements.txt index 8755cc052a..901ca8dece 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,5 +9,3 @@ django-rest-swagger==2.2.0 coverage==4.5.2 django-nose==1.4.6 jsonnet==0.12.1 -django-heroku -gunicorn==20.1.0