Skip to content
This repository was archived by the owner on Apr 3, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,7 @@ You should be ready to go.
Start the app by running:

$ powder up

Stop powder:

$ powder down
51 changes: 51 additions & 0 deletions app/controllers/admin/sponsors_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
class Admin::SponsorsController < AdminController

before_action :find_sponsor, only: [:show, :edit, :update]

def index
@sponsors = Sponsor.all
end

def show
end

def new
@sponsor = Sponsor.new
end

def create
@sponsor = Sponsor.new(sponsor_params)
if @sponsor.save
flash[:success] = "Patrocinador registrado con éxito."
redirect_to admin_sponsors_path
else
flash[:error] = "No se pudo registrar patrocinador: #{@sponsor.humanized_errors}"
render :new
end
end

def edit
end

def update
respond_to do |format|
if @sponsor.update(sponsor_params)
format.html { redirect_to admin_sponsors_path, notice: 'Patrocinador actualizado con éxito.' }
format.json { render :index, status: :ok, location: @sponsor }
else
format.html { render :edit, error: "No se pudo actualizar patrocinador: #{@sponsor.humanized_errors}" }
format.json { render json: @sponsor.errors, status: :unprocessable_entity }
end
end
end

private

def sponsor_params
params.require(:sponsor).permit :name, :website, :twitter, :image, :active
end

def find_sponsor
@sponsor = Sponsor.find(params[:id])
end
end
1 change: 1 addition & 0 deletions app/controllers/app/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class App::HomeController < AppController
def show
@event = Event.includes({ talks: :speaker }, :venue).current
@talks = @event.talks.accepted
@sponsors = Sponsor.active_sponsors
end

end
69 changes: 2 additions & 67 deletions app/models/sponsor.rb
Original file line number Diff line number Diff line change
@@ -1,68 +1,3 @@
class Sponsor

def self.all
[
#{
#name: 'Cocoworking',
#website: 'https://www.facebook.com/CoCoWorkingMx',
#twitter: 'elcocoworking',
#image: 'sponsors/cocoworking.jpg'
#},
#{
#name: 'Don chambitas',
#website: 'http://www.donchambitas.com',
#twitter: 'DonChambitas',
#image: 'sponsors/chambitas.jpg'
#},
{
name: 'densitylabs',
website:'https://twitter.com/densitylabs',
twitter: 'densitylabs',
image: 'sponsors/densitylabs.jpg'
},
# {
# name: 'easybroker',
# website: "https://www.easybroker.com",
# twitter: 'EasyBroker',
# image: 'sponsors/eb.jpg'
# },
#{
#name: 'vauxoo',
#website: "https://www.vauxoo.com",
#twitter: 'vauxoo',
#image: 'sponsors/vauxoo.png'
#},
{
name: 'magmalabs',
website: "http://www.magmalabs.io",
twitter: 'weareMagmaLabs',
image: 'sponsors/magmalabs.png'
},
{
name: 'micheladaio',
website: 'http://michelada.io',
twitter: 'micheladaio',
image: 'sponsors/micheladaio.png'
},
#{
#name: 'netmask',
#website: "http://devmask.net/",
#twitter: 'netmask',
#image: 'sponsors/netmask.jpg'
#},
{
name: 'Tango.io',
website: 'http://tango.io',
twitter: 'tangosource',
image: 'sponsors/tangoio.svg'
}
# {
# name: 'The Office',
# website: "http://theofficecowork.com/",
# twitter: 'TheOfficeCowork',
# image: 'sponsors/theoffice.jpg'
# }
]
end

class Sponsor < ActiveRecord::Base
scope :active_sponsors, -> { where(active: true).shuffle }
end
25 changes: 25 additions & 0 deletions app/views/admin/sponsors/_form.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
= form_for [:admin, sponsor], html: { class: "form-horizontal" } do |f|

.form-group
= f.label :name, "Nombre", class: "col-md-2"
.col-md-8
= f.text_field :name, class: "form-control"

.form-group
= f.label :website, "Website", class: "col-md-2"
.col-md-8
= f.text_field :website, class: "form-control"

.form-group
= f.label :twitter, "Twitter", class: "col-md-2"
.col-md-8
= f.text_field :twitter, class: "form-control"

.form-group
= f.label :image, "Image", class: "col-md-2"
.col-md-8
= f.text_field :image, class: "form-control"

.form-group
.col-md-offset-2.col-md-2
= f.submit "#{sponsor.new_record? ? "Crear" : "Guardar"} patrocinador", class: "btn btn-primary"
14 changes: 14 additions & 0 deletions app/views/admin/sponsors/_sponsor.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
tr
td= sponsor.name
td= sponsor.website
td= sponsor.twitter
td
- if sponsor.active
= link_to admin_sponsor_path(sponsor, sponsor: { active: false} ), method: :patch do
i.glyphicon.glyphicon-remove
- else
= link_to admin_sponsor_path(sponsor, sponsor: { active: true} ), method: :patch do
i.glyphicon.glyphicon-ok
td
= link_to edit_admin_sponsor_path(sponsor) do
i.glyphicon.glyphicon-edit
5 changes: 5 additions & 0 deletions app/views/admin/sponsors/edit.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.row
.col-md-6
h2 Editar patrocinador

= render partial: 'form', locals: { sponsor: @sponsor }
14 changes: 14 additions & 0 deletions app/views/admin/sponsors/index.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
h2 Ponentes

table.table.table-hover.table-stripped
thead
tr
th Nombre
th Website
th Twitter
th Active

tbody
= render @sponsors

= link_to 'Nuevo patrocinador', new_admin_sponsor_path, class: 'btn btn-default'
5 changes: 5 additions & 0 deletions app/views/admin/sponsors/new.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.row
.col-md-6
h2 Nuevo patrocinador

= render partial: 'form', locals: { sponsor: @sponsor }
14 changes: 14 additions & 0 deletions app/views/admin/sponsors/show.html.slim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
h2= @sponsor.name

.row
.col-sm-3.col-md-3
.thumbnail
img src=@sponsor.image

.col-sm-4.col-md-4
h3= link_to "https://twitter.com/#{@sponsor.twitter}" do
i.fa.fa-twitter
= " #{@sponsor.twitter}"
h4= link_to "mailto:#{@sponsor.website}" do
i.fa.fa-envelope-o
= " #{@sponsor.website}"
2 changes: 1 addition & 1 deletion app/views/app/home/_sponsors.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
h2 Patrocinadores
div
ul.small-block-grid-1.medium-block-grid-2.large-block-grid-4
- Sponsor.all.shuffle.each do |sponsor|
- sponsors.each do |sponsor|
li
= link_to sponsor[:website], target: '_blank' do
= image_tag sponsor[:image], height: 85, width: 200
2 changes: 1 addition & 1 deletion app/views/app/home/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
= render partial: 'speakers', locals: { event: @event, talks: @talks }
= render partial: 'venue', locals: { venue: @event.venue }

= render 'sponsors'
= render partial: 'sponsors', locals: { sponsors: @sponsors }
= render 'about'

/= render 'schedule'
Expand Down
1 change: 1 addition & 0 deletions app/views/layouts/admin.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ html lang='es'
li= link_to 'Lugares', admin_venues_path
li= link_to 'Ponentes', admin_speakers_path
li= link_to 'Ubicaciones', admin_locations_path
li= link_to 'Patrocinadores', admin_sponsors_path

ul.nav.navbar-nav.pull-right
li.dropdown
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
resources :speakers
resources :talks
resources :venues

resources :sponsors
end

scope module: :app do
Expand Down
12 changes: 12 additions & 0 deletions db/migrate/20160727065507_create_sponsors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class CreateSponsors < ActiveRecord::Migration
def change
create_table :sponsors do |t|
t.string :name
t.string :website
t.string :twitter
t.string :image

t.timestamps null: false
end
end
end
5 changes: 5 additions & 0 deletions db/migrate/20160727065713_add_active_to_sponsors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddActiveToSponsors < ActiveRecord::Migration
def change
add_column :sponsors, :active, :boolean
end
end
6 changes: 6 additions & 0 deletions db/migrate/20160727072144_add_not_null_to_active.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddNotNullToActive < ActiveRecord::Migration
def change
Sponsor.update_all(active: false)
change_column :sponsors, :active, :boolean, null: false, default: false
end
end
12 changes: 11 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160426171806) do
ActiveRecord::Schema.define(version: 20160727072144) do

# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
Expand Down Expand Up @@ -56,6 +56,16 @@
t.datetime "updated_at"
end

create_table "sponsors", force: :cascade do |t|
t.string "name"
t.string "website"
t.string "twitter"
t.string "image"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "active", default: false, null: false
end

create_table "talks", force: :cascade do |t|
t.string "title"
t.string "description"
Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/admin/sponsors_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'rails_helper'

describe Admin::SponsorsController do
pending
end
6 changes: 6 additions & 0 deletions spec/fabricators/sponsor_fabricator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Fabricator(:sponsor) do
name "MyString"
website "MyString"
twitter "MyString"
image "MyString"
end
4 changes: 2 additions & 2 deletions spec/models/sponsor_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rails_helper'

describe Sponsor do
pending
RSpec.describe Sponsor, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
end