Skip to content

Commit

Permalink
Merge pull request #149 from labhackercd/develop
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
erivanio authored Sep 10, 2021
2 parents a6e7bb1 + d303269 commit f1ee851
Show file tree
Hide file tree
Showing 23 changed files with 216 additions and 253 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM labhackercd/alpine-python3-nodejs
FROM dockerhub-pub.camara.leg.br/labhacker/alpine-python3-nodejs:1.0.0

ENV BUILD_PACKAGES postgresql-dev postgresql-client gettext

Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Django==1.11.3
Django==1.11.29
python-decouple>=3.0
django-compressor>=2.1
django-compressor-toolkit>=0.6.0
Expand All @@ -8,4 +8,5 @@ django-tastypie>=0.14.0
django-js-reverse>=0.7.3
requests>=2.18.3
django-livereload-server>=0.2.3
git+https://github.com/tenhodito/pygov-br.git
git+https://github.com/tenhodito/pygov-br.git
django-cors-headers==3.1.0
22 changes: 22 additions & 0 deletions src/api/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,25 @@ class Meta:
'id': ALL,
'agenda': ALL_WITH_RELATIONS,
}


class VoteResource(ModelResource):

agenda = fields.ToOneField(AgendaResource, 'agenda', full=True, null=True)
proposal = fields.ToOneField(ProposalResource, 'proposal',
full=True, null=True)
proposal_group = fields.ToOneField(ProposalGroupResource, 'proposal_group',
full=True, null=True)

class Meta:
queryset = models.Vote.objects.filter(agenda__is_visible=True)
allowed_methods = ['get']
filtering = {
'id': ALL,
'agenda': ALL_WITH_RELATIONS,
'proposal': ALL_WITH_RELATIONS,
'proposal_group': ALL_WITH_RELATIONS,
'datetime': ALL,
'vote': ALL,
}
ordering = ['datetime', 'vote']
1 change: 1 addition & 0 deletions src/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
v1_api.register(resources.ProposalResource())
v1_api.register(resources.ProposalGroupResource())
v1_api.register(resources.ProposalTypeResource())
v1_api.register(resources.VoteResource())

urlpatterns = [
url(r'^api/', include(v1_api.urls)),
Expand Down
20 changes: 20 additions & 0 deletions src/core/migrations/0004_agenda_video_id.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.23 on 2019-10-31 14:25
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0003_vote_ip'),
]

operations = [
migrations.AddField(
model_name='agenda',
name='video_id',
field=models.CharField(blank=True, max_length=200, null=True, verbose_name='youtube id'),
),
]
5 changes: 3 additions & 2 deletions src/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def save(self, *args, **kwargs):
class Agenda(models.Model):

initial_date = models.DateField(verbose_name=_("Initial date"))
video_id = models.CharField(_('youtube id'), max_length=200, blank=True, null=True)
end_date = models.DateField(verbose_name=_("End date"))
title = models.CharField(max_length=100, verbose_name=_("Title"))
description = models.TextField(verbose_name=_("Description"))
Expand Down Expand Up @@ -116,8 +117,8 @@ def save(self, *args, **kwargs):
self.year)

self.url = ('http://www.camara.gov.br/'
'proposicoesWeb/fichadetramitacao'
'?idProposicao={}'.format(proposal['idProposicao']))
'propostas-legislativas/{}'.format(
proposal['idProposicao']))
return super(Proposal, self).save(*args, **kwargs)


Expand Down
48 changes: 25 additions & 23 deletions src/core/static/js/app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

