This repository has been archived by the owner on Jul 30, 2019. It is now read-only.
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 #981 from 18F/jy-admin-auctions-closed
Create closed auctions section for admin
- Loading branch information
Showing
21 changed files
with
200 additions
and
21 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
class Admin::Auctions::ClosedController < Admin::BaseController | ||
def index | ||
@view_model = Admin::ClosedAuctionsViewModel.new | ||
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 |
---|---|---|
|
@@ -3,6 +3,10 @@ def name | |
nil | ||
end | ||
|
||
def github_login | ||
'N/A' | ||
end | ||
|
||
def admin_user_page_link_partial | ||
'components/null' | ||
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 |
---|---|---|
|
@@ -3,6 +3,10 @@ def auctions_nav_class | |
'' | ||
end | ||
|
||
def closed_auctions_nav_class | ||
'' | ||
end | ||
|
||
def vendors_nav_class | ||
'' | ||
end | ||
|
37 changes: 37 additions & 0 deletions
37
app/view_models/admin/closed_auctions_list_item_view_model.rb
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,37 @@ | ||
class Admin::ClosedAuctionsListItemViewModel | ||
attr_reader :auction | ||
|
||
def initialize(auction) | ||
@auction = auction | ||
end | ||
|
||
def title | ||
auction.title | ||
end | ||
|
||
def id | ||
auction.id | ||
end | ||
|
||
def delivery_url | ||
auction.delivery_url | ||
end | ||
|
||
def accepted_at | ||
DcTimePresenter.convert_and_format(auction.accepted_at) | ||
end | ||
|
||
def rejected_at | ||
DcTimePresenter.convert_and_format(auction.rejected_at) | ||
end | ||
|
||
def winning_vendor_github_login | ||
winning_bidder.github_login | ||
end | ||
|
||
private | ||
|
||
def winning_bidder | ||
WinningBid.new(auction).find.bidder || NullBidder.new | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
class Admin::ClosedAuctionsViewModel < Admin::BaseViewModel | ||
def successful_partial | ||
if successfully_delivered.any? | ||
'admin/auctions/closed/successful' | ||
else | ||
'admin/auctions/closed/no_successful' | ||
end | ||
end | ||
|
||
def rejected_partial | ||
if rejected.any? | ||
'admin/auctions/closed/rejected' | ||
else | ||
'admin/auctions/closed/no_rejected' | ||
end | ||
end | ||
|
||
def successfully_delivered | ||
@_successfully_delivered ||= complete_and_successful_auctions.map do |auction| | ||
Admin::ClosedAuctionsListItemViewModel.new(auction) | ||
end | ||
end | ||
|
||
def rejected | ||
@_rejected ||= rejected_auctions.map do |auction| | ||
Admin::ClosedAuctionsListItemViewModel.new(auction) | ||
end | ||
end | ||
|
||
def closed_auctions_nav_class | ||
'usa-current' | ||
end | ||
|
||
private | ||
|
||
def complete_and_successful_auctions | ||
AuctionQuery.new.complete_and_successful | ||
end | ||
|
||
def rejected_auctions | ||
AuctionQuery.new.rejected | ||
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,3 @@ | ||
<div> | ||
No auctions have been rejected yet | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div> | ||
No auctions have been successfully delivered yet | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<table class="usa-table-borderless"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Title</th> | ||
<th scope="col">Vendor</th> | ||
<th scope="col">Delivery URL</th> | ||
<th scope="col">Date rejected</th> | ||
<th scope="col">Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @view_model.rejected.each do |auction| %> | ||
<tr> | ||
<td><%= link_to(auction.title, admin_auction_path(auction.id)) %></td> | ||
<td><%= auction.winning_vendor_github_login %></td> | ||
<td><%= auction.delivery_url %></td> | ||
<td><%= auction.rejected_at %></td> | ||
<td><%= link_to 'edit', edit_admin_auction_path(auction.id) %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
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,22 @@ | ||
<table class="usa-table-borderless"> | ||
<thead> | ||
<tr> | ||
<th scope="col">Title</th> | ||
<th scope="col">Vendor</th> | ||
<th scope="col">Delivery URL</th> | ||
<th scope="col">Date accepted</th> | ||
<th scope="col">Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% @view_model.successfully_delivered.each do |auction| %> | ||
<tr> | ||
<td><%= link_to(auction.title, admin_auction_path(auction.id)) %></td> | ||
<td><%= auction.winning_vendor_github_login %></td> | ||
<td><%= auction.delivery_url %></td> | ||
<td><%= auction.accepted_at %></td> | ||
<td><%= link_to 'edit', edit_admin_auction_path(auction.id) %></td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> |
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,9 @@ | ||
<%= render partial: 'admin/auctions_subnav', locals: { view_model: @view_model } %> | ||
|
||
<h2>Successfully Delivered</h2> | ||
|
||
<%= render partial: @view_model.successful_partial, locals: { view_model: @view_model } %> | ||
|
||
<h2>Rejected Auctions</h2> | ||
|
||
<%= render partial: @view_model.rejected_partial, locals: { view_model: @view_model } %> |
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,22 @@ | ||
Feature: Admin views closed auctions in the admin panel | ||
As an admin of the Micro-purchase system | ||
I want to be able to view successful and rejected closed auctions | ||
|
||
Scenario: Viewing closed successful auctions | ||
Given I am an administrator | ||
And there is a complete and successful auction | ||
And I sign in | ||
When I visit the admin closed auctions page | ||
Then I should see the name of the auction | ||
And I should see the edit link for the auction | ||
And I should see "No auctions have been rejected yet" | ||
|
||
Scenario: Viewing closed rejected auctions | ||
Given I am an administrator | ||
And there is a rejected auction | ||
And I sign in | ||
When I visit the admin closed auctions page | ||
Then I should see the name of the auction | ||
And I should see the edit link for the auction | ||
And I should see "No auctions have been successfully delivered yet" | ||
|
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
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