Class: AlchemyCrm::ContactsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/alchemy_crm/contacts_controller.rb

Instance Method Summary collapse

Methods included from I18nHelpers

#alchemy_crm_t, #i18n_t, included, #translate_model_attribute

Instance Method Details

#disableObject



70
71
72
73
74
75
76
77
78
79
80
# File 'app/controllers/alchemy_crm/contacts_controller.rb', line 70

def disable
  @contact = Contact.find_by_email_sha1(params[:token])
  if @contact
    @contact_disabled = @contact.disable!
    @page = @element.page
    @root_page = @page.get_language_root
    render :template => 'alchemy/pages/show'
  else
    contact_not_found
  end
end

#showObject



11
12
13
14
15
# File 'app/controllers/alchemy_crm/contacts_controller.rb', line 11

def show
  @page = @element.page
  @root_page = @page.get_language_root
  render :template => 'alchemy/pages/show'
end

#signoutObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/alchemy_crm/contacts_controller.rb', line 53

def signout
  @contact = Contact.find_by_email_and_verified(params[:email], true)
  if @contact.blank?
    flash[:notice] = ::I18n.t(:contact_unknown, :scope => :alchemy_crm)
    @contact_signed_out = false
  else
    ContactsMailer.signout_mail(
      @contact,
      Alchemy::Page.find_by_page_layout_and_language_id('newsletter_mails', session[:language_id])
    ).deliver
    @contact_signed_out = true
  end
  @page = @element.page
  @root_page = @page.get_language_root
  render :template => 'alchemy/pages/show'
end

#signupObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/alchemy_crm/contacts_controller.rb', line 17

def 
  @contact = Contact.new(params[:contact])
  if @contact.save
    ContactsMailer.(
      @contact,
      Alchemy::Page.find_by_page_layout_and_language_id('newsletter_mails', session[:language_id])
    ).deliver
    @contact_signed_up = true
  else
    @contact_signed_up = false
  end
  @page = @element.page
  @root_page = @page.get_language_root
  render :template => 'alchemy/pages/show'
end

#verifyObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/alchemy_crm/contacts_controller.rb', line 33

def verify
  @contact = Contact.find_by_email_sha1(params[:token])
  if @contact
    @contact_verified = @contact.update_attribute(:verified, true)
    if params[:newsletter_ids]
      @subscriptions = @contact.subscriptions.where(:newsletter_id => params[:newsletter_ids])
    else
      @subscriptions = @contact.subscriptions
    end
    @subscriptions.each do |subscription|
      subscription.update_attribute(:verified, true)
    end
    @page = @element.page
    @root_page = @page.get_language_root
    render :template => 'alchemy/pages/show'
  else
    contact_not_found
  end
end