Add paid_at date to donations
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		
							parent
							
								
									2f70bae523
								
							
						
					
					
						commit
						5e2d5c3b28
					
				| @ -69,6 +69,6 @@ class Admin::DonationsController < Admin::BaseController | ||||
| 
 | ||||
|     # Only allow a list of trusted parameters through. | ||||
|     def donation_params | ||||
|       params.require(:donation).permit(:user_id, :amount_sats, :amount_eur, :amount_usd, :public_name) | ||||
|       params.require(:donation).permit(:user_id, :amount_sats, :amount_eur, :amount_usd, :public_name, :paid_at) | ||||
|     end | ||||
| end | ||||
|  | ||||
| @ -4,6 +4,6 @@ class DonationsController < ApplicationController | ||||
|   # GET /donations | ||||
|   # GET /donations.json | ||||
|   def index | ||||
|     @donations = current_user.donations | ||||
|     @donations = current_user.donations.completed | ||||
|   end | ||||
| end | ||||
|  | ||||
| @ -7,4 +7,7 @@ class Donation < ApplicationRecord | ||||
| 
 | ||||
|   # Hooks | ||||
|   # TODO before_create :store_fiat_value | ||||
| 
 | ||||
|   #Scopes | ||||
|   scope :completed, -> { where.not(paid_at: nil) } | ||||
| end | ||||
|  | ||||
| @ -45,6 +45,13 @@ | ||||
|     </p> | ||||
|   </div> | ||||
| 
 | ||||
|   <div class="field"> | ||||
|     <p> | ||||
|       <%= form.label :paid_at %> | ||||
|       <%= form.text_field :paid_at %> | ||||
|     </p> | ||||
|   </div> | ||||
| 
 | ||||
|   <div class="actions"> | ||||
|     <p> | ||||
|       <%= form.submit %> | ||||
|  | ||||
| @ -9,6 +9,7 @@ | ||||
|         <th>in EUR</th> | ||||
|         <th>in USD</th> | ||||
|         <th>Public name</th> | ||||
|         <th>Date</th> | ||||
|         <th colspan="3"></th> | ||||
|       </tr> | ||||
|     </thead> | ||||
| @ -21,6 +22,7 @@ | ||||
|           <td><%= donation.amount_eur %></td> | ||||
|           <td><%= donation.amount_usd %></td> | ||||
|           <td><%= donation.public_name %></td> | ||||
|           <td><%= donation.paid_at ? donation.paid_at.strftime("%Y-%m-%d") : "" %></td> | ||||
|           <td><%= link_to 'Show', admin_donation_path(donation) %></td> | ||||
|           <td><%= link_to 'Edit', edit_admin_donation_path(donation) %></td> | ||||
|           <td><%= link_to 'Destroy', admin_donation_path(donation), method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||||
|  | ||||
| @ -25,5 +25,10 @@ | ||||
|   <%= @donation.public_name %> | ||||
| </p> | ||||
| 
 | ||||
| <p> | ||||
|   <strong>Date:</strong> | ||||
|   <%= @donation.paid_at %> | ||||
| </p> | ||||
| 
 | ||||
| <%= link_to 'Edit', edit_admin_donation_path(@donation) %> | | ||||
| <%= link_to 'Back', admin_donations_path %> | ||||
|  | ||||
| @ -12,7 +12,7 @@ | ||||
|       <% @donations.each do |donation| %> | ||||
|         <li> | ||||
|           <h3> | ||||
|             <%= donation.created_at.strftime("%B %d, %Y") %> | ||||
|             <%= donation.paid_at.strftime("%B %d, %Y") %> | ||||
|           </h3> | ||||
|           <p class="amount-btc"> | ||||
|             <%= sats_to_btc donation.amount_sats %> BTC | ||||
|  | ||||
							
								
								
									
										5
									
								
								db/migrate/20201219121808_add_paid_at_to_donations.rb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								db/migrate/20201219121808_add_paid_at_to_donations.rb
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| class AddPaidAtToDonations < ActiveRecord::Migration[6.0] | ||||
|   def change | ||||
|     add_column :donations, :paid_at, :datetime | ||||
|   end | ||||
| end | ||||
| @ -10,7 +10,7 @@ | ||||
| # | ||||
| # It's strongly recommended that you check this file into your version control system. | ||||
| 
 | ||||
| ActiveRecord::Schema.define(version: 2020_12_17_161544) do | ||||
| ActiveRecord::Schema.define(version: 2020_12_19_121808) do | ||||
| 
 | ||||
|   create_table "donations", force: :cascade do |t| | ||||
|     t.integer "user_id" | ||||
| @ -20,6 +20,7 @@ ActiveRecord::Schema.define(version: 2020_12_17_161544) do | ||||
|     t.string "public_name" | ||||
|     t.datetime "created_at", precision: 6, null: false | ||||
|     t.datetime "updated_at", precision: 6, null: false | ||||
|     t.datetime "paid_at" | ||||
|     t.index ["user_id"], name: "index_donations_on_user_id" | ||||
|   end | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user