show account status/upgrade button in various places

This commit is contained in:
Skud committed 2013-05-20 12:57:35 +10:00
1 parent d601396741
commit dad64d41fb
6 files changed
+50 -9

No files matched your search

+4
View File
@@ -1,4 +1,8 @@
class AccountType < ActiveRecord::Base
attr_accessible :is_paid, :is_permanent_paid, :name
has_many :products
def to_s
name
end
end
+9 -4
View File
@@ -13,6 +13,7 @@ class Member < ActiveRecord::Base
has_many :authentications
has_many :orders
has_one :account
has_one :account_type, :through => :account
default_scope order("lower(login_name) asc")
scope :confirmed, where('confirmed_at IS NOT NULL')
@@ -113,10 +114,14 @@ class Member < ActiveRecord::Base
end
def is_paid?
if account.account_type.is_permanent_paid
return true
elsif account.account_type.is_paid and account.paid_until >= Time.zone.now
return true
if account.account_type # it might be nil if you've never had one
if account.account_type.is_permanent_paid
return true
elsif account.account_type.is_paid and account.paid_until >= Time.zone.now
return true
else
return false
end
else
return false
end
+8
View File
@@ -27,6 +27,14 @@
= link_to 'Add', new_garden_path, :class => 'btn btn-mini'
.span4
%p
Your account:
%strong
= current_member.account_type || "Free"
account
%br/
- if current_member == current_member && !current_member.is_paid?
= link_to "Upgrade and Support Growstuff", shop_path, :class => 'btn btn-primary'
- if current_member.has_role?(:admin)
%p
%b You are an ADMIN USER.
+12 -4
View File
@@ -15,6 +15,14 @@
%strong Member since:
= @member.created_at.to_s(:date)
%p
%strong Account type:
= @member.account_type || "Free"
account
- if @member == current_member && !@member.is_paid?
= link_to "Upgrade", shop_path, :class => 'btn btn-primary btn-mini'
- if @twitter_auth || @flickr_auth || @member.show_email
%h4 Contact
@@ -42,12 +50,12 @@
= @member.location
%br/
= link_to 'Find members near here', nearby_members_path(:location => @member.location)
%p
- if current_member == @member
%p
= link_to 'Edit Settings', "edit", :class => 'btn btn-mini'
.span9
%p
- if can? :update, @member
%p
= link_to 'Edit your profile', "edit", :class => 'btn btn-primary'
.tabbable
%ul.nav.nav-tabs
- first_garden = true
+8
View File
@@ -74,6 +74,14 @@ describe 'home/index.html.haml', :type => "view" do
assert_select "a[href=#{url_for(@post)}]"
end
it 'shows account type' do
rendered.should contain "Free account"
end
it 'shows upgrade account button' do
rendered.should contain "Upgrade"
end
it 'shows admin status' do
rendered.should contain "You are an ADMIN USER"
end
+9 -1
View File
@@ -18,6 +18,10 @@ describe "members/show" do
rendered.should contain @time.strftime("%B %d, %Y")
end
it "shows account type" do
rendered.should contain "Free account"
end
it "contains a gravatar icon" do
assert_select "img", :src => /gravatar\.com\/avatar/
end
@@ -106,7 +110,11 @@ describe "members/show" do
end
it "contains an edit settings button" do
rendered.should contain "Edit Settings"
rendered.should contain "Edit your profile"
end
it "asks you to upgrade your account" do
rendered.should contain "Upgrade"
end
it "contains no send message button" do