$('.JS-vote-input').click(function(event) {
$('.JS-vote-input').click(function (event) {
var target = $(event.target);
var siblingCheckbox = Votes.siblingCheckbox(target);
var voteType = Votes.getVoteType(target);
Expand Down Expand Up @@ -33,7 +33,7 @@ $('.JS-vote-input').click(function(event) {
Buttons.changeButtonsState(target, groupId);
})

$('.JS-next-group-btn').click(function(event) {
$('.JS-next-group-btn').click(function (event) {
var target = $(event.target);
if (target.hasClass('-disabled')) {
AlertMessage.remainingVotesError();
Expand All @@ -42,7 +42,7 @@ $('.JS-next-group-btn').click(function(event) {
Tabs.next(target);
});

$('.JS-prev-group-btn').click(function(event) {
$('.JS-prev-group-btn').click(function (event) {
var target = $(event.target);
if (target.hasClass('-disabled')) {
AlertMessage.remainingVotesError();
Expand All @@ -51,7 +51,7 @@ $('.JS-prev-group-btn').click(function(event) {
Tabs.previous(target);
});

$('.JS-tab-item').click(function(event) {
$('.JS-tab-item').click(function (event) {
var target = $(event.target);
if (target.hasClass('-active')) {
return false;
Expand All @@ -71,7 +71,7 @@ if ($('.JS-remaining-votes').length) {
var remainingVotesOffset = 0;
}

$(window).scroll(function(event) {
$(window).scroll(function (event) {
Scroll.themeNavigation();
if ($('.JS-remaining-votes').length) {
var navigation = $('.JS-tab-navigation');
Expand All @@ -88,19 +88,19 @@ $(window).scroll(function(event) {
}
});

$('.JS-change-votes').click(function(event) {
$('.JS-change-votes').click(function (event) {
var target = $(event.target);
var groupId = target.closest('.JS-group-review').data('groupId');
Tabs.changeActiveGroupTo('finish', groupId);
});

$('.JS-error-close').click(function(event) {
$('.JS-error-close').click(function (event) {
var target = $(event.target);
target.closest('.JS-error-message').removeClass('-show');
setTimeout.clearAll();
});

$('.JS-confirm-votes').submit(function(e) {
$('.JS-confirm-votes').submit(function (e) {
var submitButton = $(this).find('.JS-submit-votes-btn');
var csrftoken = $(this).find('[name="csrfmiddlewaretoken"]').val();
var recaptchaResponse = $(this).find('[name="g-recaptcha-response"]').val();
Expand All @@ -115,7 +115,7 @@ $('.JS-confirm-votes').submit(function(e) {
groups: []
};

$('.JS-group-form').each(function() {
$('.JS-group-form').each(function () {
var groupId = $(this).closest('.JS-group').data('groupId');
var groupData = {
groupId: groupId,
Expand All @@ -125,7 +125,7 @@ $('.JS-confirm-votes').submit(function(e) {
})

$.ajaxSetup({
beforeSend: function(xhr, settings) {
beforeSend: function (xhr, settings) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
});
Expand All @@ -135,12 +135,12 @@ $('.JS-confirm-votes').submit(function(e) {
$.ajax({
method: 'POST',
url: window.Urls.agenda(agendaId),
data: {data: JSON.stringify(data)},
success: function(data) {
data: { data: JSON.stringify(data) },
success: function (data) {
window.onbeforeunload = null;
window.location.href = window.location.href;
},
error: function(data) {
error: function (data) {
submitButton.removeAttr('disabled');
submitButton.removeClass('-loading');
console.log(data);
Expand All @@ -156,54 +156,56 @@ if (!hideTutorial || hideTutorial == 'false') {
$('.JS-help-button').addClass('-active');
}

$('.JS-help-button').click(function(event) {
$('.JS-help-button').click(function (event) {
$(this).addClass('-active');
$('.JS-tutorial.-active').removeClass('-active');
$('.JS-modal').find('.JS-tutorial').first().addClass('-active');
$('.JS-modal').addClass('-show');
});

$('.JS-modal-next').click(function(event) {
$('.JS-modal-next').click(function (event) {
var target = $(event.target);
var tutorial = target.closest('.JS-tutorial');
tutorial.removeClass('-active');
var next = tutorial.next('.JS-tutorial');
next.addClass('-active');
});

$('.JS-modal-close').click(function(event) {
$('.JS-modal-close').click(function (event) {
var target = $(event.target);
target.closest('.JS-modal').removeClass('-show');
$('.JS-help-button').removeClass('-active');
Cookie.create('hideTutorial', true);
});

$('.JS-navigation-btn').click(function(event) {
$('.JS-navigation-btn').click(function (event) {
var target = $(event.target);
var btn = target.find('.JS-prev-group-btn,.JS-next-group-btn');
if (btn.hasClass('-disabled')) {
AlertMessage.remainingVotesError();
}
});

$('.JS-share-lnk').click(function(event) {
$('.JS-share-lnk').click(function (event) {
Share.results(event.target);
});

$('.JS-alert-close').click(function(event) {
$('.JS-alert-close').click(function (event) {
AlertMessage.hide();
});

window.onbeforeunload = function(e) {
window.onbeforeunload = function (e) {
if ($('.JS-vote-input:checked').length) {
var confirmationMessage = 'Ao deixar a página você perderá todos os seus votos. ' +
'Tem certeza que quer sair?';
'Tem certeza que quer sair?';
(e || window.event).returnValue = confirmationMessage;
return confirmationMessage;
}
};

$('.JS-unlogged-user').click(function(event) {
AlertMessage.error('Você precisa <a href="/home?next=' + $(this).attr('href') + '">fazer login</a> para votar');
$('.JS-unlogged-user').click(function (event) {
AlertMessage.error(
'<a href="https://edemocracia.camara.leg.br/accounts/login/camara_deputados/?next=/pautaparticipativa/pauta/2">' +
'Você precisa fazer login para votar! </a>');
return false;
});
1 change: 1 addition & 0 deletions src/core/static/styles/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
@import 'components/modal-box';
@import 'components/vote-button';
@import 'components/proposal-card';
@import 'components/not-logged-in-card';
@import 'components/alert-message';
@import 'components/proposal-list';
@import 'components/remaining-votes';
Expand Down
2 changes: 1 addition & 1 deletion src/core/static/styles/base/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ $icons: (
youtube: "\e246",
youtube-play: "\e247",
youtube-square: "\e248",
adm-publica: "\61",
adm-publica: "\65",
agropecuaria: "\62",
assistencia-social: "\64",
cidades: "\65",
Expand Down
13 changes: 13 additions & 0 deletions src/core/static/styles/components/_agenda-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,17 @@
justify-content: center;
align-items: stretch;
flex-basis: 50%;


& > .description {
margin-top: auto;
align-self: flex-end;
font-size: 1rem;
padding: 1rem 0;

@include bp-mediumup {
padding-bottom: 0
}
}

}
14 changes: 14 additions & 0 deletions src/core/static/styles/components/_not-logged-in-card.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.not-logged-in-card {
@extend %card;

background-color: #d55c4d;

&:last-child {
margin-bottom: 1rem;
}

> a {
color: #FFFFFF;
}

}
6 changes: 3 additions & 3 deletions src/core/templates/components/agenda-block.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<div class="title">Concluir</div>

<div class="note-message">
<p class="text">Confira os seus votos.</p>
<p class="text">Depois de enviar, eles não poderão ser alterados!</p>
<p class="text">Confira seus votos.</p>
<p class="text">Depois de enviá-los, eles não poderão ser alterados!</p>
</div>

<div class="controls">
Expand All @@ -53,7 +53,7 @@
<div class="modal">
<div class="tutorial -active JS-tutorial">
<h3 class="title">Bem-vindo!</h3>
<p>Esta pauta contém 3 temas:</p>
<p>Esta pauta contém {{ object.groups.count }} tema(s):</p>
<ul class="themes">
{% for group in object.groups.all %}
<li class="theme-tag -{{group.theme.slug}}">{{group.theme.name}}</li>
Expand Down
4 changes: 4 additions & 0 deletions src/core/templates/components/group-block.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ <h2 class="title -{{group.theme.slug}}">{{group.theme.name}}</h2>

{% include "components/navigation-controls.html" with group=group first_group=first_group %}

{% if not request.user.is_authenticated %}
{% include "components/not-logged-in-card.html" %}
{% endif %}

<form class="group-form JS-group-form" action="">
<ul class="proposal-list">
{% for proposal in group.proposals.all|randomize %}
Expand Down
5 changes: 5 additions & 0 deletions src/core/templates/components/not-logged-in-card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<div class="not-logged-in-card">
<a href="https://edemocracia.camara.leg.br/accounts/login/camara_deputados/?next=/pautaparticipativa/pauta/2">
<p> Atenção! Você precisa fazer login para votar. </p>
</a>
</div>
12 changes: 6 additions & 6 deletions src/core/templates/components/proposal-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ <h3 class="title">{{proposal.title}}</h3>
<p class="description">{{proposal.description}}</p>

<div class="votes">
<div class="vote-button -upvote JS-tickbox" data-tooltip="Você já usou seus votos a favor" data-hide-tooltip>
<input class="JS-vote-input" id="group{{group.id}}-upvote{{proposal.id}}" type="checkbox" name="{{proposal.id}}" value="upvote" data-vote-type="upvote">
<label for="group{{group.id}}-upvote{{proposal.id}}">Quero isto na pauta</label>
<div class="vote-button -upvote JS-tickbox {% if not request.user.is_authenticated %}JS-unlogged-user disabled{% endif %}" data-tooltip="Você já usou seus votos a favor" data-hide-tooltip>
<input {% if not request.user.is_authenticated %} disabled {% endif %} class="JS-vote-input" id="group{{group.id}}-upvote{{proposal.id}}" type="checkbox" name="{{proposal.id}}" value="upvote" data-vote-type="upvote">
<label for="group{{group.id}}-upvote{{proposal.id}}">Quero que votem</label>
</div>
<div class="vote-button -downvote JS-tickbox" data-tooltip="Você já usou seu voto contra" data-hide-tooltip>
<input class="JS-vote-input" id="group{{group.id}}-downvote{{proposal.id}}" type="checkbox" name="{{proposal.id}}" value="downvote" data-vote-type="downvote">
<label for="group{{group.id}}-downvote{{proposal.id}}">Não quero isto na pauta</label>
<div class="vote-button -downvote JS-tickbox {% if not request.user.is_authenticated %}JS-unlogged-user {% endif %}" data-tooltip="Você já usou seu voto contra" data-hide-tooltip>
<input {% if not request.user.is_authenticated %} disabled {% endif %} class="JS-vote-input" id="group{{group.id}}-downvote{{proposal.id}}" type="checkbox" name="{{proposal.id}}" value="downvote" data-vote-type="downvote">
<label for="group{{group.id}}-downvote{{proposal.id}}">Não quero que votem</label>
</div>
</div>

Expand Down
6 changes: 6 additions & 0 deletions src/core/templates/components/results.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@ <h2 class="title">Resultado Parcial</h2>
<p class="text">Compartilhe esta pauta para mais pessoas votarem</p>
</div>

{% if object.id == 1 %}
<div class="note-message">
<p class="text">Veja uma <a href="{% url 'relatorio-pauta-1' %}">análise do processo participativo</a>.</p>
</div>
{% endif %}

<div class="note-message">
<p class="text"><a href="{% url 'download-csv' object.id %}">Baixe o resultado em csv</a></p>
</div>

<div class="share">
<a class="link -facebook JS-share-lnk" data-social="facebook" title="Facebook"></a>
Expand Down
Loading

0 comments on commit f1ee851

Please sign in to comment.