<%= render "statistics", :presenter => @presenter, :user => @user %>
+ <% if @presenter.show_staff_notes? %>
+
+
+
+
+ Staff Notes (<%= @presenter.staff_notes.count %>)
+
+
+
<%= link_to "Staff Notes", user_staff_notes_path(user_id: @user.id) %>
+ <%= render "admin/staff_notes/partials/list_of_notes", staff_notes: @presenter.staff_notes %>
+ New Staff Note
+ <%= render "admin/staff_notes/partials/new", staff_note: @presenter.new_staff_note, user: @user %>
+
+
+
<% if @presenter.can_view_favorites? %>
- <%= render "posts/partials/common/inline_blacklist" %>
+ <%= render "posts/partials/common/inline_blacklist" %>
- <%= render "post_summary", :presenter => @presenter, :user => @user %>
+ <%= render "post_summary", :presenter => @presenter, :user => @user %>
<% end %>
diff --git a/config/routes.rb b/config/routes.rb
index 52487cb54..939939dae 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -21,6 +21,7 @@ Rails.application.routes.draw do
resource :dashboard, :only => [:show]
resources :exceptions, only: [:index, :show]
resource :reowner, controller: 'reowner', only: [:new, :create]
+ resources :staff_notes, only: [:index]
end
resources :edit_histories
namespace :moderator do
@@ -336,6 +337,7 @@ Rails.application.routes.draw do
resource :api_key, :only => [:show, :view, :update, :destroy], :controller => "maintenance/user/api_keys" do
post :view
end
+ resources :staff_notes, only: [:index, :new, :create], controller: "admin/staff_notes"
collection do
get :home
diff --git a/db/migrate/20210426025625_add_staff_notes_table.rb b/db/migrate/20210426025625_add_staff_notes_table.rb
new file mode 100644
index 000000000..edcccc5f7
--- /dev/null
+++ b/db/migrate/20210426025625_add_staff_notes_table.rb
@@ -0,0 +1,11 @@
+class AddStaffNotesTable < ActiveRecord::Migration[6.1]
+ def change
+ create_table :staff_notes do |t|
+ t.timestamps
+ t.references :user, null: false, foreign_key: true, index: true
+ t.integer :creator_id, null: false, index: true
+ t.string :body
+ t.boolean :resolved, null: false, default: false
+ end
+ end
+end
diff --git a/db/migrate/20210506235640_add_staff_audit_logs_table.rb b/db/migrate/20210506235640_add_staff_audit_logs_table.rb
new file mode 100644
index 000000000..fecb9067f
--- /dev/null
+++ b/db/migrate/20210506235640_add_staff_audit_logs_table.rb
@@ -0,0 +1,10 @@
+class AddStaffAuditLogsTable < ActiveRecord::Migration[6.1]
+ def change
+ create_table :staff_audit_logs do |t|
+ t.timestamps
+ t.references :user, null: false, foreign_key: true, index: true
+ t.string :action, null: false, default: 'unknown_action'
+ t.json :values
+ end
+ end
+end
diff --git a/db/structure.sql b/db/structure.sql
index c2f46229b..83e6625af 100644
--- a/db/structure.sql
+++ b/db/structure.sql
@@ -2022,6 +2022,73 @@ CREATE TABLE public.schema_migrations (
);
+--
+-- Name: staff_audit_logs; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE public.staff_audit_logs (
+ id bigint NOT NULL,
+ created_at timestamp(6) without time zone NOT NULL,
+ updated_at timestamp(6) without time zone NOT NULL,
+ user_id bigint NOT NULL,
+ action character varying DEFAULT 'unknown_action'::character varying NOT NULL,
+ "values" json
+);
+
+
+--
+-- Name: staff_audit_logs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE public.staff_audit_logs_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: staff_audit_logs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE public.staff_audit_logs_id_seq OWNED BY public.staff_audit_logs.id;
+
+
+--
+-- Name: staff_notes; Type: TABLE; Schema: public; Owner: -
+--
+
+CREATE TABLE public.staff_notes (
+ id bigint NOT NULL,
+ created_at timestamp(6) without time zone NOT NULL,
+ updated_at timestamp(6) without time zone NOT NULL,
+ user_id bigint NOT NULL,
+ creator_id integer NOT NULL,
+ body character varying,
+ resolved boolean DEFAULT false NOT NULL
+);
+
+
+--
+-- Name: staff_notes_id_seq; Type: SEQUENCE; Schema: public; Owner: -
+--
+
+CREATE SEQUENCE public.staff_notes_id_seq
+ START WITH 1
+ INCREMENT BY 1
+ NO MINVALUE
+ NO MAXVALUE
+ CACHE 1;
+
+
+--
+-- Name: staff_notes_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
+--
+
+ALTER SEQUENCE public.staff_notes_id_seq OWNED BY public.staff_notes.id;
+
+
--
-- Name: tag_aliases; Type: TABLE; Schema: public; Owner: -
--
@@ -3025,6 +3092,20 @@ ALTER TABLE ONLY public.posts ALTER COLUMN change_seq SET DEFAULT nextval('publi
ALTER TABLE ONLY public.saved_searches ALTER COLUMN id SET DEFAULT nextval('public.saved_searches_id_seq'::regclass);
+--
+-- Name: staff_audit_logs id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.staff_audit_logs ALTER COLUMN id SET DEFAULT nextval('public.staff_audit_logs_id_seq'::regclass);
+
+
+--
+-- Name: staff_notes id; Type: DEFAULT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.staff_notes ALTER COLUMN id SET DEFAULT nextval('public.staff_notes_id_seq'::regclass);
+
+
--
-- Name: tag_aliases id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -3547,6 +3628,22 @@ ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (version);
+--
+-- Name: staff_audit_logs staff_audit_logs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.staff_audit_logs
+ ADD CONSTRAINT staff_audit_logs_pkey PRIMARY KEY (id);
+
+
+--
+-- Name: staff_notes staff_notes_pkey; Type: CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.staff_notes
+ ADD CONSTRAINT staff_notes_pkey PRIMARY KEY (id);
+
+
--
-- Name: tag_aliases tag_aliases_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@@ -4522,6 +4619,27 @@ CREATE INDEX index_saved_searches_on_query ON public.saved_searches USING btree
CREATE INDEX index_saved_searches_on_user_id ON public.saved_searches USING btree (user_id);
+--
+-- Name: index_staff_audit_logs_on_user_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_staff_audit_logs_on_user_id ON public.staff_audit_logs USING btree (user_id);
+
+
+--
+-- Name: index_staff_notes_on_creator_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_staff_notes_on_creator_id ON public.staff_notes USING btree (creator_id);
+
+
+--
+-- Name: index_staff_notes_on_user_id; Type: INDEX; Schema: public; Owner: -
+--
+
+CREATE INDEX index_staff_notes_on_user_id ON public.staff_notes USING btree (user_id);
+
+
--
-- Name: index_tag_aliases_on_antecedent_name; Type: INDEX; Schema: public; Owner: -
--
@@ -4865,6 +4983,14 @@ CREATE TRIGGER trigger_posts_on_tag_index_update BEFORE INSERT OR UPDATE ON publ
CREATE TRIGGER trigger_wiki_pages_on_update BEFORE INSERT OR UPDATE ON public.wiki_pages FOR EACH ROW EXECUTE PROCEDURE tsvector_update_trigger('body_index', 'public.danbooru', 'body', 'title');
+--
+-- Name: staff_audit_logs fk_rails_02329e5ef9; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.staff_audit_logs
+ ADD CONSTRAINT fk_rails_02329e5ef9 FOREIGN KEY (user_id) REFERENCES public.users(id);
+
+
--
-- Name: post_image_hashes fk_rails_2b7afcc2f0; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -4881,6 +5007,14 @@ ALTER TABLE ONLY public.favorites
ADD CONSTRAINT fk_rails_a7668ef613 FOREIGN KEY (user_id) REFERENCES public.users(id);
+--
+-- Name: staff_notes fk_rails_bab7e2d92a; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY public.staff_notes
+ ADD CONSTRAINT fk_rails_bab7e2d92a FOREIGN KEY (user_id) REFERENCES public.users(id);
+
+
--
-- Name: favorites fk_rails_d20e53bb68; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -5128,6 +5262,8 @@ INSERT INTO "schema_migrations" (version) VALUES
('20210117173030'),
('20210405040522'),
('20210425020131'),
-('20210430201028');
+('20210426025625'),
+('20210430201028'),
+('20210506235640');