-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from TreinaDev/feat/protege-rotas-premium
Adiciona opção de assinatura e protege rotas pagas
- Loading branch information
Showing
24 changed files
with
396 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,5 @@ | |
} | ||
|
||
.dropdown-item:active { | ||
background-color: #9030df !important; | ||
background-color: #9030df !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class SubscriptionsController < ApplicationController | ||
before_action :authenticate_user! | ||
|
||
def index | ||
@subscription = current_user.subscription | ||
end | ||
|
||
def update | ||
@subscription = Subscription.find params[:id] | ||
@subscription.active! | ||
redirect_to subscriptions_path, notice: t('.success') | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Subscription < ApplicationRecord | ||
belongs_to :user | ||
enum status: { inactive: 0, active: 10 } | ||
|
||
def active! | ||
self.start_date = Time.zone.now.to_date | ||
super | ||
end | ||
|
||
def inactive! | ||
self.start_date = nil | ||
super | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,54 @@ | ||
<h2 class="text-center mb-5"><%= InvitationRequest.model_name.human(count: @invitation_request_infos.length) %></h2> | ||
|
||
<div class="container"> | ||
<div class="row justify-content-center gap-5"> | ||
<%= form_with url: invitation_requests_path, method: :get, class: 'col-10 me-5 px-0' do |f| %> | ||
<div class="d-flex gap-2 col-3"> | ||
<%= f.label :filter, class: 'd-none' %> | ||
<%= f.select :filter, | ||
invitation_request_filter_options, | ||
{ include_blank: 'Todas', selected: params[:filter] }, | ||
class: 'form-select' %> | ||
<%= f.submit t(:filter_btn ), class: 'btn btn-sm btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% if current_user.subscription.inactive? %> | ||
<div class="text-center become-premium-div mt-5"> | ||
<h2 class="become-premium-text"><%= t('subscriptions.become') %> <%= link_to t('subscriptions.subscriber'), subscriptions_path %> <%= t('subscriptions.see_and_request') %></h2> | ||
</div> | ||
<% else %> | ||
<div class="container"> | ||
<div class="row justify-content-center gap-5"> | ||
<%= form_with url: invitation_requests_path, method: :get, class: 'col-10 me-5 px-0' do |f| %> | ||
<div class="d-flex gap-2 col-3"> | ||
<%= f.label :filter, class: 'd-none' %> | ||
<%= f.select :filter, | ||
invitation_request_filter_options, | ||
{ include_blank: 'Todas', selected: params[:filter] }, | ||
class: 'form-select' %> | ||
<%= f.submit t(:filter_btn ), class: 'btn btn-sm btn-primary' %> | ||
</div> | ||
<% end %> | ||
<% if @invitation_request_infos.any? %> | ||
<% @invitation_request_infos.each do |invitation_request| %> | ||
<div class="col-5 rounded border p-3" id="request_<%= invitation_request.id %>"> | ||
<div class="card-body"> | ||
<div class="d-flex flex-column gap-4"> | ||
<div class="d-flex flex-column gap-2"> | ||
<h4 class="text-break text-dark m-0"><%= invitation_request.project_title %></h4> | ||
<div class="d-flex flex-column gap-2 align-items-start"> | ||
<p class="m-0"><%= invitation_request.project_description %></p> | ||
<p class="m-0 fs-sm badge text-bg-secondary"><%= invitation_request.project_category %></p> | ||
<% if @invitation_request_infos.any? %> | ||
<% @invitation_request_infos.each do |invitation_request| %> | ||
<div class="col-5 rounded border p-3" id="request_<%= invitation_request.id %>"> | ||
<div class="card-body"> | ||
<div class="d-flex flex-column gap-4"> | ||
<div class="d-flex flex-column gap-2"> | ||
<h4 class="text-break text-dark m-0"><%= invitation_request.project_title %></h4> | ||
<div class="d-flex flex-column gap-2 align-items-start"> | ||
<p class="m-0"><%= invitation_request.project_description %></p> | ||
<p class="m-0 fs-sm badge text-bg-secondary"><%= invitation_request.project_category %></p> | ||
</div> | ||
</div> | ||
<div class="d-flex justify-content-between align-items-center"> | ||
<p class="m-0 text-muted"> | ||
<%= t(:time_ago, time: time_ago_in_words(invitation_request.created_at)) %> | ||
</p> | ||
<p class="m-0 text-center <%= css_color_class(invitation_request.status.to_sym) %> fw-bold fs-5"> | ||
<%= InvitationRequest.human_attribute_name("status.#{invitation_request.status}") %> | ||
</p> | ||
</div> | ||
</div> | ||
<div class="d-flex justify-content-between align-items-center"> | ||
<p class="m-0 text-muted"> | ||
<%= t(:time_ago, time: time_ago_in_words(invitation_request.created_at)) %> | ||
</p> | ||
<p class="m-0 text-center <%= css_color_class(invitation_request.status.to_sym) %> fw-bold fs-5"> | ||
<%= InvitationRequest.human_attribute_name("status.#{invitation_request.status}") %> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> | ||
<% elsif @error %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:project_api_error) %></h3> | ||
<% elsif params[:filter].nil? || params[:filter].blank? %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:no_invitation_request_msg) %></h3> | ||
<% else %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:no_filter_results_msg) %></h3> | ||
<% end %> | ||
<% elsif @error %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:project_api_error) %></h3> | ||
<% elsif params[:filter].nil? || params[:filter].blank? %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:no_invitation_request_msg) %></h3> | ||
<% else %> | ||
<h3 class="mt-5 alert alert-warning text-center" ><%= t(:no_filter_results_msg) %></h3> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<h2 class="text-center"><%= Subscription.model_name.human %></h2> | ||
|
||
<div class="container justify-items-center text-center mt-5"> | ||
<div class="d-flex row gap-5 justify-content-center"> | ||
<div class="card column col-4 shadow"> | ||
<div id="free-account-div" class="card-body d-flex flex-column justify-content-between"> | ||
<div> | ||
<h3 class="card-title"><%= t('.free_account') %></h3> | ||
|
||
<ul class="list-group"> | ||
<li class="list-group-item"><%= t('.platform_access') %></li> | ||
<li class="list-group-item"><%= t('.searchable_content') %></li> | ||
<li class="list-group-item"><%= t('.hiring_capabilities') %></li> | ||
</ul> | ||
</div> | ||
|
||
<% if current_user.subscription.inactive? %> | ||
<div class="card-footer"> | ||
<h4><%= t('.current_tier') %></h4> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
|
||
<div class="card column col-4 shadow"> | ||
<div id="premium-account-div" class="card-body d-flex flex-column justify-content-between"> | ||
<h3 class="card-title"><%= t('.premium_account') %></h3> | ||
|
||
<ul class="list-group"> | ||
<li class="list-group-item"><%= t('.projects_access') %></li> | ||
<li class="list-group-item"><%= t('.highlight_in_search_results')%></li> | ||
<li class="list-group-item"><%= t('.request_invitation') %></li> | ||
<li class="list-group-item"><%= t('.no_ads') %></li> | ||
</ul> | ||
|
||
<% if current_user.subscription.inactive? %> | ||
<%= button_to t('.subscribe_btn'), subscription_path(current_user.subscription), method: :patch, class: "btn btn-primary btn-lg mt-4" %> | ||
<% else %> | ||
<div class="card-footer"> | ||
<h4><%= t('.current_tier') %></h4> | ||
</div> | ||
<% end %> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.