Skip to content
2 changes: 1 addition & 1 deletion app/controllers/documents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def verification_letter
private

def document_params
params.require(:document).permit(:event_id, :name, :file)
params.require(:document).permit(:event_id, :name, :file, :category)
end

def set_document
Expand Down
8 changes: 8 additions & 0 deletions app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# id :bigint not null, primary key
# aasm_state :string
# archived_at :datetime
# category :integer default("general"), not null
# deleted_at :datetime
# name :text
# slug :text
Expand Down Expand Up @@ -48,6 +49,13 @@ class Document < ApplicationRecord

scope :common, -> { where(event_id: nil) }

enum :category, {
general: 0,
nonprofit_status: 1,
tax_exemption: 2,
forms: 3
}

aasm timestamps: true do
state :active, initial: true
state :archived, before_exit: -> do
Expand Down
2 changes: 1 addition & 1 deletion app/views/documents/_document.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= link_to auditor_signed_in? ? document : document_download_path(document) do %>
<li class="card card--hover h-100">
<li class="card card--hover h-100 w-fit">
<div class="overflow-hidden" style="max-height: 270px;">
<%= render "documents/preview", document: %>
</div>
Expand Down
5 changes: 5 additions & 0 deletions app/views/documents/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
<%= form.text_field :name, required: true, data: { target: "new-document.name" } %>
</div>

<div class="field">
<%= form.label :category %>
<%= form.select :category, options_for_select(Document.categories.keys.map { |k| [k.humanize, k] }, form.object.category), { include_blank: "Select a category" }, required: false %>
</div>

<div class="actions">
<%= form.submit %>
</div>
Expand Down
43 changes: 30 additions & 13 deletions app/views/documents/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,36 @@
<% end %>

<ul class="grid">
<%= render partial: "document", collection: @active_documents %>
<%= render partial: "document", collection: @active_common_documents %>
<div class="grid-row text">
<h3>General documents</h3>
<div class="grid grid-cols-3 gap-4">
<%= render partial: "document", collection: @active_common_documents.general %>
<%= link_to event_fiscal_sponsorship_letter_path(event_id: @event.slug, format: "pdf") do %>
<li class="card card--hover h-100 w-fit">
<div class="overflow-hidden" style="max-height: 250px;">
<%= image_tag event_fiscal_sponsorship_letter_url(event_id: @event.slug, format: "png"), width: 330, style: "max-width: 100%;" %>
</div>
<strong class="h3 block mt1 line-height-2">Fiscal Sponsorship Confirmation</strong>
<%= user_mention @event.point_of_contact %>
</li>
<% end %>
</div>

<h3>Nonprofit status</h3>
<div class="grid grid-cols-3 gap-4">
<%= render partial: "document", collection: @active_common_documents.nonprofit_status %>
</div>

<h3>Tax-exemption documents</h3>
<div class="grid grid-cols-3 gap-4">
<%= render partial: "document", collection: @active_common_documents.tax_exemption %>
</div>

<h3>Forms</h3>
<div class="grid grid-cols-3 gap-4">
<%= render partial: "document", collection: @active_common_documents.forms %>
</div>
</div>

<% if @event.approved? && [email protected]_mode? %>
<%= link_to event_verification_letter_path(event_id: @event.slug, format: "pdf") do %>
Expand All @@ -35,17 +63,6 @@
<%= user_mention @event.point_of_contact %>
</li>
<% end if @event.account_number %>

<%= link_to event_fiscal_sponsorship_letter_path(event_id: @event.slug, format: "pdf") do %>
<li class="card card--hover h-100">
<div class="overflow-hidden" style="max-height: 250px;">
<%= image_tag event_fiscal_sponsorship_letter_url(event_id: @event.slug, format: "png"), width: 330, style: "max-width: 100%;" %>
</div>

<strong class="h3 block mt1 line-height-2">Fiscal Sponsorship Confirmation</strong>
<%= user_mention @event.point_of_contact %>
</li>
<% end %>
<% end %>
</ul>

Expand Down
4 changes: 4 additions & 0 deletions app/views/documents/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
<strong>Added by</strong> <%= user_mention @document.user %>
</p>

<p>
<strong>Category</strong> <%= @document.category.humanize %>
</p>

</section>

<% if @downloads.any? %>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20250721015626_add_category_to_documents.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddCategoryToDocuments < ActiveRecord::Migration[7.2]
def change
add_column :documents, :category, :integer, default: 0, null: false
end
end
Loading