Skip to content

Commit 1e7454f

Browse files
committed
introduce "highlighted" flag for organizations (they will be featured in the organization list)
1 parent 3d103a1 commit 1e7454f

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

app/admin/organization.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
column :posts do |organization|
2424
organization.posts.count
2525
end
26+
column :highlighted
2627
actions
2728
end
2829

@@ -37,6 +38,7 @@
3738

3839
form do |f|
3940
f.inputs do
41+
f.input :highlighted, hint: "Highlighted Time Banks will appear first"
4042
f.input :name
4143
f.input :email
4244
f.input :web
@@ -71,7 +73,8 @@ def destroy
7173
filter :neighborhood
7274
filter :created_at
7375
filter :updated_at
76+
filter :highlighted
7477

7578
permit_params :name, :email, :web, :phone, :city, :neighborhood,
76-
:address, :description, :public_opening_times, :logo
79+
:address, :description, :public_opening_times, :logo, :highlighted
7780
end

app/controllers/organizations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def index
1010

1111
organizations = Organization.where.not(id: @user_organizations&.pluck(:id))
1212
organizations = organizations.search_by_query(params[:q]) if params[:q].present?
13-
@organizations = organizations.page(params[:page]).per(25)
13+
@organizations = organizations.order(highlighted: :desc).page(params[:page]).per(25)
1414
end
1515

1616
def show

app/views/organizations/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</tr>
3232
</thead>
3333
<tbody>
34-
<%= render partial: 'organizations_row', collection: @user_organizations, as: :org if @user_organizations.present? %>
34+
<%= render partial: 'organizations_row', collection: @user_organizations, as: :org if !params[:page] || params[:page] == '1' %>
3535
<%= render partial: 'organizations_row', collection: @organizations, as: :org %>
3636
</tbody>
3737
</table>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddHighlightedToOrganizations < ActiveRecord::Migration[7.0]
2+
def change
3+
add_column :organizations, :highlighted, :boolean, default: false
4+
end
5+
end

db/structure.sql

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ CREATE TABLE public.accounts (
107107
--
108108

109109
CREATE SEQUENCE public.accounts_id_seq
110+
AS integer
110111
START WITH 1
111112
INCREMENT BY 1
112113
NO MINVALUE
@@ -143,6 +144,7 @@ CREATE TABLE public.active_admin_comments (
143144
--
144145

145146
CREATE SEQUENCE public.active_admin_comments_id_seq
147+
AS integer
146148
START WITH 1
147149
INCREMENT BY 1
148150
NO MINVALUE
@@ -286,6 +288,7 @@ CREATE TABLE public.categories (
286288
--
287289

288290
CREATE SEQUENCE public.categories_id_seq
291+
AS integer
289292
START WITH 1
290293
INCREMENT BY 1
291294
NO MINVALUE
@@ -318,6 +321,7 @@ CREATE TABLE public.device_tokens (
318321
--
319322

320323
CREATE SEQUENCE public.device_tokens_id_seq
324+
AS integer
321325
START WITH 1
322326
INCREMENT BY 1
323327
NO MINVALUE
@@ -353,6 +357,7 @@ CREATE TABLE public.documents (
353357
--
354358

355359
CREATE SEQUENCE public.documents_id_seq
360+
AS integer
356361
START WITH 1
357362
INCREMENT BY 1
358363
NO MINVALUE
@@ -387,6 +392,7 @@ CREATE TABLE public.events (
387392
--
388393

389394
CREATE SEQUENCE public.events_id_seq
395+
AS integer
390396
START WITH 1
391397
INCREMENT BY 1
392398
NO MINVALUE
@@ -424,6 +430,7 @@ CREATE TABLE public.members (
424430
--
425431

426432
CREATE SEQUENCE public.members_id_seq
433+
AS integer
427434
START WITH 1
428435
INCREMENT BY 1
429436
NO MINVALUE
@@ -457,6 +464,7 @@ CREATE TABLE public.movements (
457464
--
458465

459466
CREATE SEQUENCE public.movements_id_seq
467+
AS integer
460468
START WITH 1
461469
INCREMENT BY 1
462470
NO MINVALUE
@@ -490,7 +498,8 @@ CREATE TABLE public.organizations (
490498
address text,
491499
neighborhood character varying,
492500
city character varying,
493-
domain character varying
501+
domain character varying,
502+
highlighted boolean DEFAULT false
494503
);
495504

496505

@@ -499,6 +508,7 @@ CREATE TABLE public.organizations (
499508
--
500509

501510
CREATE SEQUENCE public.organizations_id_seq
511+
AS integer
502512
START WITH 1
503513
INCREMENT BY 1
504514
NO MINVALUE
@@ -574,6 +584,7 @@ CREATE TABLE public.posts (
574584
--
575585

576586
CREATE SEQUENCE public.posts_id_seq
587+
AS integer
577588
START WITH 1
578589
INCREMENT BY 1
579590
NO MINVALUE
@@ -610,6 +621,7 @@ CREATE TABLE public.push_notifications (
610621
--
611622

612623
CREATE SEQUENCE public.push_notifications_id_seq
624+
AS integer
613625
START WITH 1
614626
INCREMENT BY 1
615627
NO MINVALUE
@@ -652,6 +664,7 @@ CREATE TABLE public.transfers (
652664
--
653665

654666
CREATE SEQUENCE public.transfers_id_seq
667+
AS integer
655668
START WITH 1
656669
INCREMENT BY 1
657670
NO MINVALUE
@@ -713,6 +726,7 @@ CREATE TABLE public.users (
713726
--
714727

715728
CREATE SEQUENCE public.users_id_seq
729+
AS integer
716730
START WITH 1
717731
INCREMENT BY 1
718732
NO MINVALUE
@@ -1305,7 +1319,7 @@ ALTER TABLE ONLY public.active_storage_attachments
13051319
-- PostgreSQL database dump complete
13061320
--
13071321

1308-
SET search_path TO "$user",public;
1322+
SET search_path TO "$user", public;
13091323

13101324
INSERT INTO "schema_migrations" (version) VALUES
13111325
('1'),
@@ -1377,4 +1391,5 @@ INSERT INTO "schema_migrations" (version) VALUES
13771391
('20230314233504'),
13781392
('20230401114456'),
13791393
('20231120164231'),
1380-
('20231120164346');
1394+
('20231120164346'),
1395+
('20241230170753');

0 commit comments

Comments
 (0)