Skip to content

Commit 43a41cd

Browse files
Sarvesh-MkYodaLightsabrsampoder
authored
[Documents] Can now categorize documents when uploading (#11065)
Co-authored-by: yodalightsabr <[email protected]> Co-authored-by: Sam Poder <[email protected]> Co-authored-by: Sam Poder <[email protected]>
1 parent c81cc87 commit 43a41cd

File tree

7 files changed

+54
-15
lines changed

7 files changed

+54
-15
lines changed

app/controllers/documents_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def verification_letter
129129
private
130130

131131
def document_params
132-
params.require(:document).permit(:event_id, :name, :file)
132+
params.require(:document).permit(:event_id, :name, :file, :category)
133133
end
134134

135135
def set_document

app/models/document.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# id :bigint not null, primary key
88
# aasm_state :string
99
# archived_at :datetime
10+
# category :integer default("general"), not null
1011
# deleted_at :datetime
1112
# name :text
1213
# slug :text
@@ -48,6 +49,13 @@ class Document < ApplicationRecord
4849

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

52+
enum :category, {
53+
general: 0,
54+
nonprofit_status: 1,
55+
tax_exemption: 2,
56+
forms: 3
57+
}
58+
5159
aasm timestamps: true do
5260
state :active, initial: true
5361
state :archived, before_exit: -> do

app/views/documents/_document.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<%= link_to auditor_signed_in? ? document : document_download_path(document) do %>
2-
<li class="card card--hover h-100">
2+
<li class="card card--hover h-100 w-fit">
33
<div class="overflow-hidden" style="max-height: 270px;">
44
<%= render "documents/preview", document: %>
55
</div>

app/views/documents/_form.html.erb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
<%= form.text_field :name, required: true, data: { target: "new-document.name" } %>
1515
</div>
1616

17+
<div class="field">
18+
<%= form.label :category %>
19+
<%= form.select :category, options_for_select(Document.categories.keys.map { |k| [k.humanize, k] }, form.object.category), { include_blank: "Select a category" }, required: false %>
20+
</div>
21+
1722
<div class="actions">
1823
<%= form.submit %>
1924
</div>

app/views/documents/index.html.erb

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,36 @@
2121
<% end %>
2222

2323
<ul class="grid">
24-
<%= render partial: "document", collection: @active_documents %>
25-
<%= render partial: "document", collection: @active_common_documents %>
24+
<div class="grid-row text">
25+
<h3>General documents</h3>
26+
<div class="grid grid-cols-3 gap-4">
27+
<%= render partial: "document", collection: @active_common_documents.general %>
28+
<%= link_to event_fiscal_sponsorship_letter_path(event_id: @event.slug, format: "pdf") do %>
29+
<li class="card card--hover h-100 w-fit">
30+
<div class="overflow-hidden" style="max-height: 250px;">
31+
<%= image_tag event_fiscal_sponsorship_letter_url(event_id: @event.slug, format: "png"), width: 330, style: "max-width: 100%;" %>
32+
</div>
33+
<strong class="h3 block mt1 line-height-2">Fiscal Sponsorship Confirmation</strong>
34+
<%= user_mention @event.point_of_contact %>
35+
</li>
36+
<% end %>
37+
</div>
38+
39+
<h3>Nonprofit status</h3>
40+
<div class="grid grid-cols-3 gap-4">
41+
<%= render partial: "document", collection: @active_common_documents.nonprofit_status %>
42+
</div>
43+
44+
<h3>Tax-exemption documents</h3>
45+
<div class="grid grid-cols-3 gap-4">
46+
<%= render partial: "document", collection: @active_common_documents.tax_exemption %>
47+
</div>
48+
49+
<h3>Forms</h3>
50+
<div class="grid grid-cols-3 gap-4">
51+
<%= render partial: "document", collection: @active_common_documents.forms %>
52+
</div>
53+
</div>
2654

2755
<% if @event.approved? && !@event.demo_mode? %>
2856
<%= link_to event_verification_letter_path(event_id: @event.slug, format: "pdf") do %>
@@ -35,17 +63,6 @@
3563
<%= user_mention @event.point_of_contact %>
3664
</li>
3765
<% end if @event.account_number %>
38-
39-
<%= link_to event_fiscal_sponsorship_letter_path(event_id: @event.slug, format: "pdf") do %>
40-
<li class="card card--hover h-100">
41-
<div class="overflow-hidden" style="max-height: 250px;">
42-
<%= image_tag event_fiscal_sponsorship_letter_url(event_id: @event.slug, format: "png"), width: 330, style: "max-width: 100%;" %>
43-
</div>
44-
45-
<strong class="h3 block mt1 line-height-2">Fiscal Sponsorship Confirmation</strong>
46-
<%= user_mention @event.point_of_contact %>
47-
</li>
48-
<% end %>
4966
<% end %>
5067
</ul>
5168

app/views/documents/show.html.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
<strong>Added by</strong> <%= user_mention @document.user %>
4141
</p>
4242

43+
<p>
44+
<strong>Category</strong> <%= @document.category.humanize %>
45+
</p>
46+
4347
</section>
4448

4549
<% if @downloads.any? %>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddCategoryToDocuments < ActiveRecord::Migration[7.2]
2+
def change
3+
add_column :documents, :category, :integer, default: 0, null: false
4+
end
5+
end

0 commit comments

Comments
 (0)