Skip to content

Commit

Permalink
cambios en configuracion de participantes
Browse files Browse the repository at this point in the history
  • Loading branch information
m4droid committed Aug 18, 2016
1 parent 63ebcd4 commit d0d0791
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 27 deletions.
3 changes: 0 additions & 3 deletions actas/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@

class ActasConfig(AppConfig):
name = 'actas'

participantes_min = 4
participantes_max = 10
14 changes: 14 additions & 0 deletions actas/tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
from django.apps import apps
from django.test import TestCase
from django.test.utils import override_settings


class AppTestCase(TestCase):

def tearDown(self):
apps.clear_cache()

def test_get_name(self):
with override_settings(INSTALLED_APPS=['actas']):
self.assertEquals('actas', apps.get_app_config('actas').name)
12 changes: 0 additions & 12 deletions actas/tests/test_app_name.py

This file was deleted.

27 changes: 21 additions & 6 deletions actas/tests/test_views_acta_base.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
# -*- coding: utf-8 -*-
from django.test import TestCase, Client
from django.core.urlresolvers import reverse

from ..apps import ActasConfig
from django.test.utils import override_settings


class ViewsSubirConfirmarTestCase(TestCase):

def setup(self):
self.client = Client()

def test_obtener_acta_base(self):
def test_obtener_acta_base_defecto(self):

expected = {
u'min_participantes': ActasConfig.participantes_min,
u'max_participantes': ActasConfig.participantes_max,
u'min_participantes': 4,
u'max_participantes': 10,
u'geo': {},
u'participantes': [{} for _ in range(ActasConfig.participantes_min)],
u'participantes': [{} for _ in range(4)],
u'itemsGroups': [], # TODO: Fix this
}

response = self.client.get(reverse('actas:base'))
self.assertEquals(200, response.status_code)
self.assertEquals(expected, response.json())

def test_obtener_acta_base_settings_py(self):

expected = {
u'min_participantes': 5,
u'max_participantes': 9,
u'geo': {},
u'participantes': [{} for _ in range(5)],
u'itemsGroups': [], # TODO: Fix this
}

with override_settings(DISCUSION_ABIERTA={'PARTICIPANTES_MIN': expected['min_participantes'], 'PARTICIPANTES_MAX': expected['max_participantes']}):
response = self.client.get(reverse('actas:base'))
self.assertEquals(200, response.status_code)
self.assertEquals(expected, response.json())
1 change: 1 addition & 0 deletions actas/tests/test_views_acta_subir.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ def setup(self):
def test_obtener_subir(self):
response = self.client.get(reverse('actas:subir'))
self.assertEquals(200, response.status_code)
self.assertIsNotNone(response.cookies.get('csrftoken'))
16 changes: 12 additions & 4 deletions actas/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from django.conf import settings
from django.db import transaction
from django.http import JsonResponse
from django.shortcuts import render
from django.views.decorators.csrf import ensure_csrf_cookie

from .apps import ActasConfig
from .libs import validar_acta_json, validar_cedulas_participantes, guardar_acta

from .models import GrupoItems
Expand All @@ -24,11 +24,19 @@ def subir(request):


def acta_base(request):

participantes_min = 4
participantes_max = 10

if hasattr(settings, 'DISCUSION_ABIERTA') and type(settings.DISCUSION_ABIERTA) == dict:
participantes_min = int(settings.DISCUSION_ABIERTA.get('PARTICIPANTES_MIN', participantes_min))
participantes_max = int(settings.DISCUSION_ABIERTA.get('PARTICIPANTES_MAX', participantes_max))

acta = {
'min_participantes': ActasConfig.participantes_min,
'max_participantes': ActasConfig.participantes_max,
'min_participantes': participantes_min,
'max_participantes': participantes_max,
'geo': {},
'participantes': [{} for _ in range(ActasConfig.participantes_min)]
'participantes': [{} for _ in range(participantes_min)]
}

acta['itemsGroups'] = [g.to_dict() for g in GrupoItems.objects.all().order_by('orden')]
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Django==1.9.8
Django==1.10
pyquery==1.2.13
requests==2.10.0
requests==2.11.1

0 comments on commit d0d0791

Please sign in to comment.