Skip to content

Commit

Permalink
Add estimate on campaign + discord widget (gitcoinco#1335)
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric Berry authored Jun 22, 2020
1 parent fde1460 commit 22a3af3
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .env-example
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ CAMO_KEY=
CAMPAIGN_DEMO_ID=395
CLOUDFRONT_HOST=
CODEFUND_ANALYTICS_KEY=
CRATE_SERVER_ID=
CRATE_CHANNEL_ID=
DATABASE_URL=
DEFAULT_HOST=app.codefund.io
DOCRAPTOR_API_KEY=
Expand Down
14 changes: 14 additions & 0 deletions app/controllers/campaign_estimates_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class CampaignEstimatesController < ApplicationController
before_action :authenticate_administrator!
before_action :set_campaign, only: :show

def show
@campaign_bundle = @campaign.campaign_bundle
end

private

def set_campaign
@campaign = Campaign.find(params[:campaign_id])
end
end
2 changes: 2 additions & 0 deletions app/helpers/campaign_estimates_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module CampaignEstimatesHelper
end
3 changes: 2 additions & 1 deletion app/helpers/campaigns_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ def campaign_tabs(campaign)
{name: "Properties", path: campaign_properties_path(campaign)},
{name: "Countries", path: campaign_countries_path(campaign)},
{name: "Comments", path: campaign_comments_path(campaign), validation: authorized_user.can_view_comments?},
{name: "Settings", path: edit_campaign_path(campaign)}
{name: "Settings", path: edit_campaign_path(campaign)},
{name: "Estimate", path: campaign_estimate_path(campaign), validation: authorized_user.can_admin_system? && campaign.campaign_bundle}
]
end

Expand Down
13 changes: 13 additions & 0 deletions app/views/campaign_estimates/show.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<%= render(PageComponent.new(subject: @campaign, sidebar: true, tabs: TabsComponent.new(tabs: campaign_tabs(@campaign)))) do |component| %>
<% component.with(:header) do %>
<%= render(Page::HeaderComponent.new(title: @campaign.name, sidebar: true, datepicker: true, buttons: [
layout_button(link: {date_range: @campaign.date_range}, icon: "fad fa-calendar-star", title: "Set date range to campaign dates"),
layout_button(link: new_campaign_path(clone: @campaign.id), icon: "fad fa-copy", title: "Clone campaign"),
layout_button(link: campaign_path(@campaign.id, params: {campaign: {status: "paused"}}), method: :put, icon: "fad fa-pause", title: "Pause campaign", display: @campaign.active?),
layout_button(link: campaign_path(@campaign.id, params: {campaign: {status: "active"}}), method: :put, icon: "fad fa-play", title: "Activate campaign", display: @campaign.paused?)
])) %>
<% end %>
<% component.with(:body) do %>
<%= render "/campaign_bundles/campaigns/inventory", campaign: @campaign if @campaign.start_date && @campaign.region_ids.present? && @campaign.audience_ids.present? %>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,6 @@
<!-- Target for dynamically generated modals -->
<div id="global-modal" class="modal fade"></div>
<%= noty_flash %>
<%= render "/widgets/crate" if current_user && ENV["CRATE_SERVER_ID"].present? %>
</body>
</html>
6 changes: 6 additions & 0 deletions app/views/widgets/_crate.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script src="https://cdn.jsdelivr.net/npm/@widgetbot/crate@3" async defer>
new Crate({
server: '<%= ENV["CRATE_SERVER_ID"] %>', // CodeFund
channel: '<%= ENV["CRATE_CHANNEL_ID"] %>' // #general
})
</script>
2 changes: 1 addition & 1 deletion bin/copy_production_db_to_local
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ source .env
export RAILS_ENV=development

bundle exec rails db:drop db:create
#./bin/heroku_pg_dump_production_replica
./bin/heroku_pg_dump_production_replica
pg_restore -U ${PG_USERNAME:-postgres} --verbose --clean --no-acl --no-owner -h ${PG_HOST:-localhost} -p ${PG_PORT:-5432} -d code_fund_ads_development tmp/production-shallow.dump
bundle exec rails db:migrate
./bin/generate_db_artifacts
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
resources :campaign_dailies, only: [:index], path: "/dailies"
resources :campaign_properties, only: [:index, :update], path: "/properties"
resources :campaign_reports, only: [:create], path: "/reports"
resources :campaign_estimates, only: [:show], path: "/estimate"
resources :events, only: [:index], as: :campaign_events
resources :versions, only: [:index], as: :campaign_versions, path: "/revisions"
end
Expand Down

0 comments on commit 22a3af3

Please sign in to comment.