Skip to content

Commit

Permalink
Merge pull request #1123 from ciudadanointeligente/secret_match_link_…
Browse files Browse the repository at this point in the history
…merepresenta

Hay un link secreto donde est'a el match de merepesenta
  • Loading branch information
lfalvarez committed Feb 21, 2019
2 parents 5af7056 + 62e09dd commit a9d91d4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions merepresenta/match/tests/views_and_forms_tests.py
Expand Up @@ -31,6 +31,13 @@ def test_get_the_view(self):
self.assertEquals(response.status_code, 200)
self.assertIsInstance(response.context['form'], QuestionsCategoryForm)

def test_get_the_secret_view(self):
url = reverse('match_secret')
response = self.client.get(url)
self.assertEquals(response.status_code, 200)
self.assertIsInstance(response.context['form'], QuestionsCategoryForm)
self.assertTemplateUsed(response, 'match/pergunta.html')

def test_get_post(self):
a = Area.objects.create(name='area')
e = Election.objects.create(name='Deputada/o estadual', area=a)
Expand Down
5 changes: 4 additions & 1 deletion merepresenta/match/views.py
Expand Up @@ -48,6 +48,9 @@ def dispatch(self, *args, **kwargs):
return HttpResponseRedirect(reverse_lazy('volunteer_index'))
return super(MatchView, self).dispatch(*args, **kwargs)

class MatchSecretView(MatchQuestionCategoryBase):
template_name = 'match/pergunta.html'
success_template = 'match/resultado_ajax.html'

class MatchResultView(MatchQuestionCategoryBase):
template_name = 'match/pergunta.html'
Expand All @@ -62,4 +65,4 @@ def post(self, request, *args, **kwargs):
builder.set_electors_categories(categories)
r = builder.get_result_as_array()
return JsonResponse(json.dumps(r), safe=False)


3 changes: 2 additions & 1 deletion merepresenta/settings.py
@@ -1,4 +1,5 @@
MEREPRESENTA_SITE_ID = 2
MEREPRESENTA_CANDIDATES_ALLOWED_TO_UPDATE = True
ELEITOR_WORKING = True
MEREPRESENTA_VOLUNTARIOS_ON = True
MEREPRESENTA_VOLUNTARIOS_ON = True
SECRET_URL_MATCH='secret_match'
7 changes: 6 additions & 1 deletion merepresenta/urls.py
Expand Up @@ -16,8 +16,9 @@
CouldNotFindCandidate,
FacebookContacted,
complete)
from merepresenta.match.views import MatchView, MatchResultView, MatchResultAjaxView
from merepresenta.match.views import MatchView, MatchResultView, MatchResultAjaxView, MatchSecretView
from merepresenta.views import ColigacoesPerAreaView, ColigacoesInitialRedirect
from django.conf import settings

class MeRepresentaMeiaLaranjaForm(MediaNaranjaElectionForm):
def __init__(self, *args, **kwargs):
Expand All @@ -28,6 +29,7 @@ class MeRepresentaMeiaLaranja(CompleteMediaNaranjaView):
def get_form_class(self):
return MeRepresentaMeiaLaranjaForm

SECRET_URL_MATCH = getattr(settings, 'SECRET_URL_MATCH', 'secret_match' )

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
Expand Down Expand Up @@ -62,6 +64,9 @@ def get_form_class(self):
url(r'^eleitora/?$',
MatchView.as_view(),
name='match'),
url(r'^{secret_url}/?$'.format(secret_url=SECRET_URL_MATCH),
MatchSecretView.as_view(),
name='match_secret'),
url(r'^resultado/?$',
MatchResultView.as_view(),
name='match_result'),
Expand Down

0 comments on commit a9d91d4

Please sign in to comment.