From 69b5e550a6ef47011d4bea0f5ee10e7323bbf599 Mon Sep 17 00:00:00 2001 From: Juan Carlos Date: Sun, 20 Apr 2014 19:00:24 -0500 Subject: [PATCH] agregar contenido de injuve a acciones, closes #33 --- Gemfile.lock | 84 +++++++++---------- app/models/user.rb | 15 +++- app/views/actions/show.html.haml | 14 ++++ .../shared/_action_submit_form.html.haml | 12 ++- ...20140420231033_add_recurrente_to_action.rb | 9 ++ db/schema.rb | 7 +- lib/tasks/sample_data.rake | 44 +++++----- 7 files changed, 108 insertions(+), 77 deletions(-) create mode 100644 db/migrate/20140420231033_add_recurrente_to_action.rb diff --git a/Gemfile.lock b/Gemfile.lock index 741a3c4..54449b2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,36 +1,33 @@ GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.3) - actionpack (= 4.0.3) + actionmailer (4.0.4) + actionpack (= 4.0.4) mail (~> 2.5.4) - actionpack (4.0.3) - activesupport (= 4.0.3) + actionpack (4.0.4) + activesupport (= 4.0.4) builder (~> 3.1.0) erubis (~> 2.7.0) rack (~> 1.5.2) rack-test (~> 0.6.2) - activemodel (4.0.3) - activesupport (= 4.0.3) + activemodel (4.0.4) + activesupport (= 4.0.4) builder (~> 3.1.0) - activerecord (4.0.3) - activemodel (= 4.0.3) + activerecord (4.0.4) + activemodel (= 4.0.4) activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.3) + activesupport (= 4.0.4) arel (~> 4.0.0) activerecord-deprecated_finders (1.0.3) - activesupport (4.0.3) - i18n (~> 0.6, >= 0.6.4) + activesupport (4.0.4) + i18n (~> 0.6, >= 0.6.9) minitest (~> 4.2) multi_json (~> 1.3) thread_safe (~> 0.1) tzinfo (~> 0.3.37) - addressable (2.3.5) + addressable (2.3.6) arel (4.0.2) - atomic (1.1.15) bcrypt (3.1.7) - bcrypt-ruby (3.1.5) - bcrypt (>= 3.1.3) better_errors (1.1.0) coderay (>= 1.0.0) erubis (>= 2.6.6) @@ -59,8 +56,8 @@ GEM execjs coffee-script-source (1.7.0) debug_inspector (0.0.2) - devise (3.2.3) - bcrypt-ruby (~> 3.0) + devise (3.2.4) + bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 3.2.6, < 5) thread_safe (~> 0.1) @@ -73,7 +70,7 @@ GEM factory_girl_rails (4.4.1) factory_girl (~> 4.4.0) railties (>= 3.0.0) - faker (1.2.0) + faker (1.3.0) i18n (~> 0.5) faraday (0.9.0) multipart-post (>= 1.2, < 3) @@ -81,9 +78,9 @@ GEM font-awesome-rails (4.0.3.1) railties (>= 3.2, < 5.0) formatador (0.2.4) - guard (2.5.1) + guard (2.6.0) formatador (>= 0.2.4) - listen (~> 2.6) + listen (~> 2.7) lumberjack (~> 1.0) pry (>= 0.9.12) thor (>= 0.18.1) @@ -101,7 +98,7 @@ GEM activesupport (>= 4.0.1) haml (>= 3.1, < 5.0) railties (>= 4.0.1) - hashie (2.0.5) + hashie (2.1.1) hike (1.2.3) holder_rails (2.3.1) railties (>= 3.1.0) @@ -121,20 +118,20 @@ GEM multi_json libnotify (0.8.0) ffi (>= 1.0.11) - listen (2.6.2) + listen (2.7.1) celluloid (>= 0.15.2) celluloid-io (>= 0.15.0) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) - lumberjack (1.0.4) + lumberjack (1.0.5) mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) method_source (0.8.2) mime-types (1.25.1) - mini_portile (0.5.2) + mini_portile (0.5.3) minitest (4.7.5) - multi_json (1.8.4) + multi_json (1.9.2) multi_xml (0.5.5) multipart-post (2.0.0) nio4r (1.0.0) @@ -152,9 +149,9 @@ GEM rack (~> 1.0) omniauth-facebook (1.6.0) omniauth-oauth2 (~> 1.1) - omniauth-google-oauth2 (0.2.2) + omniauth-google-oauth2 (0.2.3) omniauth (~> 1.0) - omniauth-oauth2 + omniauth-oauth2 (~> 1.1) omniauth-oauth (1.0.1) oauth omniauth (~> 1.0) @@ -178,25 +175,25 @@ GEM rack (1.5.2) rack-test (0.6.2) rack (>= 1.0) - rails (4.0.3) - actionmailer (= 4.0.3) - actionpack (= 4.0.3) - activerecord (= 4.0.3) - activesupport (= 4.0.3) + rails (4.0.4) + actionmailer (= 4.0.4) + actionpack (= 4.0.4) + activerecord (= 4.0.4) + activesupport (= 4.0.4) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.3) + railties (= 4.0.4) sprockets-rails (~> 2.0.0) rails_12factor (0.0.2) rails_serve_static_assets rails_stdout_logging rails_serve_static_assets (0.0.2) rails_stdout_logging (0.0.3) - railties (4.0.3) - actionpack (= 4.0.3) - activesupport (= 4.0.3) + railties (4.0.4) + actionpack (= 4.0.4) + activesupport (= 4.0.4) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (10.1.1) + rake (10.3.1) rb-fsevent (0.9.4) rb-inotify (0.9.3) ffi (>= 0.5.0) @@ -218,7 +215,7 @@ GEM rspec-expectations (~> 2.13.0) rspec-mocks (~> 2.13.0) rubyzip (0.9.9) - sass (3.2.14) + sass (3.3.5) sass-rails (4.0.0) railties (>= 4.0.0.beta, < 5.0) sass (>= 3.1.10) @@ -231,12 +228,12 @@ GEM multi_json (~> 1.0) rubyzip (< 1.0.0) websocket (~> 1.0.4) - slop (3.4.7) + slop (3.5.0) spork (1.0.0rc4) spork-rails (4.0.0) rails (>= 3.0.0, < 5) spork (>= 1.0rc0) - sprockets (2.11.0) + sprockets (2.12.1) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) @@ -246,15 +243,14 @@ GEM activesupport (>= 3.0) sprockets (~> 2.8) sqlite3 (1.3.8) - thor (0.18.1) - thread_safe (0.2.0) - atomic (>= 1.1.7, < 2) + thor (0.19.1) + thread_safe (0.3.3) tilt (1.4.1) timers (1.1.0) treetop (1.4.15) polyglot polyglot (>= 0.3.1) - tzinfo (0.3.38) + tzinfo (0.3.39) uglifier (2.1.1) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) diff --git a/app/models/user.rb b/app/models/user.rb index 4d4a963..865fa3e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -34,11 +34,18 @@ def todo_actions def complete_action!(accion) if !doing_action?(accion).nil? - completada = relationships.find_by(action_id: accion.id) - completada.completed = true - completada.save + if accion.recurrente + completada = relationships.find_by(action_id: accion.id) + completada.completed = false + completada.save + add_points(accion) + else + completada = relationships.find_by(action_id: accion.id) + completada.completed = true + completada.save + add_points(accion) + end - add_points(accion) end end diff --git a/app/views/actions/show.html.haml b/app/views/actions/show.html.haml index 7eb7987..bd0f68c 100644 --- a/app/views/actions/show.html.haml +++ b/app/views/actions/show.html.haml @@ -15,6 +15,20 @@ Descripción de la acción %p = @action.desc + %h3 + ¿En dónde será? + %p + = @action.lugar + %h3 + ¿Cuando? + %p + = @action.fecha + %p + = @action.horario + %h3 + ¿Quién lo propone? + %p + = @action.promotor - if !@action.canjeable && !current_user.nil? %h3 Pasos para completar diff --git a/app/views/shared/_action_submit_form.html.haml b/app/views/shared/_action_submit_form.html.haml index 65b826c..d4845d9 100644 --- a/app/views/shared/_action_submit_form.html.haml +++ b/app/views/shared/_action_submit_form.html.haml @@ -4,14 +4,20 @@ - accion1 = current_user.completed_actions.find { |a| a.action_id == @action.id } - if accion1.nil? %section - = form_tag('/acciones/users') do + = form_tag('/acciones/users') do = render 'shared/error_messages', object: @action + %h3 + Esta acción te dará: + %p + = @action.points + Puntos - if @action.canjeable %h3 Canjea tu código aquí .field %input{:name => "code", type: "text"} - + + %input{:name => "id", type: "hidden", value: @action.id} = submit_tag "Completar" -else @@ -24,4 +30,4 @@ .field %input{:name => "code", type: "text"} %input{:name => "id", type: "hidden", value: @action.id} - = submit_tag "Agregar acción!" \ No newline at end of file + = submit_tag "Agregar acción!" diff --git a/db/migrate/20140420231033_add_recurrente_to_action.rb b/db/migrate/20140420231033_add_recurrente_to_action.rb new file mode 100644 index 0000000..48a1bb4 --- /dev/null +++ b/db/migrate/20140420231033_add_recurrente_to_action.rb @@ -0,0 +1,9 @@ +class AddRecurrenteToAction < ActiveRecord::Migration + def change + add_column :actions, :lugar, :string + add_column :actions, :promotor, :string + add_column :actions, :recurrente, :boolean + add_column :actions, :fecha, :string + add_column :actions, :horario, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index c4784e3..6d1f2ba 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140315001018) do +ActiveRecord::Schema.define(version: 20140420231033) do create_table "actions", force: true do |t| t.string "name" @@ -22,6 +22,11 @@ t.integer "level", default: 1 t.boolean "canjeable", default: false t.string "code" + t.string "lugar" + t.string "promotor" + t.boolean "recurrente" + t.string "fecha" + t.string "horario" end create_table "badge_relationships", force: true do |t| diff --git a/lib/tasks/sample_data.rake b/lib/tasks/sample_data.rake index 4fd9e16..9d4305e 100644 --- a/lib/tasks/sample_data.rake +++ b/lib/tasks/sample_data.rake @@ -15,7 +15,7 @@ namespace :db do email: "jjuanchow@gmail.com", password: "juancar1os", password_confirmation: "juancar1os") - 99.times do |n| + 10.times do |n| first_name = Faker::Name.first_name last_name = Faker::Name.last_name email = "ejemplo-#{n+1}@muevete.org" @@ -45,30 +45,24 @@ namespace :db do Action.create!(name: "Participaste en el Cicloton", desc: "Bien por andar en bicicleta y cuidar más tu cuerpo. ", points: 30, level: 1, canjeable: true, code: 'AAAA-12345') Action.create!(name: "Introduce tu'código de Ecobici", desc: "Ganarás 30 puntos por introducir tu tarjeta de Ecobici.", points: 30, level: 1, canjeable: true, code: 'AAAA-12345') - 10.times do |n| - name = Faker::Lorem.sentence(1) - desc = Faker::Lorem.sentence(20) - points = n + 10 - level = 1 - if n >= 5 && n < 10 - level = 2 - #elsif n >= 20 - # level = 3 - #else - # level = 1 - end - canj = true - code = "AAAA-12345" - if n > 5 - canj = false - end - Action.create!(name: name, - desc: desc, - points: points, - level: level, - canjeable: canj, - code: code) - end + Action.create!(name: "Taller de Lindy Hop (Swing)", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Lunes y Miercoles", horario: "16:00 a 18:00", lugar: "Sub Deportivo, Calzada de Tlalpan esq. Circuito Interior, Rio Churubusco", recurrente: true) + Action.create!(name: "Taller de Skate para Chicas", desc: "She is skate", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Martes y Jueves", horario: "15:00 a 17:00", lugar: "Centro Deportivo y Recreativo Tola, Acueducto de Guadalupe esq Axayacatl col. Santa Isabel Tola. Gusvato A. Madero", recurrente: true) + Action.create!(name: "Taller de Danza Afrobrasileña", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Martes y Jueves", horario: "10:00 a 12:00", lugar: "Sub Deportivo, Calzada de Tlalpan esq. Circuito Interior, Rio Churubusco", recurrente: true) + Action.create!(name: "Taller de Danza Afroamericana", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Martes y Jueves", horario: "10:00 a 12:00", lugar: "Sub Deportivo, Calzada de Tlalpan esq. Circuito Interior, Rio Churubusco", recurrente: true) + Action.create!(name: "Taller de Atletismo y Acondicionamiento Físico", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Sábados y Domingos", horario: "10:00 a 14:00", lugar: "Av. Ing. Eduardo Molina esq. Talismán (camellón)", recurrente: true) + Action.create!(name: "Taller de Atletismo ", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Sábados y Domingos", horario: "11:00 a 13:00", lugar: "Parque viveros de Coyoacán (puerta 1)", recurrente: true) + Action.create!(name: "Taller de Elasticidad ", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Miercoles y Viernes", horario: "16:00 a 18:00", lugar: "Sub Deportivo, Calzada de Tlalpan esq. Circuito Interior, Rio Churubusco", recurrente: true) + Action.create!(name: "Taller de Mi Cuerpo, Mi Sexualidad, Mi Libertad, Mi Responsabilidad", desc: "Aportar las herramientas prácticas en la vida diaria de los participantes respecto a temas de género, sexualidad y diversidad. Se pretende que la persona conozca más sobre sí misma, sobre su cuerpo y su entorno social en función de las necesidades y normas sexuales que le rodean y la toma de decisiones a las que se enfrenta como joven y las decisiones que deberá tomar en tanto ser libre.", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", horario: "17:00 a 19:00", lugar: "Injuve DF, México Tacuba 235, col. Un Hogar para Nosotros, 3er piso", recurrente: true) + Action.create!(name: "Taller de Barras Urbanas ", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Miercoles y Sábado", horario: "10:00 a 12:00", lugar: "Deportivo Santa Cruz Meyehualco, Calle 71 esq. Ermita s/n col Santa Cruz Meyehualco, Delegación Iztapalapa", recurrente: true) + Action.create!(name: "Taller de Lucha Olímpica ", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Lunes y Miercoles", horario: "10:00 a 12:00", lugar: "Sub Deportivo, Calzada de Tlalpan esq. Circuito Interior, Rio Churubusco", recurrente: true) + Action.create!(name: "Taller de Lucha Judo", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Martes y Jueves", horario: "10:00 a 12:00", lugar: "Sub Deportivo, Calzada de Tlalpan esq. Circuito Interior, Rio Churubusco", recurrente: true) + Action.create!(name: "Taller de Danza Clásica", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Lunes y Martes", horario: "14:00 a 16:00", lugar: "Sub Deportivo, Calzada de Tlalpan esq. Circuito Interior, Rio Churubusco", recurrente: true) + Action.create!(name: "Taller de Karate", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Miercoles y Viernes", horario: "10:00 a 12:00", lugar: "Sub Deportivo, Calzada de Tlalpan esq. Circuito Interior, Rio Churubusco", recurrente: true) + Action.create!(name: "Taller de Hula Hula", desc: "Para que te muevas!", points: 10, level: 1, canjeable: true, code: "AAAA-12345", promotor: "INJUVE", fecha: "Martes y Jueves", horario: "12:00 a 14:00", lugar: "Sub Deportivo, Calzada de Tlalpan esq. Circuito Interior, Rio Churubusco", recurrente: true) + + + + end def make_user_actions