Skip to content

Commit

Permalink
Merge pull request #1020 from metabrainz/administration-system
Browse files Browse the repository at this point in the history
GSoC 2023 - Administration system -  Rollup PR
  • Loading branch information
MonkeyDo committed Sep 19, 2023
2 parents 07d40bf + 71a3867 commit 0d96f3e
Show file tree
Hide file tree
Showing 86 changed files with 5,206 additions and 240 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -36,7 +36,7 @@
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.1.11",
"array-move": "^3.0.1",
"bookbrainz-data": "4.0.0",
"bookbrainz-data": "4.1.1",
"chart.js": "^2.9.4",
"chartjs-adapter-date-fns": "^1.0.0",
"classnames": "^2.3.2",
Expand Down
6 changes: 6 additions & 0 deletions sql/migrations/2023-05-29-admin_logs/down.sql
@@ -0,0 +1,6 @@
BEGIN TRANSACTION;

DROP TABLE IF EXISTS bookbrainz.admin_log;
DROP TYPE IF EXISTS bookbrainz.admin_action_type;

COMMIT;
25 changes: 25 additions & 0 deletions sql/migrations/2023-05-29-admin_logs/up.sql
@@ -0,0 +1,25 @@
BEGIN TRANSACTION;

CREATE TYPE bookbrainz.admin_action_type AS ENUM (
'Change Privileges'
);

COMMIT;

BEGIN TRANSACTION;

CREATE TABLE bookbrainz.admin_log (
id SERIAL PRIMARY KEY,
admin_id INT NOT NULL,
target_user_id INT NOT NULL,
old_privs INT,
new_privs INT,
action_type bookbrainz.admin_action_type NOT NULL,
time TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT timezone('UTC'::TEXT, now()),
note VARCHAR NOT NULL
);

ALTER TABLE bookbrainz.admin_log ADD FOREIGN KEY (admin_id) REFERENCES bookbrainz.editor(id);
ALTER TABLE bookbrainz.admin_log ADD FOREIGN KEY (target_user_id) REFERENCES bookbrainz.editor(id);

COMMIT;
5 changes: 5 additions & 0 deletions sql/migrations/2023-05-29-user_privileges/up.sql
@@ -0,0 +1,5 @@
BEGIN TRANSACTION;

ALTER TABLE bookbrainz.editor ADD COLUMN privs INT NOT NULL DEFAULT 1;

COMMIT;
3 changes: 3 additions & 0 deletions sql/migrations/2023-08-23-identifier-types-sequence/up.sql
@@ -0,0 +1,3 @@
BEGIN TRANSACTION;
SELECT SETVAL('identifier_type_id_seq', (SELECT MAX(id) FROM identifier_type));
COMMIT;
19 changes: 19 additions & 0 deletions sql/schemas/bookbrainz.sql
Expand Up @@ -20,6 +20,10 @@ CREATE TYPE bookbrainz.external_service_oauth_type AS ENUM (
'critiquebrainz'
);

CREATE TYPE bookbrainz.admin_action_type AS ENUM (
'Change Privileges'
);

CREATE TABLE bookbrainz.editor_type (
id SERIAL PRIMARY KEY,
label VARCHAR(255) NOT NULL CHECK (label <> '')
Expand All @@ -37,6 +41,7 @@ CREATE TABLE bookbrainz.editor (
type_id INT NOT NULL,
gender_id INT,
area_id INT,
privs INT NOT NULL DEFAULT 1,
revisions_applied INT NOT NULL DEFAULT 0 CHECK (revisions_applied >= 0),
revisions_reverted INT NOT NULL DEFAULT 0 CHECK (revisions_reverted >= 0),
total_revisions INT NOT NULL DEFAULT 0 CHECK (total_revisions >= 0),
Expand All @@ -56,6 +61,20 @@ CREATE TABLE bookbrainz.editor__language (
)
);

CREATE TABLE bookbrainz.admin_log (
id SERIAL PRIMARY KEY,
admin_id INT NOT NULL,
target_user_id INT NOT NULL,
old_privs INT,
new_privs INT,
action_type bookbrainz.admin_action_type NOT NULL,
time TIMESTAMP WITHOUT TIME ZONE NOT NULL DEFAULT timezone('UTC'::TEXT, now()),
note VARCHAR NOT NULL
);

ALTER TABLE bookbrainz.admin_log ADD FOREIGN KEY (admin_id) REFERENCES bookbrainz.editor (id);
ALTER TABLE bookbrainz.admin_log ADD FOREIGN KEY (target_user_id) REFERENCES bookbrainz.editor (id);

CREATE TABLE bookbrainz.entity (
bbid UUID PRIMARY KEY DEFAULT public.uuid_generate_v4(),
type bookbrainz.entity_type NOT NULL
Expand Down
31 changes: 19 additions & 12 deletions src/client/components/footer.js
Expand Up @@ -59,24 +59,31 @@ function Footer(props) {
</small>
</Col>
<Col className="text-right" xs={4}>
<small>
<div className="small">
<a href="/admin-logs">
Admin Logs
</a>
</div>
<div className="small">
<a href="/privacy">
Privacy & Terms
</a>
</div>
</Col>
</Row>
<Row>
<Col className="text-center" xs={12}>
<small>
Alpha Software —{' '}
<a href={`${repositoryUrl}tree/${siteRevision || 'master'}`}>
{siteRevision || 'unknown revision'}
</a> —&nbsp;
<a href="https://tickets.metabrainz.org/projects/BB/issues/">
Report a Bug
</a>
</small>
</Col>
</Row>
<div className="text-center">
<small>
Alpha Software —{' '}
<a href={`${repositoryUrl}tree/${siteRevision || 'master'}`}>
{siteRevision || 'unknown revision'}
</a> —&nbsp;
<a href="https://tickets.metabrainz.org/projects/BB/issues/">
Report a Bug
</a>
</small>
</div>
</Container>
</footer>
);
Expand Down

0 comments on commit 0d96f3e

Please sign in to comment.