Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename user templates directory to supporters #459

Merged
merged 3 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ import * as Yup from "yup";
import { getPageProps } from "../utils";
import { Dataset, DatasetsInput, TextInput } from "./utils";

type ProfileEditProps = {
type SupporterProfileEditProps = {
datasets: Dataset[];
is_commercial: boolean;
csrf_token: string;
initial_form_data: any;
initial_errors: any;
};

function ProfileEdit({
function SupporterProfileEdit({
datasets,
is_commercial,
csrf_token,
initial_form_data,
initial_errors,
}: ProfileEditProps): JSX.Element {
}: SupporterProfileEditProps): JSX.Element {
return (
<>
<h1 className="page-title">Your Profile</h1>
Expand Down Expand Up @@ -104,7 +104,7 @@ document.addEventListener("DOMContentLoaded", () => {

const renderRoot = createRoot(domContainer!);
renderRoot.render(
<ProfileEdit
<SupporterProfileEdit
datasets={datasets}
is_commercial={is_commercial}
csrf_token={csrf_token}
Expand Down
2 changes: 1 addition & 1 deletion metabrainz/admin/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from flask_wtf import FlaskForm
from flask_wtf.file import FileField, FileAllowed
from wtforms import StringField, BooleanField, SelectField, TextAreaField
from wtforms.fields.html5 import EmailField, URLField, DecimalField
from wtforms.fields import EmailField, URLField, DecimalField
from metabrainz.model import supporter
from metabrainz.db import tier as db_tier
from flask_uploads import UploadSet, IMAGES
Expand Down
8 changes: 4 additions & 4 deletions metabrainz/admin/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ class SupportersView(AdminBaseView):
def index(self):
value = request.args.get('value')
results = Supporter.search(value) if value else []
return self.render('admin/users/index.html',
return self.render('admin/supporters/index.html',
value=value, results=results)

@expose('/<int:supporter_id>')
def details(self, supporter_id):
supporter = Supporter.get(id=supporter_id)
active_tokens = Token.get_all(owner_id=supporter.id, is_active=True)
return self.render(
'admin/users/details.html',
'admin/supporters/details.html',
supporter=supporter,
active_tokens=active_tokens,
)
Expand Down Expand Up @@ -122,7 +122,7 @@ def edit(self, supporter_id):
return redirect(url_for('.details', supporter_id=supporter.id))

return self.render(
'admin/users/edit.html',
'admin/supporters/edit.html',
supporter=supporter,
form=form,
)
Expand Down Expand Up @@ -200,7 +200,7 @@ def index(self):
limit = 20
offset = (page - 1) * limit
supporters, count = Supporter.get_all_commercial(limit=limit, offset=offset)
return self.render('admin/commercial-users/index.html', supporters=supporters,
return self.render('admin/commercial-supporters/index.html', supporters=supporters,
page=page, limit=limit, count=count)


Expand Down
3 changes: 1 addition & 2 deletions metabrainz/payments/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from flask_wtf import FlaskForm
from flask_babel import lazy_gettext
from wtforms import StringField, BooleanField
from wtforms.fields import RadioField
from wtforms.fields.html5 import DecimalField, IntegerField
from wtforms.fields import RadioField, DecimalField, IntegerField
from wtforms.validators import DataRequired
from metabrainz.payments import Currency

Expand Down
3 changes: 1 addition & 2 deletions metabrainz/supporter/forms.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from flask_wtf import FlaskForm, RecaptchaField
from flask_babel import gettext
from wtforms import BooleanField, TextAreaField, validators
from wtforms.fields.core import StringField, SelectMultipleField
from wtforms.fields.html5 import EmailField, URLField, DecimalField
from wtforms.fields import StringField, SelectMultipleField, EmailField, URLField, DecimalField
from wtforms.validators import DataRequired, Length
from wtforms.widgets import ListWidget, CheckboxInput

Expand Down
20 changes: 10 additions & 10 deletions metabrainz/supporter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@

@supporters_bp.route('/supporters')
def supporters_list():
return render_template('users/supporters-list.html', tiers=Tier.get_available(sort=True, sort_desc=True))
return render_template('supporters/supporters-list.html', tiers=Tier.get_available(sort=True, sort_desc=True))


@supporters_bp.route('/supporters/bad')
def bad_standing():
return render_template('users/bad-standing.html')
return render_template('supporters/bad-standing.html')


@supporters_bp.route('/supporters/account-type')
def account_type():
return render_template(
'users/account-type.html',
'supporters/account-type.html',
tiers=Tier.get_available(sort=True),
featured_supporters=Supporter.get_featured()
)
Expand All @@ -52,7 +52,7 @@ def tier(tier_id):
t = Tier.get(id=tier_id)
if not t or not t.available:
raise NotFound(gettext("Can't find tier with a specified ID."))
return render_template('users/tier.html', tier=t)
return render_template('supporters/tier.html', tier=t)


@supporters_bp.route('/signup')
Expand All @@ -61,7 +61,7 @@ def signup():
mb_username = session.fetch_data(SESSION_KEY_MB_USERNAME)
if mb_username is None:
# Show template with a link to MusicBrainz OAuth page
return render_template('users/mb-signup.html')
return render_template('supporters/mb-signup.html')

account_type = session.fetch_data(SESSION_KEY_ACCOUNT_TYPE)
if not account_type:
Expand Down Expand Up @@ -180,7 +180,7 @@ def custom_validation(f):
form_data["amount_pledged"] = float(form_data["amount_pledged"])
form_data.pop("csrf_token", None)

return render_template("users/signup-commercial.html", props=json.dumps({
return render_template("supporters/signup-commercial.html", props=json.dumps({
"tier": {
"name": selected_tier.name,
"price": float(selected_tier.price)
Expand Down Expand Up @@ -243,7 +243,7 @@ def signup_noncommercial():
form_data = dict(**form.data)
form_data.pop("csrf_token", None)

return render_template("users/signup-non-commercial.html", props=json.dumps({
return render_template("supporters/signup-non-commercial.html", props=json.dumps({
"datasets": [{"id": d.id, "description": d.description, "name": d.name} for d in available_datasets],
"mb_username": mb_username,
"recaptcha_site_key": current_app.config["RECAPTCHA_PUBLIC_KEY"],
Expand Down Expand Up @@ -292,7 +292,7 @@ def musicbrainz_post():
@supporters_bp.route('/profile')
@login_required
def profile():
return render_template("users/profile.html")
return render_template("supporters/profile.html")


@supporters_bp.route('/profile/edit', methods=['GET', 'POST'])
Expand Down Expand Up @@ -328,7 +328,7 @@ def profile_edit():
form_data = dict(**form.data)
form_data.pop("csrf_token", None)

return render_template("users/profile-edit.html", props=json.dumps({
return render_template("supporters/profile-edit.html", props=json.dumps({
"datasets": [{"id": d.id, "description": d.description, "name": d.name} for d in available_datasets],
"is_commercial": current_user.is_commercial,
"csrf_token": generate_csrf(),
Expand All @@ -351,7 +351,7 @@ def regenerate_token():
@supporters_bp.route('/login')
@login_forbidden
def login():
return render_template('users/mb-login.html')
return render_template('supporters/mb-login.html')


@supporters_bp.route('/logout')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@

{% block scripts %}
{{ super() }}
<script src="{{ get_static_path('profileEdit.js') }}" type="text/javascript"></script>
<script src="{{ get_static_path('supporterProfileEdit.js') }}" type="text/javascript"></script>
{% endblock %}
40 changes: 20 additions & 20 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
certifi
click==8.1.3
email_validator==1.0.5
Flask==2.3.2
click==8.1.7
email_validator==2.1.1
Flask==3.0.2
Flask-Admin==1.6.1
Flask-Babel==3.1.0
Flask-Babel==4.0.0
Flask-DebugToolbar@git+https://github.com/amCap1712/flask-debugtoolbar.git@f42bb238cd3fbc79c51b93c341164c2be820025e
Flask-Login==0.6.3
Flask-SQLAlchemy==3.0.3
Flask-SQLAlchemy==3.0.5
Flask-Testing==0.8.1
Flask-UUID==0.2
Flask-WTF==1.2.1
git+https://github.com/maxcountryman/flask-uploads.git@f66d7dc93e68#egg=Flask_Uploads
git+https://github.com/metabrainz/brainzutils-python.git@v2.7.1
idna==2.7
idna==3.6
importlib-metadata>=3.10.0
intuit-oauth==1.2.4
intuit-oauth==1.2.5
itsdangerous==2.1.2
Jinja2==3.1.3
MarkupSafe==2.1.2
MarkupSafe==2.1.5
mbdata==26.0.1
msgpack-python==0.5.6
msgpack==0.5.6
psycopg2-binary==2.9.7
pytest==7.4.0
pytest==8.1.1
pytest-cov==4.1.0
python-dateutil==2.8.0
python-quickbooks==0.9.6
pytz==2022.7.1
python-dateutil==2.9.0.post0
python-quickbooks==0.9.7
pytz==2024.1
rauth==0.7.3
redis==4.5.4
reportlab==3.6.13
redis==5.0.3
reportlab==4.1.0
requests==2.31.0
sentry-sdk[flask]==1.29.2
sentry-sdk[flask]==1.43.0
six==1.16.0
SQLAlchemy==1.4.18
SQLAlchemy==1.4.52
sqlalchemy-dst>=1.0.1
stripe==2.60.0
urllib3==2.0.7
stripe==8.7.0
urllib3==2.2.1
Werkzeug==3.0.1
WTForms==2.3.3
WTForms==3.1.2
10 changes: 8 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,14 @@ module.exports = function (env, argv) {
path.resolve(cssDir, "main.less"),
],
signupCommercial: path.resolve(jsDir, "src/forms/SignupCommercial.tsx"),
signupNonCommercial: path.resolve(jsDir, "src/forms/SignupNonCommercial.tsx"),
profileEdit: path.resolve(jsDir, "src/forms/ProfileEdit.tsx")
signupNonCommercial: path.resolve(
jsDir,
"src/forms/SignupNonCommercial.tsx"
),
supporterProfileEdit: path.resolve(
jsDir,
"src/forms/SupporterProfileEdit.tsx"
),
},
output: {
filename: isProd ? "[name].[contenthash].js" : "[name].js",
Expand Down
Loading