Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
starting to remove name field
Browse files Browse the repository at this point in the history
  • Loading branch information
citrus committed Apr 22, 2011
1 parent 8c2cb85 commit 39f5ca9
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 12 deletions.
10 changes: 10 additions & 0 deletions app/controllers/subscribers_controller.rb
Expand Up @@ -30,6 +30,16 @@ def unsubscribe
redirect_to subscriber_path(@subscriber)
end
end

def resubscribe
if @subscriber.email == params[:subscriber][:email] && @subscriber.resubscribe!
flash[:notice] = t('resubscribe_success_public')
redirect_to current_user ? account_path : subscriber_path
else
flash[:error] = t('resubscribe_failed_public')
redirect_to resubscribe_subscriber_path(@subscriber)
end
end

private

Expand Down
13 changes: 13 additions & 0 deletions app/controllers/users_controller_decorator.rb
@@ -0,0 +1,13 @@
UsersController.instance_eval do

before_filter :get_subscriber, :only => :show

end

UsersController.class_eval do

def get_subscriber
@subscriber = Subscriber.find_by_email(current_user.email) if current_user
end

end
12 changes: 12 additions & 0 deletions app/views/hooks/_account_summary.html.erb
@@ -0,0 +1,12 @@
<h2><%= t('newsletter') %></h2>
<% if @subscriber && @subscriber.active? %>
<p>
<%= t('newsletter_account') %><br/>
<%= link_to t('unsubscribe'), subscriber_path(@subscriber) %>
</p>
<% elsif @subscriber %>
<p>
<%= t('newsletter_signup') %><br/>
<%= link_to t('resubscribe'), resubscribe_subscriber_path(@subscriber) %>
</p>
<% end %>
10 changes: 6 additions & 4 deletions app/views/hooks/_signup_checkbox.html.erb
@@ -1,4 +1,6 @@
<p>
<%= check_box_tag(:newsletter) %>
<%= label_tag(:newsletter, t(:subscribe_newsletter_too)) %>
</p>
<% if @user && @user.new_record? %>
<p>
<%= check_box_tag(:newsletter) %>
<%= label_tag(:newsletter, t(:subscribe_newsletter_too)) %>
</p>
<% end %>
4 changes: 0 additions & 4 deletions app/views/subscribers/_fields.html.erb
@@ -1,7 +1,3 @@
<p>
<%= form.label :name %><br/>
<%= form.text_field :name, :class => 'title required' %>
</p>
<p>
<%= form.label :email %><br/>
<%= form.email_field :email, :class => 'title required' %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/subscribers/show.html.erb
Expand Up @@ -5,10 +5,10 @@
<%= form_for @subscriber, :url => unsubscribe_subscriber_path(@subscriber.token) do |form| %>
<p>
<%= form.label :email %>
<%= form.text_field :email, :value => "" %>
<%= form.email_field :email, :value => "" %>
</p>
<p>
<%= form.submit t('unsubscribe') %> or
<%= link_to t('cancel'), root_path %>
<%= link_to t('cancel'), :back %>
</p>
<% end %>
2 changes: 2 additions & 0 deletions config/locales/en.yml
Expand Up @@ -2,6 +2,8 @@ en:
spree_mail: Spree Mail
newsletter_sign_up: Sign up for our Newsletter

newsletter: Newsletter

subscribers: Subscribers
listing_subscribers: Listing Subscribers
show_subscriber: Show Subscriber
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -5,6 +5,7 @@

resources :subscribers, :except => [:index,:edit,:update] do
put :unsubscribe, :on => :member
put :resubscribe, :on => :member
end

namespace(:admin) do
Expand Down
2 changes: 2 additions & 0 deletions lib/spree_mail/custom_hooks.rb
@@ -1,6 +1,8 @@
module SpreeMail
class CustomHooks < Spree::ThemeSupport::HookListener

insert_after :account_summary, 'hooks/account_summary'

insert_after :footer_left, 'hooks/footer_left'
insert_after :signup_below_password_fields, 'hooks/signup_checkbox'

Expand Down
2 changes: 0 additions & 2 deletions spree_mail.gemspec
Expand Up @@ -17,8 +17,6 @@ Gem::Specification.new do |s|

s.require_paths = ['lib']

s.has_rdoc = true

s.add_dependency('spree_core', '>= 0.30.1')
s.add_dependency('spree_auth', '>= 0.30.1')
s.add_dependency('mustache', '>= 0.12.0')
Expand Down

0 comments on commit 39f5ca9

Please sign in to comment.