From 3247180dfa776eb4109712387b7a8a5520ae068e Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 28 Jul 2015 20:32:53 +0200 Subject: [PATCH 01/12] responds with ajax to comment creation [#47] --- app/controllers/comments_controller.rb | 9 +++++---- app/views/comments/_form.html.erb | 2 +- app/views/comments/create.js.erb | 4 ++++ 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 app/views/comments/create.js.erb diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 91a92e5ba..00fd20653 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -1,12 +1,13 @@ class CommentsController < ApplicationController before_action :authenticate_user! before_action :set_debate, :set_parent + respond_to :html, :js def create - comment = Comment.build(@debate, current_user, params[:comment][:body]) - comment.save! - comment.move_to_child_of(@parent) if reply? - redirect_to @debate, notice: "Comentario guardado" + @comment = Comment.build(@debate, current_user, params[:comment][:body]) + @comment.save! + @comment.move_to_child_of(@parent) if reply? + respond_with @comment end private diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 03b6caad7..11478e39b 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -1,7 +1,7 @@ <%= link_to comment_link_text(parent), "", class: "js-add-comment-link", data: {'id': dom_id(parent)} %> -
-
-
- <%= link_to debate_votes_path(@debate, value: 'yes'), :class => 'in-favor', method: "post" do %> - - <%= percentage('likes', @debate) %> - <% end %> -
- - - -
- <%= link_to debate_votes_path(@debate, value: 'no'), :class => 'against', method: "post" do %> - - <%= percentage('dislikes', @debate) %> - <% end %> -
-
- -
-

<%= pluralize(@debate.total_votes, t("debates.debate.vote"), t("debates.debate.votes")) %>

-
+
+ <%= render 'votes/vote' %>
diff --git a/app/views/votes/_vote.html.erb b/app/views/votes/_vote.html.erb new file mode 100644 index 000000000..95e32460a --- /dev/null +++ b/app/views/votes/_vote.html.erb @@ -0,0 +1,23 @@ +
+
+ <%= link_to debate_votes_path(@debate, value: 'yes'), class: 'in-favor', method: 'post', remote: true do %> + + <%= percentage('likes', @debate) %> + <% end %> +
+ + + +
+ <%= link_to debate_votes_path(@debate, value: 'no'), class: 'against', method: 'post', remote: true do %> + + <%= percentage('dislikes', @debate) %> + <% end %> +
+
+ +
+

+ <%= pluralize(@debate.total_votes, t("debates.debate.vote"), t("debates.debate.votes")) %> +

+
\ No newline at end of file diff --git a/app/views/votes/create.js.erb b/app/views/votes/create.js.erb new file mode 100644 index 000000000..55733e509 --- /dev/null +++ b/app/views/votes/create.js.erb @@ -0,0 +1 @@ +$("#votes").html("<%= j render('vote') %>"); \ No newline at end of file From 8a642d3c967f4d7aa50d36edbd1cc394c6f16b20 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 28 Jul 2015 20:53:09 +0200 Subject: [PATCH 04/12] fixes specs [#47] --- spec/features/votes_spec.rb | 38 +++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/spec/features/votes_spec.rb b/spec/features/votes_spec.rb index cec794376..d1aabd84a 100644 --- a/spec/features/votes_spec.rb +++ b/spec/features/votes_spec.rb @@ -28,21 +28,47 @@ feature 'Votes' do end end - scenario 'Create' do + scenario 'Create', :js do find('#in_favor a').click - expect(page).to have_content "Thanks for voting." + + within('#in_favor') do + expect(page).to have_content "100%" + end + + within('#against') do + expect(page).to have_content "0%" + end + + expect(page).to have_content "1 vote" end - scenario 'Update' do + scenario 'Update', :js do find('#in_favor a').click find('#against a').click - expect(page).to have_content "Thanks for voting." + + within('#in_favor') do + expect(page).to have_content "0%" + end + + within('#against') do + expect(page).to have_content "100%" + end + + expect(page).to have_content "1 vote" end - scenario 'Trying to vote multiple times' do + scenario 'Trying to vote multiple times', :js do find('#in_favor a').click find('#in_favor a').click - expect(page).to have_content "Your vote is already registered." + + within('#in_favor') do + expect(page).to have_content "100%" + end + + within('#against') do + expect(page).to have_content "0%" + end + expect(page).to have_content "1 vote" end From 63cac453e6e51d7ad7b3156f68df2816fc828642 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Tue, 28 Jul 2015 21:04:58 +0200 Subject: [PATCH 05/12] binds js behaviour to ajax generated content [#47] --- app/assets/javascripts/comments.js.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/comments.js.coffee b/app/assets/javascripts/comments.js.coffee index b40da3485..79333e0c7 100644 --- a/app/assets/javascripts/comments.js.coffee +++ b/app/assets/javascripts/comments.js.coffee @@ -4,7 +4,7 @@ jQuery -> $("#js-comment-form-#{id}").toggle() ready = -> - $('.js-add-comment-link').click -> + $('body').on 'click', '.js-add-comment-link', -> id = $(this).data().id toggle_comment(id) false From f1ebca66c1ad62aff920f104d8e143044f91686e Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 30 Jul 2015 12:55:45 +0200 Subject: [PATCH 06/12] add app.js module --- app/assets/javascripts/app.js.coffee | 1 + app/assets/javascripts/application.js | 1 + 2 files changed, 2 insertions(+) create mode 100644 app/assets/javascripts/app.js.coffee diff --git a/app/assets/javascripts/app.js.coffee b/app/assets/javascripts/app.js.coffee new file mode 100644 index 000000000..d8efafdee --- /dev/null +++ b/app/assets/javascripts/app.js.coffee @@ -0,0 +1 @@ +window.App = {} diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index c73d04209..5c03e171e 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -15,6 +15,7 @@ //= require foundation //= require turbolinks //= require ckeditor/init +//= require app //= require_tree . $(function(){ $(document).foundation(); }); From 1237f9d8ad9f58652619205faca8b6e5efb69c2f Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 30 Jul 2015 13:19:34 +0200 Subject: [PATCH 07/12] make a comments module. Move module initializing to application.js --- app/assets/javascripts/application.js | 11 ++++++++++- app/assets/javascripts/comments.js.coffee | 12 ++++++------ 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 5c03e171e..08153c4ec 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -18,4 +18,13 @@ //= require app //= require_tree . -$(function(){ $(document).foundation(); }); +var initialize_modules = function() { + App.Comments.initialize(); +}; + +$(function(){ + $(document).foundation(); + + $(document).ready(initialize_modules) + $(document).on('page:load', initialize_modules) +}); diff --git a/app/assets/javascripts/comments.js.coffee b/app/assets/javascripts/comments.js.coffee index 79333e0c7..a84cd02ac 100644 --- a/app/assets/javascripts/comments.js.coffee +++ b/app/assets/javascripts/comments.js.coffee @@ -1,13 +1,13 @@ -jQuery -> - toggle_comment = (id) -> +App.Comments = + + toggle_form: (id) -> $("#js-comment-form-#{id}").toggle() - ready = -> + initialize: -> $('body').on 'click', '.js-add-comment-link', -> id = $(this).data().id - toggle_comment(id) + App.Comments.toggle_form(id) false - $(document).ready(ready) - $(document).on('page:load', ready) \ No newline at end of file + From 59cea45c26ef53ee039604a61c30f2eb125db75f Mon Sep 17 00:00:00 2001 From: kikito Date: Thu, 30 Jul 2015 14:08:05 +0200 Subject: [PATCH 08/12] Use App.Comments module in create.js.erb --- app/assets/javascripts/comments.js.coffee | 9 ++++++++- app/views/comments/create.js.erb | 7 +++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/comments.js.coffee b/app/assets/javascripts/comments.js.coffee index a84cd02ac..7a8743f88 100644 --- a/app/assets/javascripts/comments.js.coffee +++ b/app/assets/javascripts/comments.js.coffee @@ -1,6 +1,13 @@ - App.Comments = + add_response: (parent_id, response_html) -> + $(response_html).insertAfter($("#js-comment-form-#{parent_id}")) + + reset_and_hide_form: (id) -> + form = $("#js-comment-form-#{id}") + form.val('') + form.hide() + toggle_form: (id) -> $("#js-comment-form-#{id}").toggle() diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index b694c6a69..9eeec3108 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -1,4 +1,3 @@ -var form = "#js-comment-form-<%= dom_id(@parent) %>" -$(form + " #comment_body").val(''); -$(form).hide(); -$("<%= j(render @comment) %>").insertAfter($(form)); \ No newline at end of file +var parent_id = '<%= dom_id(@parent) %>'; +App.Comments.reset_and_hide_form(parent_id); +App.Comments.add_response(parent_id, "<%= j(render @comment) %>"); From cd2d05e0c5ea5792ed74ca7e89134c8c794f4971 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 30 Jul 2015 18:18:28 +0200 Subject: [PATCH 09/12] fixing conflicts [#47] [#47] --- CONTRIBUTING.md | 38 +++++++++++ MIT-LICENSE.md | 21 +++++++ README.md | 45 +++++++++++++ README.rdoc | 28 --------- app/assets/images/comments_divider.png | Bin 0 -> 1537 bytes app/assets/images/user_default_2.jpg | Bin 0 -> 1703 bytes app/assets/stylesheets/debates.scss | 84 +++++++++++++++++++++---- app/controllers/account_controller.rb | 23 +++++++ app/views/account/show.html.erb | 13 ++++ app/views/comments/_comment.html.erb | 27 ++++---- app/views/comments/_form.html.erb | 2 +- app/views/debates/show.html.erb | 4 +- app/views/layouts/_footer.html.erb | 3 +- app/views/layouts/_header.html.erb | 6 ++ app/views/votes/_votes.html.erb | 40 ++++++------ config/locales/en.yml | 7 ++- config/locales/es.yml | 7 ++- config/locales/responders.en.yml | 3 + config/locales/responders.es.yml | 4 +- config/routes.rb | 2 + spec/features/account_spec.rb | 33 ++++++++++ 21 files changed, 312 insertions(+), 78 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 MIT-LICENSE.md create mode 100644 README.md delete mode 100644 README.rdoc create mode 100644 app/assets/images/comments_divider.png create mode 100644 app/assets/images/user_default_2.jpg create mode 100644 app/controllers/account_controller.rb create mode 100644 app/views/account/show.html.erb create mode 100644 spec/features/account_spec.rb diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..f06f5b703 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,38 @@ +## Miembros del equipo + +* Raimond Garcia [github](https://github.com/voodoorai2000) | [twitter](https://twitter.com/voodoorai2000) +* Juanjo Bazán [github](https://github.com/xuanxu) | [twitter](https://twitter.com/xuanxu) +* Enrique García Cota [github](https://github.com/kikito) | [twitter](https://twitter.com/otikik) +* Alberto Garcia Cabeza [github](https://github.com/decabeza) | [twitter](https://twitter.com/decabeza) + +## Comunicación general y de incidencias + +El método preferido para informar sobre una incidencia en el proyecto es [creando una incidencia en la cuenta de Github del proyecto](https://github.com/AyuntamientoMadrid/participacion/issues/new). + +Para comunicación más puntual e informal, contacta con los miembros del equipo por twitter. + +## Resolver una incidencia + +Cuando quieras resolver una incidencia mediante código: + +* Avisa de que vas a trabajar en esta incidencia añadiendo un comentario +* Haz un fork del proyecto +* Crea una rama para resolver la incidencia desde la rama `master` +* Añade el código necesario para resolver la incidencia en tantos commits como sea preciso +* Asegúrate de que los tests pasan (y escribe más tests para probar la nueva funcionalidad si fuera preciso) +* Envía una *pull request* al repositorio principal indicando la incidencia que se está arreglando + +## Otras formas de contribuir sin código + +* Si crees que hay una funcionalidad que hace falta, o descubres un problema, abre una incidencia (asegúrate de que + no haya una incidencia para lo mismo ya abierta antes) +* También puedes ayudar dando este proyecto a conocer + +## Cómo escribir una incidencia + +* Trata de darle un título descriptivo (algo más que "xxx no funciona"). +* Es buena idea incluir las siguientes secciones: + * Pasos que se han realizado para producir la incidencia + * Lo que se esperaba que pasara + * Lo que ha pasado +* También es buena idea que incluyas tu sistema operativo, navegador, versión de navegador y plugins instalados. diff --git a/MIT-LICENSE.md b/MIT-LICENSE.md new file mode 100644 index 000000000..8bdbc6043 --- /dev/null +++ b/MIT-LICENSE.md @@ -0,0 +1,21 @@ +# The MIT License (MIT) + +## Copyright (c) 2015 Ayuntamiento de Madrid + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 000000000..648cefd8d --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Aplicación de Participación Ciudadana del Ayuntamiento de Madrid + +Este es el repositorio de código abierto de la Aplicación de Participación Ciudadana del Ayuntamiento de Madrid. + +## Estado del proyecto + +El desarrollo de esta aplicación comenzó el [15 de Julio de 2015](https://github.com/AyuntamientoMadrid/participacion/commit/8db36308379accd44b5de4f680a54c41a0cc6fc6) + +Este proyecto está en las primeras fases de su desarrollo. Las funcionalidades actualmente presentes en el código, así como sus nombres, deben considerarse como provisionales. + +## Tecnología + +El backend de esta aplicación se desarrolla con el lenguaje de programación [Ruby](https://www.ruby-lang.org/) sobre el *framework* [Ruby on Rails](http://rubyonrails.org/). +Las herramientas utilizadas para el frontend no están cerradas aún. Los estilos de la página usan [SCSS](http://sass-lang.com/) sobre [Foundation](http://foundation.zurb.com/) + +## Configuración para desarrollo y tests + +Prerequisitos: tener instalado git, Ruby 2.2.2, la gema `bundler`, y una librería moderna de PostgreSQL. + +``` +cd participacion +bundle install +cp config/database.yml.example config/database.yml +cp config/secrets.yml.example config/secrets.yml +bundle exec bin/rake db:create db:schema_load +RAILS_ENV=test bundle exec rake db:create db:schema_load +``` + +Para ejecutar la aplicación en local: +``` +bundle exec bin/rails s +``` + +Para ejecutar los tests: +``` +bundle exec bin/rspec +``` + +## Licencia + +El código de este proyecto está publicado bajo la licencia MIT (ver MIT-license.md) + +## Contribuciones + +Ver fichero CONTRIBUTING.md diff --git a/README.rdoc b/README.rdoc deleted file mode 100644 index dd4e97e22..000000000 --- a/README.rdoc +++ /dev/null @@ -1,28 +0,0 @@ -== README - -This README would normally document whatever steps are necessary to get the -application up and running. - -Things you may want to cover: - -* Ruby version - -* System dependencies - -* Configuration - -* Database creation - -* Database initialization - -* How to run the test suite - -* Services (job queues, cache servers, search engines, etc.) - -* Deployment instructions - -* ... - - -Please feel free to use a different markup language if you do not plan to run -rake doc:app. diff --git a/app/assets/images/comments_divider.png b/app/assets/images/comments_divider.png new file mode 100644 index 0000000000000000000000000000000000000000..1d2bffd9b83291c0730c5ea7edcf5d6c67e5367e GIT binary patch literal 1537 zcmeAS@N?(olHy`uVBq!ia0vp^u|Ukm!3HE3T1@&5q$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~;1FfeOmhD4M^`1)8S=jZArg4F0$^BXQ!4Z zB&DWj=GiK}-@RW+Av48RDcsc8z_-9TH6zobswg$M$}c3jDm&RSMakYy!KT6rXh3di zNuokUZcbjYRfVk**jy_h8zii+qySb@l5ML5aa4qFfP!;=QL2Keo|$g4ftk62xuu?= zskym{xsHO7fuX6sfw8`^fv%CUm5G6siID;nC;@FNN=dT{a&d#&1?1T(Wt5Z@Sn2DR zmzV368|&p4rRy77T3YHG80i}s=>k>g7FXt#Bv$C=6)VF`a7isrF3Kz@$;{7F0GXJW zlwVq6s|0i@#0$9vaAWg|p}_L?onmQS}I=LDc zm>D}+8kkr*o5A$DF%IFnd9d(DvvixH6^HZMurM(;bpqb;y62oS8tK8K&Rlk?3b&a@pBxW zdWAD$c{9Dyt+sUGS>Y0z-)r{o&-#h$K z7k+5gxt!T@sOo2-rM-*zHiIv$cS%g zn(s%kZaSm(!q-F<&1dp5lTbDC;=xcMPE4&lT+@w>ZB6RcElRnc! zsc{|g?G?Z7=V>3hdP|40k;} z(NUkTHYbD4AZqP3=g=KDt}?!;7hO1i#Uar+pKB{ZwDLlCc;-%H-73GD$^Yc}%}atb z#l>zi$BLa@WGK~ptTxgjeT$r}+BOZ1r9{F^Txkz`Lhs7;x)#uh z&S?Z8TjH{0E+bpwV3;wK1qy;cQ3?CWRAQI|lrb_leq?hPP;}g`9X~FS#W%U+``-6? zp7;IU@BNOw$qs`x8D63YfXvLzKnRwMod6=e+ge-(ARyq}HUQXRK4xbarv^nym&{_L z3UQg0a-d#|6UAh56eOp5ofc~`&cKEEZi3Vzf1Ev!z=TbU>`)rzMyC$96I;t^Jhyzi z*;-y~Rojr%6gb(d@j9FioUy=OM+xcDc(q7CT*IyXZWMt75T;m*r1`VL`NnKmN6|Q} zlqE^6@+1|kQp+%qQDfG z%Ai(c=nNQ^p-jgz(lg}pq=a;}JW;JnTHxv_tJ{H-%mUZ8#7$e4>mLY*lgq5fY2q#1 zW}qnt95}d!SiTn3vU>Ae+w!$+S(b}(#i0J{ed4+oT-*%#my5&8Z5GELC%KuYx#4Cf zL0Dj9f$akKh#+Lth)S~{g^@uyr6x&qa0uHER&kklBEATug8pb;RdQv0 zr8z6D=~RvcsTl0}#abu1eO+8aR8$WcPS-rQkvPWFJ@@X%rq2~1XVAZ{ z`=CcheIGYCYqKX5KbQYLxNGf;BkE+Gdv#yu-rBCVb>ep-;*N-E;Z$Gs?7FsLN&UW5 zv-^$SD|H`6raayl#e&(d<)T}@meS#iF&8i8HnZShfq3oY>$|Et#%`t&oh-;7t*-9P zz2u46SC^Has_uJi+j@or_ZuWkZ;RJcMDjO~+ zd%FV}3!NBh>d5_SR(DFV({%Mn|C!FVFPq2jU*hacSVz~{n}wuo@Luf`wD$Z3?B~d9&c@_IfVSW|3*&s-3QcZ^N+fQO5PXk z>E^n3!}<|@T=Pt?>7>2)KoCzh-gvYprKmBPxA{hnc@Oe!L!)%7GDS}ryZaILr+)y9 C7$`~r literal 0 HcmV?d00001 diff --git a/app/assets/stylesheets/debates.scss b/app/assets/stylesheets/debates.scss index d99c589f8..d25beb53f 100644 --- a/app/assets/stylesheets/debates.scss +++ b/app/assets/stylesheets/debates.scss @@ -8,7 +8,7 @@ // 05.1. Debates Index // 05.2. Debates Show // 06. Comments -// 06. Tags +// 07. Tags // // 01. Variables @@ -24,6 +24,9 @@ $brand: #0077B9; $debates: #008CCF; $comments-bg: #FAF9F8; +$comments-info: #A5B2B9; +$comments-text: #3F4549; + $header-color: #292B33; $link: #0077B9; @@ -33,7 +36,7 @@ $tags-border: #F0F0F0; $tags-color: #8F8F8F; $text-color: #919399; -$text-medium: #999999; +$text-medium: #999999; $text-light: #a3a6ad; $votes-background: #EDEDED; @@ -92,7 +95,7 @@ header { } h1 { - color: white; + color: white; font-size: rem-calc(45); font-weight: bolder; line-height: $line-height*3; @@ -231,7 +234,7 @@ header { margin-bottom: $line-height; } } - + .votes { background: $votes-background; margin: -5px -20px -20px -20px; @@ -291,15 +294,16 @@ header { .debate-show { color: $text-medium; margin-top: $line-height; - padding: 0 $line-height/2; + margin-bottom: $line-height*2; + padding: 0 $line-height/2; .back { color: $text-light; font-size: rem-calc(13); line-height: $line-height; - } + } - h1 { + h1 { clear: both; font-size: rem-calc(24); font-weight: bold; @@ -323,7 +327,7 @@ header { font-size: rem-calc(14); line-height: $line-height; margin-bottom: 0; - } + } } .author-photo { @@ -335,13 +339,13 @@ header { vertical-align: middle; width: 32px; } - + .votes { border: 1px solid $votes-border; box-shadow: 0 2px 0 rgba(0,0,0,.1); border-radius: 3px; padding: $line-height/2; - + .fi-like { background: $votes-like; border: 1px solid $votes-like-b; @@ -398,6 +402,10 @@ header { width: 1px; } } + + .publish-comment { + margin-top: $line-height; + } } // 06. Comments @@ -405,19 +413,71 @@ header { .comments { background: $comments-bg; - margin-top: $line-height*2; + background-image: url('comments_divider.png'); + background-repeat: repeat-x; padding-top: $line-height; + padding-bottom: $line-height*4; h2 { margin: 0; font-weight: bold; } + + .comment { + margin: $line-height/4 0; + + p { + color: $comments-text; + font-size: rem-calc(15); + margin-bottom: 0; + } + + a { + color: $comments-info; + } + + .user-photo { + border-radius: 2px; + display: inline-block; + height: 32px; + line-height: $line-height*2; + margin-right: $line-height/4; + vertical-align: top; + width: 32px; + } + + .comment-body { + margin-left: $line-height*1.6; + + .reply { + font-size: rem-calc(12); + font-weight: lighter; + } + } + + .comment-children { + border-left: 1px dotted $border; + margin-left: $line-height*1.6; + padding-left: $line-height/4; + + @media only screen and (max-width: 40em) { + margin-left: $line-height/1.5; + } + } + + .comment-info { + color: $comments-info; + font-size: rem-calc(13); + font-weight: lighter; + vertical-align: middle; + } + } } // 07. Tags // - - - - - - - - - - - - - - - - - - - - - - - - - -.tags a { +.tags a { background: $tags-bg; border: 1px solid $tags-border; border-radius: 3px; diff --git a/app/controllers/account_controller.rb b/app/controllers/account_controller.rb new file mode 100644 index 000000000..fa626ece9 --- /dev/null +++ b/app/controllers/account_controller.rb @@ -0,0 +1,23 @@ +class AccountController < ApplicationController + + before_action :authenticate_user! + before_action :set_account + + def show + end + + def update + flash[:notice] = t("flash.actions.save_changes.notice") if @account.update(account_params) + redirect_to account_path + end + + private + def set_account + @account = current_user + end + + def account_params + params.require(:account).permit(:first_name, :last_name) + end + +end diff --git a/app/views/account/show.html.erb b/app/views/account/show.html.erb new file mode 100644 index 000000000..b3d45d967 --- /dev/null +++ b/app/views/account/show.html.erb @@ -0,0 +1,13 @@ +

<%= t("account.show.title") %>

+ +<%= form_for @account, as: :account, url: account_path do |f| %> + <%= f.label :first_name, t("account.show.first_name_label") %> + <%= f.text_field :first_name %> + <%= f.label :last_name, t("account.show.last_name_label") %> + <%= f.text_field :last_name %> + + <%= f.submit t("account.show.save_changes_submit"), class: "button radius" %> +<% end %> + +<%= link_to t("account.show.change_credentials_link"), edit_user_registration_path %> + diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index a27a689c9..0d152d928 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -1,13 +1,18 @@ -
-

<%= comment.user.name %>

-

hace <%= time_ago_in_words(comment.created_at) %>

-

<%= comment.body %>

+
+
-
- <%= render comment.children %> -
- -
- <%= render 'comments/form', parent: comment %> -
+ <%= image_tag('user_default_2.jpg', class: 'user-photo left', size: '32x32') %> + +
+ + <%= comment.user.name %> • <%= time_ago_in_words(comment.created_at) %> + +

<%= comment.body %>

+

<%= render 'comments/form', parent: comment %>

+
+ +
+ <%= render comment.children %> +
+
\ No newline at end of file diff --git a/app/views/comments/_form.html.erb b/app/views/comments/_form.html.erb index 6e2c95c7f..01661221f 100644 --- a/app/views/comments/_form.html.erb +++ b/app/views/comments/_form.html.erb @@ -6,6 +6,6 @@ <%= f.hidden_field :commentable_type, value: parent.class %> <%= f.hidden_field :commentable_id, value: parent.id %> - <%= f.submit comment_button_text(parent), class: "button radius" %> + <%= f.submit comment_button_text(parent), class: "button radius small" %> <% end %>
diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb index feebfda56..c164b6638 100644 --- a/app/views/debates/show.html.erb +++ b/app/views/debates/show.html.erb @@ -4,7 +4,7 @@
- <%= link_to "< ".html_safe + t("debates.show.back_link"), debates_path, class: 'left back' %> + <%= link_to "« ".html_safe + t("debates.show.back_link"), debates_path, class: 'left back' %>

<%= @debate.title %>

@@ -25,7 +25,7 @@

<%= t("debates.show.comments") %>

-
+
<%= t("debates.show.leave_comment") %> <%= render 'comments/form', parent: @debate %>
diff --git a/app/views/layouts/_footer.html.erb b/app/views/layouts/_footer.html.erb index 4becc055a..98e047a08 100644 --- a/app/views/layouts/_footer.html.erb +++ b/app/views/layouts/_footer.html.erb @@ -1,4 +1,3 @@ -
+
<%= image_tag('footer.jpg', style: 'width: 100%; max-width: 1170px;') %>
- \ No newline at end of file diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 95b5fb7af..4353e164a 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -23,6 +23,12 @@
<%= render 'devise/menu/login_items' %> + + <% if user_signed_in? %> +
    +
  • <%= link_to(t("layouts.header.my_account_link"), account_path) %>
  • +
+ <% end %>
diff --git a/app/views/votes/_votes.html.erb b/app/views/votes/_votes.html.erb index f29504995..bde222092 100644 --- a/app/views/votes/_votes.html.erb +++ b/app/views/votes/_votes.html.erb @@ -1,23 +1,25 @@
-
-
- <%= link_to debate_votes_path(@debate, value: 'yes'), class: 'in-favor', method: "post" do %> - - <%= percentage('likes', @debate) %> - <% end %> -
- - - -
- <%= link_to debate_votes_path(@debate, value: 'no'), class: 'against', method: "post" do %> - - <%= percentage('dislikes', @debate) %> - <% end %> -
+
+
+ <%= link_to debate_votes_path(@debate, value: 'yes'), class: 'in-favor', method: "post" do %> + + <%= percentage('likes', @debate) %> + <% end %>
-
-

<%= pluralize(@debate.total_votes, t("debates.debate.vote"), t("debates.debate.votes")) %>

+ + +
+ <%= link_to debate_votes_path(@debate, value: 'no'), class: 'against', method: "post" do %> + + <%= percentage('dislikes', @debate) %> + <% end %>
-
+
+ +
+

+ <%= pluralize(@debate.total_votes, t("debates.debate.vote"), t("debates.debate.votes")) %> +

+
+
\ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 0374b471b..9bcc65400 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -10,6 +10,7 @@ en: open_city: We are opening Madrid open_city_slogan: So the citizens can decide what kind of city they want. create_debate: Create a debate + my_account_link: My account debates: debate: debate: Debate @@ -40,4 +41,8 @@ en: back_link: Back votes: notice_thanks: "Thanks for voting." - notice_already_registered: "Your vote is already registered." \ No newline at end of file + notice_already_registered: "Your vote is already registered." + account: + show: + title: "My account" + save_changes_submit: "Save changes" diff --git a/config/locales/es.yml b/config/locales/es.yml index e88b83346..b702eb1fd 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -10,6 +10,7 @@ es: open_city: Estamos abriendo Madrid open_city_slogan: Para que todos los madrileños decidamos que ciudad queremos tener. create_debate: Crea un debate + my_account_link: Mi cuenta debates: debate: debate: Debate @@ -40,4 +41,8 @@ es: back_link: Volver votes: notice_thanks: "Gracias por votar." - notice_already_registered: "Tu voto ya ha sido registrado." \ No newline at end of file + notice_already_registered: "Tu voto ya ha sido registrado." + account: + show: + title: "Mi cuenta" + save_changes_submit: "Guardar cambios" diff --git a/config/locales/responders.en.yml b/config/locales/responders.en.yml index c3e147abf..cd0d93fe8 100644 --- a/config/locales/responders.en.yml +++ b/config/locales/responders.en.yml @@ -10,3 +10,6 @@ en: destroy: notice: '%{resource_name} was successfully destroyed.' alert: '%{resource_name} could not be destroyed.' + save_changes: + notice: "Saved" + diff --git a/config/locales/responders.es.yml b/config/locales/responders.es.yml index aa3a47f0d..ad8012f9e 100644 --- a/config/locales/responders.es.yml +++ b/config/locales/responders.es.yml @@ -7,4 +7,6 @@ es: notice: "%{resource_name} actualizado correctamente." destroy: notice: "%{resource_name} borrado correctamente." - alert: "%{resource_name} no ha podido ser borrado." \ No newline at end of file + alert: "%{resource_name} no ha podido ser borrado." + save_changes: + notice: "Cambios guardados" diff --git a/config/routes.rb b/config/routes.rb index a364ef871..f5afd988c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -11,6 +11,8 @@ Rails.application.routes.draw do resources :comments, only: :create end + resource :account, controller: "account", only: [:show, :update] + # Example of regular route: # get 'products/:id' => 'catalog#view' diff --git a/spec/features/account_spec.rb b/spec/features/account_spec.rb new file mode 100644 index 000000000..7179b6c6b --- /dev/null +++ b/spec/features/account_spec.rb @@ -0,0 +1,33 @@ +require 'rails_helper' + +feature 'Account' do + + background do + @user = create(:user, first_name: "Manuela", last_name:"Colau") + end + + scenario 'Show' do + login_as(@user) + visit root_path + click_link "My account" + + expect(page).to have_selector("input[value='Manuela']") + expect(page).to have_selector("input[value='Colau']") + end + + scenario 'Edit' do + login_as(@user) + visit account_path + + fill_in 'account_first_name', with: 'Larry' + fill_in 'account_last_name', with: 'Bird' + click_button 'Save changes' + + expect(page).to have_content "Saved" + + visit account_path + + expect(page).to have_selector("input[value='Larry']") + expect(page).to have_selector("input[value='Bird']") + end +end \ No newline at end of file From 5d5b9d00e02ee9d55345c77751470087d44d7033 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 30 Jul 2015 18:43:11 +0200 Subject: [PATCH 10/12] adds ajax to vote links [#47] --- app/views/votes/_votes.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/votes/_votes.html.erb b/app/views/votes/_votes.html.erb index bde222092..ddf2f9d5b 100644 --- a/app/views/votes/_votes.html.erb +++ b/app/views/votes/_votes.html.erb @@ -1,7 +1,7 @@
- <%= link_to debate_votes_path(@debate, value: 'yes'), class: 'in-favor', method: "post" do %> + <%= link_to debate_votes_path(@debate, value: 'yes'), class: 'in-favor', method: "post", remote: true do %> <%= percentage('likes', @debate) %> <% end %> @@ -10,7 +10,7 @@
- <%= link_to debate_votes_path(@debate, value: 'no'), class: 'against', method: "post" do %> + <%= link_to debate_votes_path(@debate, value: 'no'), class: 'against', method: "post", remote: true do %> <%= percentage('dislikes', @debate) %> <% end %> From ad0e578f2a80d24d3ce07e47a539691882fe3588 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 30 Jul 2015 18:43:28 +0200 Subject: [PATCH 11/12] renders votes partial on ajax request [#47] --- app/views/votes/create.js.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/votes/create.js.erb b/app/views/votes/create.js.erb index 55733e509..5e855e40e 100644 --- a/app/views/votes/create.js.erb +++ b/app/views/votes/create.js.erb @@ -1 +1 @@ -$("#votes").html("<%= j render('vote') %>"); \ No newline at end of file +$("#votes").html("<%= j render('votes') %>"); \ No newline at end of file From 5bdc3fbaa0d0b92bb7987e5b291be2a067e8ee29 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Thu, 30 Jul 2015 18:45:17 +0200 Subject: [PATCH 12/12] updates correct dom element after voting [#47] --- app/views/debates/show.html.erb | 2 ++ app/views/votes/_votes.html.erb | 42 ++++++++++++++++----------------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/app/views/debates/show.html.erb b/app/views/debates/show.html.erb index c164b6638..3ae0cace4 100644 --- a/app/views/debates/show.html.erb +++ b/app/views/debates/show.html.erb @@ -17,7 +17,9 @@

<%= render 'shared/tags', debate: @debate %>

+
<%= render 'votes/votes' %> +
diff --git a/app/views/votes/_votes.html.erb b/app/views/votes/_votes.html.erb index ddf2f9d5b..fd2704ed4 100644 --- a/app/views/votes/_votes.html.erb +++ b/app/views/votes/_votes.html.erb @@ -1,25 +1,23 @@ -
-
-
- <%= link_to debate_votes_path(@debate, value: 'yes'), class: 'in-favor', method: "post", remote: true do %> - - <%= percentage('likes', @debate) %> - <% end %> -
- - - -
- <%= link_to debate_votes_path(@debate, value: 'no'), class: 'against', method: "post", remote: true do %> - - <%= percentage('dislikes', @debate) %> - <% end %> -
+
+
+ <%= link_to debate_votes_path(@debate, value: 'yes'), class: 'in-favor', method: "post", remote: true do %> + + <%= percentage('likes', @debate) %> + <% end %>
-
-

- <%= pluralize(@debate.total_votes, t("debates.debate.vote"), t("debates.debate.votes")) %> -

+ + +
+ <%= link_to debate_votes_path(@debate, value: 'no'), class: 'against', method: "post", remote: true do %> + + <%= percentage('dislikes', @debate) %> + <% end %>
-
\ No newline at end of file +
+ +
+

+ <%= pluralize(@debate.total_votes, t("debates.debate.vote"), t("debates.debate.votes")) %> +

+