Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions admin/schema_updates/2024-12-11-add-user-table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
BEGIN;

CREATE TABLE "user" (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
name TEXT NOT NULL,
password TEXT NOT NULL,
email TEXT UNIQUE,
unconfirmed_email TEXT,
email_confirmed_at TIMESTAMP WITH TIME ZONE,
member_since TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
last_login_at TIMESTAMP WITH TIME ZONE,
last_updated TIMESTAMP WITH TIME ZONE,
deleted BOOLEAN
);

ALTER TABLE "user" ADD CONSTRAINT user_pkey PRIMARY KEY (id);

COMMIT;
10 changes: 10 additions & 0 deletions admin/schema_updates/2024-12-12-link-user-and-supporter-table.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
BEGIN;

ALTER TABLE supporter ADD COLUMN user_id INTEGER;
UPDATE supporter SET user_id = musicbrainz_row_id;

ALTER TABLE supporter ADD CONSTRAINT supporter_user_id_fkey
FOREIGN KEY (user_id) REFERENCES "user" (id)
ON UPDATE CASCADE ON DELETE SET NULL;

COMMIT;
22 changes: 22 additions & 0 deletions admin/schema_updates/2025-02-15-add-moderation-log.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
CREATE TYPE moderation_action_type AS ENUM ('block', 'unblock');

BEGIN;

ALTER TABLE "user" ADD COLUMN is_blocked BOOLEAN NOT NULL DEFAULT FALSE;
CREATE TABLE moderation_log (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
user_id INTEGER NOT NULL,
moderator_id INTEGER NOT NULL,
action moderation_action_type NOT NULL,
reason TEXT NOT NULL,
timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);
ALTER TABLE moderation_log ADD CONSTRAINT moderation_log_pkey PRIMARY KEY (id);
ALTER TABLE moderation_log ADD CONSTRAINT moderation_log_user_id_fkey FOREIGN KEY (user_id) REFERENCES "user" (id);
ALTER TABLE moderation_log ADD CONSTRAINT moderation_log_moderator_id_fkey FOREIGN KEY (moderator_id) REFERENCES "user" (id);
CREATE INDEX moderation_log_user_id_idx ON moderation_log (user_id);

ALTER TABLE "user" ADD COLUMN login_id UUID NOT NULL;
CREATE UNIQUE INDEX user_login_id_idx ON "user" (login_id);

