docbrown/app/views/users/_pro_membership.html.erb
rhymes c8abbe9d60 Pro: memberships (#3461)
* Add ProMembership model

* Implement ProMembershipsController#create

* Implement basic ProMembershipsController#show

* Add ProMembership to ledger

* Populate user history after pro subscription is created

* Add fields for expiration notifications

* Add ProMemberships::ExpirationNotifier to notify users of expiring memberships

* Add tasks for recurring jobs to notify users of expiration

* Add auto_recharge column to ProMembership

* Add ProMemberships::Biller (incomplete)

* Fix specs

* Add ProMembership to Administrate

* Fix spec

* Add has_enough_credits? to User and Organization

* Add Payments::Customer class

* Finish ProMembership::Biller functionality

* Fix ProMemberships::Creator check for credits

* Disable destroy actions for ProMembershipsController

* Correctly authenticate ProMembershipsController actions

* Make sure only pro user's history can be indexed

* Add ProMembershipsController#update action for auto recharge

* Use regular AR to save new credits and add touch to the purchaser

* Clarify Pro membership create policy

* Display information about an existing pro membership

* Add UI to show page

* Add system test for Pro membership creation

* Implement edit membership

* Make sure users with pro memberships can access history and dashboard pro

* Fix padding issue

* Show a different text for a user that has credits but not enough for Pro

* Move Pro Membership functionality inside settings

* Update Pro Membership link in email notifications

* Bust all relevant caches

* Add the Pro checkmark around the website

* Use Users::ResaveArticlesJob instead of delay

* Add/remove user from pro-members chat channel

* Use the appropriate Pro checkmark

* Remove unfinished pro elements

* Remove checkmark JS
2019-09-24 10:38:54 -07:00

66 lines
2.4 KiB
Text

<h3>Pro Membership</h3>
<% if @user.pro? %>
<% if @pro_membership %>
<%= form_for(@pro_membership) do |f| %>
<dl class="membership-status">
<dt>Status</dt>
<dd class="status">
<% if @pro_membership.active? %>
<%= image_tag("checkmark-green.svg", class: "icon-img", alt: "check mark", title: "active", width: 25) %>
<% else %>
<span class="no">expired</span>
<% end %>
</dd>
<dt>Expiration date</dt>
<dd class="expiration-date">
<time datetime="<%= @pro_membership.expires_at.iso8601 %>">
<%= @pro_membership.expires_at.to_date.to_s(:long) %>
</time>
</dd>
<dt>Top up from credit card?</dt>
<dd class="auto-recharge">
<div class="field">
<%= f.check_box :auto_recharge %>
</div>
</dd>
</dl>
<%= f.submit "SUBMIT", class: "cta" %>
<% end %>
<% else %> <!-- existing pro roles without paid membership -->
<dl class="membership-status">
<dt>Status</dt>
<dd class="status">
<%= image_tag("checkmark-green.svg", class: "icon-img", alt: "check mark", title: "active", width: 25) %>
</dd>
<dt>Expiration date</dt>
<dd class="expiration-date">
<em>Never</em>
</dd>
</dl>
<% end %>
<% else %>
<p>
<%= link_to "Pro Membership", pro_membership_path %>
is <strong><%= ProMembership::MONTHLY_COST %></strong> credits per month.
</p>
<% available_credits = @user.credits.unspent.size %>
<% if available_credits >= ProMembership::MONTHLY_COST %>
<p>You currently have <strong><%= available_credits %></strong> available credits.</p>
<%= form_for(ProMembership.new(user: @user)) do |f| %>
<%= f.submit("Become a Pro member", class: "cta") %>
<% end %>
<% elsif available_credits.positive? %>
<p>You currently have <strong>4 credits</strong>, you need <%= ProMembership::MONTHLY_COST %> to become a Pro member.</p>
<a href="<%= purchase_credits_path %>" class="membership-purchase-link">Purchase credits</a>
<% else %>
<p>You currently have <strong>no credits</strong>, you need <%= ProMembership::MONTHLY_COST %> to become a Pro member.</p>
<a href="<%= purchase_credits_path %>" class="membership-purchase-link">Purchase credits</a>
<% end %>
<% end %>
<p>
You can find additional info on the <%= link_to "Pro Membership page", pro_membership_path %>.
</p>