Skip to content

Commit

Permalink
Merge branch 'lofensivo' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
bencrealc authored Jan 5, 2022
2 parents 09b7225 + 96667b8 commit 78bd855
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
7 changes: 1 addition & 6 deletions decide/decide/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
14 changes: 14 additions & 0 deletions decide/voting/migrations/0007_merge_20220103_1820.py
Original file line number Diff line number Diff line change
@@ -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 = [
]
1 change: 0 additions & 1 deletion decide/voting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 2 additions & 4 deletions decide/voting/serializers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from rest_framework import serializers
from . import validators
from .models import Question, QuestionOption, Voting
from base.serializers import KeySerializer, AuthSerializer


Expand All @@ -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:
Expand All @@ -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)

Expand Down
4 changes: 1 addition & 3 deletions decide/voting/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
7 changes: 5 additions & 2 deletions decide/voting/validators.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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

Expand Down
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 78bd855

Please sign in to comment.