COMMIT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TYPE moderation_action_type ADD VALUE 'comment';
ALTER TYPE moderation_action_type ADD VALUE 'verify_email';
16 changes: 15 additions & 1 deletion admin/sql/create_foreign_keys.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ ALTER TABLE token
REFERENCES supporter (id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE SET NULL;

ALTER TABLE supporter ADD CONSTRAINT supporter_user_id_fkey
FOREIGN KEY (user_id) REFERENCES "user" (id)
ON UPDATE CASCADE ON DELETE SET NULL;

ALTER TABLE supporter
ADD CONSTRAINT supporter_tier_id_fkey FOREIGN KEY (tier_id)
REFERENCES tier (id) MATCH SIMPLE
Expand All @@ -17,7 +21,7 @@ ALTER TABLE dataset_supporter

ALTER TABLE dataset_supporter
ADD CONSTRAINT dataset_supporter_dataset_id_fkey FOREIGN KEY (dataset_id)
REFERENCES "dataset" (id) MATCH SIMPLE
REFERENCES dataset (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION;

ALTER TABLE token_log
Expand All @@ -35,4 +39,14 @@ ALTER TABLE access_log
REFERENCES token (value) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION;

ALTER TABLE moderation_log
ADD CONSTRAINT moderation_log_user_id_fkey FOREIGN KEY (user_id)
REFERENCES "user" (id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE SET NULL;

ALTER TABLE moderation_log
ADD CONSTRAINT moderation_log_moderator_id_fkey FOREIGN KEY (moderator_id)
REFERENCES "user" (id) MATCH SIMPLE
ON UPDATE CASCADE ON DELETE SET NULL;

COMMIT;
2 changes: 2 additions & 0 deletions admin/sql/create_indexes.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ BEGIN;

-- TODO: Add some, if needed.

CREATE INDEX moderation_log_user_id_idx ON moderation_log (user_id);

COMMIT;
2 changes: 2 additions & 0 deletions admin/sql/create_primary_keys.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
BEGIN;

ALTER TABLE "user" ADD CONSTRAINT user_pkey PRIMARY KEY (id);
ALTER TABLE moderation_log ADD CONSTRAINT moderation_log_pkey PRIMARY KEY (id);
ALTER TABLE tier ADD CONSTRAINT tier_pkey PRIMARY KEY (id);
ALTER TABLE supporter ADD CONSTRAINT supporter_pkey PRIMARY KEY (id);
ALTER TABLE token ADD CONSTRAINT token_pkey PRIMARY KEY (value);
Expand Down
28 changes: 25 additions & 3 deletions admin/sql/create_tables.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
BEGIN;

CREATE TABLE "user" (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
login_id UUID NOT NULL,
name TEXT NOT NULL,
password TEXT NOT NULL,
email TEXT UNIQUE,
unconfirmed_email TEXT,
email_confirmed_at TIMESTAMP WITH TIME ZONE,
member_since TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW(),
last_login_at TIMESTAMP WITH TIME ZONE,
last_updated TIMESTAMP WITH TIME ZONE,
deleted BOOLEAN NOT NULL DEFAULT FALSE,
is_blocked BOOLEAN NOT NULL DEFAULT FALSE
);

CREATE TABLE moderation_log (
id INTEGER GENERATED BY DEFAULT AS IDENTITY,
user_id INTEGER NOT NULL,
moderator_id INTEGER NOT NULL,
action moderation_action_type NOT NULL,
reason TEXT NOT NULL,
timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
);

CREATE TABLE tier (
id SERIAL NOT NULL, -- PK
name CHARACTER VARYING NOT NULL,
Expand All @@ -20,12 +44,10 @@ CREATE TABLE dataset (
CREATE TABLE supporter (
id SERIAL NOT NULL, -- PK
is_commercial BOOLEAN NOT NULL,
musicbrainz_id CHARACTER VARYING UNIQUE,
musicbrainz_row_id INTEGER UNIQUE,
user_id INTEGER UNIQUE,
created TIMESTAMP WITH TIME ZONE,
state state_types NOT NULL,
contact_name CHARACTER VARYING NOT NULL,
contact_email CHARACTER VARYING NOT NULL,
data_usage_desc TEXT,
org_name CHARACTER VARYING,
logo_filename CHARACTER VARYING,
Expand Down
6 changes: 6 additions & 0 deletions admin/sql/create_types.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
BEGIN;

CREATE TYPE moderation_action_type AS ENUM ('block', 'unblock', 'comment');

CREATE TYPE payment_method_types AS ENUM (
'stripe',
'paypal',
Expand Down Expand Up @@ -29,3 +33,5 @@ CREATE TYPE dataset_project_type AS ENUM (
'listenbrainz',
'critiquebrainz'
);

COMMIT;
2 changes: 2 additions & 0 deletions admin/sql/drop_tables.sql
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
BEGIN;

DROP TABLE IF EXISTS "user" CASCADE;
DROP TABLE IF EXISTS payment CASCADE;
DROP TABLE IF EXISTS oauth_grant CASCADE;
DROP TABLE IF EXISTS oauth_token CASCADE;
DROP TABLE IF EXISTS oauth_client CASCADE;
DROP TABLE IF EXISTS access_log CASCADE;
DROP TABLE IF EXISTS moderation_log CASCADE;
DROP TABLE IF EXISTS token_log CASCADE;
DROP TABLE IF EXISTS token CASCADE;
DROP TABLE IF EXISTS supporter CASCADE;
Expand Down
4 changes: 4 additions & 0 deletions admin/sql/oauth/create_tables.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BEGIN;

CREATE schema oauth;

CREATE TABLE oauth.scope (
Expand Down Expand Up @@ -109,3 +111,5 @@ CREATE TABLE oauth.l_code_scope (
FOREIGN KEY(code_id) REFERENCES oauth.code (id) ON DELETE CASCADE,
FOREIGN KEY(scope_id) REFERENCES oauth.scope (id) ON DELETE CASCADE
);

COMMIT;
10 changes: 10 additions & 0 deletions config.py.example
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
from datetime import timedelta

# CUSTOM CONFIGURATION

DEBUG = True # set to False in production mode

SECRET_KEY = "CHANGE_THIS"

EMAIL_VERIFICATION_SECRET_KEY = "CHANGE THIS"
EMAIL_VERIFICATION_EXPIRY = timedelta(hours=24)
EMAIL_RESET_PASSWORD_EXPIRY = timedelta(hours=24)

# Bcrypt
BCRYPT_HASH_PREFIX = "2a"
BCRYPT_LOG_ROUNDS = 12

# DATABASE
SQLALCHEMY_DATABASE_URI = "postgresql://metabrainz:metabrainz@meb_db:5432/metabrainz"
SQLALCHEMY_MUSICBRAINZ_URI = ""
Expand Down
10 changes: 10 additions & 0 deletions consul_config.py.ctmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,19 @@
{{- end -}}
{{- end -}}

from datetime import timedelta

SECRET_KEY = '''{{template "KEY" "secret_key"}}'''
DEBUG = False

EMAIL_VERIFICATION_SECRET_KEY = '''{{template "KEY" "email_verification_secret_key"}}'''
EMAIL_VERIFICATION_EXPIRY = timedelta(hours=24)
EMAIL_RESET_PASSWORD_EXPIRY = timedelta(hours=24)

# Bcrypt
BCRYPT_HASH_PREFIX = "2a"
BCRYPT_LOG_ROUNDS = 12

{{if service "pgbouncer-master"}}
{{with index (service "pgbouncer-master") 0}}
SQLALCHEMY_DATABASE_URI = "postgresql://{{template "KEY" "postgresql/username"}}:{{template "KEY" "postgresql/password"}}@{{.Address}}:{{.Port}}/{{template "KEY" "postgresql/db_name"}}"
Expand Down
4 changes: 3 additions & 1 deletion docker/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ services:
context: ..
dockerfile: Dockerfile
target: metabrainz-dev
command: python manage.py runserver -h 0.0.0.0 -p 8000
command: flask run --debug -h 0.0.0.0 -p 8000
environment:
FLASK_APP: "metabrainz:create_app()"
volumes:
- ../data/replication_packets:/data/replication_packets
- ../data/json_dumps:/data/json_dumps
Expand Down
107 changes: 107 additions & 0 deletions frontend/css/auth-page.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#auth-page {
font-style: normal;
font-weight: 400;
min-height: 500px;
background: linear-gradient(90deg, #3b9766 0%, #ffa500 100%);
margin: 0 -1em;
padding: 2em;

.form-label {
font-weight: normal;
}
.label-with-link {
display: flex;
justify-content: space-between;
width: 100%;
label {
flex-shrink: 0;
}
}
.form-label-link {
text-align: right;
}

.auth-page-container {
max-width: 600px;
margin-left: auto;
margin-right: auto;
}
.auth-card-container {
background: #e7e7e7;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.2);
border-radius: 3px;
}
.auth-card {
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: bold;
}
background: #ffffff;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.2);
padding: 1rem 6rem;
border-radius: 3px;
@media screen and (max-width: @screen-xs-max) {
padding: 1rem 3rem;
}
}
.auth-card-bottom {
display: flex;
align-items: center;
justify-content: space-between;
}
.auth-card-footer {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
padding: 1rem;
font-size: 1.3rem;
line-height: 1.6rem;
color: #808080;
}
.main-action-button {
display: block;
font-size: 1.1em;
margin: 1em auto;
}
.modal-content {
padding: 1.5em;
}
}

#conditions-modal {
font-size: initial;
}
@icon-pill-size: 50px;
@icon-logo-size: 40px;
@icon-pill-padding: 8px;
.icon-pills {
display: flex;
justify-content: space-evenly;
margin-bottom: 2rem;
.icon-pill {
background: #d9d9d9;
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.2);
text-align: center;
width: @icon-pill-size;
height: @icon-pill-size;
border-radius: @icon-pill-size;
padding: @icon-pill-padding;
display: flex;
align-items: center;
justify-content: flex-start;
overflow: hidden;
transition: width 0.42s;
&:hover {
width: 160px; // Fallback
width: calc(attr(data-logo-width px) + @icon-pill-padding * 2);
}
img {
height: @icon-logo-size;
max-width: unset;
}
}
}
1 change: 1 addition & 0 deletions frontend/css/main.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@import "theme/theme.less";
@import "carousel.less";
@import "auth-page.less";

// fixme: need to make it configurable for production and development and meb.org container and oauth container
@icon-font-path:"/static/fonts/";
Expand Down
2 changes: 1 addition & 1 deletion frontend/css/theme/boostrap/boostrap.less
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
@import "panels.less";
//@import "responsive-embed.less";
@import "wells.less";
//@import "close.less";
@import "close.less";

// Components w/ JavaScript
@import "modals.less";
Expand Down
39 changes: 38 additions & 1 deletion frontend/img/logos/listenbrainz.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading