Skip to content

Commit

Permalink
Merge branch 'prompt-meetup-connect' of https://github.com/fionatay/b…
Browse files Browse the repository at this point in the history
…ridge_troll into fionatay-prompt-meetup-connect

Conflicts:
	db/schema.rb
  • Loading branch information
tjgrathwell committed May 6, 2013
2 parents 143c4d1 + bbf6a24 commit 1bf9aef
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 32 deletions.
4 changes: 4 additions & 0 deletions app/assets/javascripts/alerts.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
$(document).ready ->
$(".alert form.button_to").bind "ajax:success", (event, data, status, xhr) ->
$(event.target).closest(".alert").remove()

22 changes: 11 additions & 11 deletions app/assets/stylesheets/_base.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@ textarea {
width: 500px;
}

a {
color: #22444D;
}

.field {
margin-bottom: 20px;
}
Expand Down Expand Up @@ -180,17 +176,21 @@ td.wide {
width: auto; display:inline;
}

.meetup-association {
border: 3px solid rgb(80, 80, 97);
.alert-action-needed {
border-color: rgb(80, 80, 97);
background-color: rgb(200, 200, 200);
width: 500px;
margin: 0 auto;
text-align: center;
padding: 15px;
border-radius: 10px;
color: rgb(51, 51, 51);
text-shadow: none;
}

// BOOTSTRAP OVERRIDES, Yo. Frowny buckets.
.alert .button_to {
float: right;
}

.alert .close {
border:none;
}

.container::before,
.container::after { display: block; }
9 changes: 9 additions & 0 deletions app/controllers/users/meetup_prompts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module Users
class MeetupPromptsController < ApplicationController
def destroy
@meetup_prompt = MeetupPrompt.build(current_user)
@meetup_prompt.destroy if @meetup_prompt
head :ok
end
end
end
20 changes: 20 additions & 0 deletions app/models/meetup_prompt.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class MeetupPrompt
def self.build(user)
return if !user || user.meetup_id || user.meetup_prompt_dismissed

new(user)
end

def initialize(user)
@user = user
end

def path
"/users/#{@user.id}/meetup_prompt"
end

def destroy
@user.meetup_prompt_dismissed = true
@user.save
end
end
28 changes: 14 additions & 14 deletions app/views/devise/registrations/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
<h1>Edit <%= resource_name.to_s.humanize %></h1>

<div class='meetup-association'>

<% if resource.meetup_id.present? %>
<p>This account is associated with <%= link_to "meetup user #{resource.meetup_id}.", "http://www.meetup.com/members/#{resource.meetup_id}/" %></p>
<% else %>
<p>This account is not associated with a SFRuby Meetup account.</p>

<p>If you associate with your meetup account, Bridgetroll can show you information about past workshops you have attended.</p>
<%= link_to 'Associate with Meetup account', "/auth/meetup", class: 'btn' %>
<% end %>
</div>

<%= render 'shared/profile_gravatars'%>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
Expand Down Expand Up @@ -55,11 +43,23 @@
</div>

<div><%= f.submit "Update" %></div>

<hr>
<div>
<%= label_tag :meetup_id, 'Associated Meetup Account' %>
<% if resource.meetup_id %>
Currently associated
with <%= link_to "Meetup user #{resource.meetup_id}.", "https://www.meetup.com/members/#{resource.meetup_id}/" %></p>
<% else %>
<p>You haven't connected your Meetup.com account yet! :(</p>
<p>Connect your Meetup.com account to import information about past workshops you have attended.</p>
<%= link_to 'Connect to Meetup.com', "/auth/meetup", class: 'btn' %>
<% end %>
</div>
<% end %>

<h3>Cancel my account</h3>

<p>Unhappy? <%= link_to "Cancel my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %>.</p>
<p><%= link_to "Delete my account", registration_path(resource_name), :confirm => "Are you sure?", :method => :delete %></p>

<%= link_to "Back", :back %>

Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
<%= msg %>
</div>
<% end %>
<%= render partial: 'users/meetup_prompt' %>
<%= yield %>
<%= yield :scripts %>
</div>
Expand Down
8 changes: 8 additions & 0 deletions app/views/users/_meetup_prompt.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% meetup_prompt = MeetupPrompt.build(current_user) %>
<% if meetup_prompt %>
<div class="alert alert-action-needed">
<%= button_to '&times;'.html_safe, meetup_prompt.path, remote: true, method: :delete, class: 'close', data: {dismiss: 'alert'} %>
Connect your Meetup.com account to import information about past workshops you have attended.
<%= link_to 'Connect to Meetup.com', "/auth/meetup", class: 'btn' %>
</div>
<% end %>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

resources :users, only: [:index] do
resource :profile, :only => [:edit, :update, :show]
resource :meetup_prompt, :only => [:destroy], :controller => 'users/meetup_prompts'
end
resources :meetup_users, :only => [:show]

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMeetupPromptDismissedToUsers < ActiveRecord::Migration
def change
add_column :users, :meetup_prompt_dismissed, :boolean
end
end
13 changes: 7 additions & 6 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,26 +109,27 @@
add_index "rsvps", ["user_id", "event_id", "user_type"], :name => "index_rsvps_on_user_id_and_event_id_and_event_type", :unique => true

create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.string "confirmation_token"
t.datetime "confirmed_at"
t.datetime "confirmation_sent_at"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "admin", :default => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.boolean "admin", :default => false
t.string "first_name"
t.string "last_name"
t.integer "meetup_id"
t.string "time_zone"
t.boolean "meetup_prompt_dismissed"
end

add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/users_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe UsersController do
before do
sign_in_stub double('user', id: 1234)
sign_in_stub double('user', id: 1234, meetup_id: 1)
end

describe "index" do
Expand Down
9 changes: 9 additions & 0 deletions spec/features/homepage_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,14 @@
page.should_not have_link("Sign Up")
page.should have_link("Profile")
end

it 'is prompted to connect their meetup account' do
visit '/'
within '.alert' do
page.should have_link 'Connect to Meetup.com'
click_button '×'
end
page.should_not have_link 'Connect to Meetup.com'
end
end
end

0 comments on commit 1bf9aef

Please sign in to comment.