mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Use consistent quotes
This commit is contained in:
parent
9ddc29e41f
commit
0385590922
@ -5,10 +5,10 @@ from flask.ext import markdown
|
||||
from flask_github import GitHub
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_pyfile('../config.cfg')
|
||||
app.config.from_pyfile("../config.cfg")
|
||||
|
||||
menu.Menu(app=app)
|
||||
markdown.Markdown(app, extensions=['fenced_code'])
|
||||
markdown.Markdown(app, extensions=["fenced_code"])
|
||||
github = GitHub(app)
|
||||
|
||||
from . import models
|
||||
|
@ -54,8 +54,8 @@ class User(db.Model, UserMixin):
|
||||
|
||||
# User authentication information
|
||||
username = db.Column(db.String(50), nullable=False, unique=True)
|
||||
password = db.Column(db.String(255), nullable=False, server_default='')
|
||||
reset_password_token = db.Column(db.String(100), nullable=False, server_default='')
|
||||
password = db.Column(db.String(255), nullable=False, server_default="")
|
||||
reset_password_token = db.Column(db.String(100), nullable=False, server_default="")
|
||||
|
||||
rank = db.Column(db.Enum(UserRank))
|
||||
|
||||
@ -68,11 +68,11 @@ class User(db.Model, UserMixin):
|
||||
confirmed_at = db.Column(db.DateTime())
|
||||
|
||||
# User information
|
||||
active = db.Column('is_active', db.Boolean, nullable=False, server_default='0')
|
||||
display_name = db.Column(db.String(100), nullable=False, server_default='')
|
||||
active = db.Column("is_active", db.Boolean, nullable=False, server_default="0")
|
||||
display_name = db.Column(db.String(100), nullable=False, server_default="")
|
||||
|
||||
# Content
|
||||
packages = db.relationship('Package', backref='author', lazy='dynamic')
|
||||
packages = db.relationship("Package", backref="author", lazy="dynamic")
|
||||
|
||||
def __init__(self, username):
|
||||
import datetime
|
||||
@ -108,7 +108,7 @@ class Package(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
# Basic details
|
||||
author_id = db.Column(db.Integer, db.ForeignKey('user.id'))
|
||||
author_id = db.Column(db.Integer, db.ForeignKey("user.id"))
|
||||
name = db.Column(db.String(100), nullable=False)
|
||||
title = db.Column(db.String(100), nullable=False)
|
||||
shortDesc = db.Column(db.String(200), nullable=False)
|
||||
@ -124,8 +124,8 @@ class Package(db.Model):
|
||||
forums = db.Column(db.Integer, nullable=False)
|
||||
|
||||
# Releases
|
||||
releases = db.relationship('PackageRelease', backref='package',
|
||||
lazy='dynamic', order_by=db.desc("package_release_releaseDate"))
|
||||
releases = db.relationship("PackageRelease", backref="package",
|
||||
lazy="dynamic", order_by=db.desc("package_release_releaseDate"))
|
||||
|
||||
def getDetailsURL(self):
|
||||
return url_for("package_page",
|
||||
@ -180,7 +180,7 @@ class Package(db.Model):
|
||||
class PackageRelease(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
package_id = db.Column(db.Integer, db.ForeignKey('package.id'))
|
||||
package_id = db.Column(db.Integer, db.ForeignKey("package.id"))
|
||||
title = db.Column(db.String(100), nullable=False)
|
||||
releaseDate = db.Column(db.DateTime, nullable=False)
|
||||
url = db.Column(db.String(100), nullable=False)
|
||||
|
@ -15,13 +15,13 @@ def domain(url):
|
||||
return urlparse(url).netloc
|
||||
|
||||
# TODO: remove on production!
|
||||
@app.route('/static/<path:path>')
|
||||
@app.route("/static/<path:path>")
|
||||
def send_static(path):
|
||||
return send_from_directory('static', path)
|
||||
return send_from_directory("static", path)
|
||||
|
||||
@app.route('/')
|
||||
@menu.register_menu(app, '.', 'Home')
|
||||
@app.route("/")
|
||||
@menu.register_menu(app, ".", "Home")
|
||||
def home_page():
|
||||
return render_template('index.html')
|
||||
return render_template("index.html")
|
||||
|
||||
from . import users, githublogin, packages
|
||||
|
@ -7,7 +7,7 @@ from app import app, github
|
||||
from app.models import *
|
||||
|
||||
|
||||
@app.route('/user/github/start/')
|
||||
@app.route("/user/github/start/")
|
||||
def github_signin_page():
|
||||
return github.authorize("public_repo,repo")
|
||||
|
||||
@ -28,7 +28,7 @@ def _do_login_user(user, remember_me=False):
|
||||
|
||||
# Check if user account has been disabled
|
||||
if not _call_or_get(user.is_active):
|
||||
flash('Your account has not been enabled.', 'error')
|
||||
flash("Your account has not been enabled.", "error")
|
||||
return False
|
||||
|
||||
# Check if user has a confirmed email address
|
||||
@ -36,15 +36,15 @@ def _do_login_user(user, remember_me=False):
|
||||
if user_manager.enable_email and user_manager.enable_confirm_email \
|
||||
and not current_app.user_manager.enable_login_without_confirm_email \
|
||||
and not user.has_confirmed_email():
|
||||
url = url_for('user.resend_confirm_email')
|
||||
flash("Your email address has not yet been confirmed", 'error')
|
||||
url = url_for("user.resend_confirm_email")
|
||||
flash("Your email address has not yet been confirmed", "error")
|
||||
return False
|
||||
|
||||
# Use Flask-Login to sign in user
|
||||
login_user(user, remember=remember_me)
|
||||
signals.user_logged_in.send(current_app._get_current_object(), user=user)
|
||||
|
||||
flash('You have signed in successfully.', 'success')
|
||||
flash("You have signed in successfully.", "success")
|
||||
|
||||
return True
|
||||
|
||||
@ -59,10 +59,10 @@ def _login_user(user):
|
||||
|
||||
|
||||
|
||||
@app.route('/user/github/callback/')
|
||||
@app.route("/user/github/callback/")
|
||||
@github.authorized_handler
|
||||
def github_authorized(oauth_token):
|
||||
next_url = request.args.get('next')
|
||||
next_url = request.args.get("next")
|
||||
if oauth_token is None:
|
||||
flash("Authorization failed [err=gh-oauth-login-failed]", "danger")
|
||||
return redirect(url_for("user.login"))
|
||||
|
@ -24,24 +24,24 @@ def doPackageList(type):
|
||||
if search is not None:
|
||||
query = query.filter(Package.title.contains(search))
|
||||
|
||||
return render_template('packages.html', title=title, packages=query.all(), query=search)
|
||||
return render_template("packages.html", title=title, packages=query.all(), query=search)
|
||||
|
||||
@app.route('/packages/')
|
||||
@app.route("/packages/")
|
||||
def packages_page():
|
||||
return doPackageList(None)
|
||||
|
||||
@app.route('/mods/')
|
||||
@menu.register_menu(app, '.mods', 'Mods', order=11)
|
||||
@app.route("/mods/")
|
||||
@menu.register_menu(app, ".mods", "Mods", order=11)
|
||||
def mods_page():
|
||||
return doPackageList(PackageType.MOD)
|
||||
|
||||
@app.route('/games/')
|
||||
@menu.register_menu(app, '.games', 'Games', order=12)
|
||||
@app.route("/games/")
|
||||
@menu.register_menu(app, ".games", "Games", order=12)
|
||||
def games_page():
|
||||
return doPackageList(PackageType.GAME)
|
||||
|
||||
@app.route('/texturepacks/')
|
||||
@menu.register_menu(app, '.txp', 'Texture Packs', order=13)
|
||||
@app.route("/texturepacks/")
|
||||
@menu.register_menu(app, ".txp", "Texture Packs", order=13)
|
||||
def txp_page():
|
||||
return doPackageList(PackageType.TXP)
|
||||
|
||||
@ -50,7 +50,7 @@ def canSeeWorkQueue():
|
||||
Permission.APPROVE_RELEASE.check(current_user) or \
|
||||
Permission.APPROVE_CHANGES.check(current_user)
|
||||
|
||||
@menu.register_menu(app, '.todo', "Work Queue", order=20, visible_when=canSeeWorkQueue)
|
||||
@menu.register_menu(app, ".todo", "Work Queue", order=20, visible_when=canSeeWorkQueue)
|
||||
@app.route("/todo/")
|
||||
@login_required
|
||||
def todo_page():
|
||||
@ -65,7 +65,7 @@ def todo_page():
|
||||
if canApproveRel:
|
||||
releases = PackageRelease.query.filter_by(approved=False).all()
|
||||
|
||||
return render_template('todo.html', title="Reports and Work Queue",
|
||||
return render_template("todo.html", title="Reports and Work Queue",
|
||||
approve_new=packages, releases=releases,
|
||||
canApproveNew=canApproveNew, canApproveRel=canApproveRel)
|
||||
|
||||
@ -94,7 +94,7 @@ def package_page(type, author, name):
|
||||
package = getPageByInfo(type, author, name)
|
||||
releases = getReleases(package)
|
||||
|
||||
return render_template('package_details.html', package=package, releases=releases)
|
||||
return render_template("package_details.html", package=package, releases=releases)
|
||||
|
||||
|
||||
class PackageForm(FlaskForm):
|
||||
@ -107,11 +107,11 @@ class PackageForm(FlaskForm):
|
||||
website = StringField("Website URL", [Optional(), URL()])
|
||||
issueTracker = StringField("Issue Tracker URL", [Optional(), URL()])
|
||||
forums = IntegerField("Forum Topic ID", [InputRequired(), NumberRange(0,999999)])
|
||||
submit = SubmitField('Save')
|
||||
submit = SubmitField("Save")
|
||||
|
||||
@menu.register_menu(app, '.new', 'Create', order=21, visible_when=lambda: current_user.is_authenticated)
|
||||
@app.route("/new/", methods=['GET', 'POST'])
|
||||
@app.route("/<type>s/<author>/<name>/edit/", methods=['GET', 'POST'])
|
||||
@menu.register_menu(app, ".new", "Create", order=21, visible_when=lambda: current_user.is_authenticated)
|
||||
@app.route("/new/", methods=["GET", "POST"])
|
||||
@app.route("/<type>s/<author>/<name>/edit/", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def create_edit_package_page(type=None, author=None, name=None):
|
||||
package = None
|
||||
@ -137,7 +137,7 @@ def create_edit_package_page(type=None, author=None, name=None):
|
||||
db.session.commit() # save
|
||||
return redirect(package.getDetailsURL()) # redirect
|
||||
|
||||
return render_template('package_create_edit.html', package=package, form=form)
|
||||
return render_template("package_create_edit.html", package=package, form=form)
|
||||
|
||||
@app.route("/<type>s/<author>/<name>/approve/")
|
||||
@login_required
|
||||
@ -163,16 +163,16 @@ class CreatePackageReleaseForm(FlaskForm):
|
||||
uploadOpt = RadioField ("File", choices=[("vcs", "From VCS Commit or Branch"), ("upload", "File Upload")])
|
||||
vcsLabel = StringField("VCS Commit or Branch", default="master")
|
||||
fileUpload = FileField("File Upload")
|
||||
submit = SubmitField('Save')
|
||||
submit = SubmitField("Save")
|
||||
|
||||
class EditPackageReleaseForm(FlaskForm):
|
||||
name = StringField("Name")
|
||||
title = StringField("Title")
|
||||
url = StringField("URL", [URL])
|
||||
approved = BooleanField("Is Approved")
|
||||
submit = SubmitField('Save')
|
||||
submit = SubmitField("Save")
|
||||
|
||||
@app.route("/<type>s/<author>/<name>/releases/new/", methods=['GET', 'POST'])
|
||||
@app.route("/<type>s/<author>/<name>/releases/new/", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def create_release_page(type, author, name):
|
||||
package = getPageByInfo(type, author, name)
|
||||
@ -193,9 +193,9 @@ def create_release_page(type, author, name):
|
||||
else:
|
||||
raise Exception("Unimplemented option = file upload")
|
||||
|
||||
return render_template('package_release_new.html', package=package, form=form)
|
||||
return render_template("package_release_new.html", package=package, form=form)
|
||||
|
||||
@app.route("/<type>s/<author>/<name>/releases/<id>/", methods=['GET', 'POST'])
|
||||
@app.route("/<type>s/<author>/<name>/releases/<id>/", methods=["GET", "POST"])
|
||||
@login_required
|
||||
def edit_release_page(type, author, name, id):
|
||||
user = User.query.filter_by(username=author).first()
|
||||
@ -233,4 +233,4 @@ def edit_release_page(type, author, name, id):
|
||||
db.session.commit()
|
||||
return redirect(package.getDetailsURL())
|
||||
|
||||
return render_template('package_release_edit.html', package=package, release=release, form=form)
|
||||
return render_template("package_release_edit.html", package=package, release=release, form=form)
|
||||
|
@ -18,14 +18,14 @@ class MyRegisterForm(RegisterForm):
|
||||
# Define the User profile form
|
||||
class UserProfileForm(FlaskForm):
|
||||
display_name = StringField("Display name")
|
||||
submit = SubmitField('Save')
|
||||
submit = SubmitField("Save")
|
||||
|
||||
@app.route('/user/', methods=['GET'])
|
||||
@app.route("/user/", methods=["GET"])
|
||||
@login_required
|
||||
def self_user_profile_page():
|
||||
return redirect(url_for("user_profile_page", username=current_user.username))
|
||||
|
||||
@app.route('/user/<username>/', methods=['GET', 'POST'])
|
||||
@app.route("/user/<username>/", methods=["GET", "POST"])
|
||||
def user_profile_page(username):
|
||||
user = User.query.filter_by(username=username).first()
|
||||
if not user:
|
||||
@ -37,7 +37,7 @@ def user_profile_page(username):
|
||||
form = UserProfileForm(formdata=request.form, obj=current_user)
|
||||
|
||||
# Process valid POST
|
||||
if request.method=='POST' and form.validate():
|
||||
if request.method=="POST" and form.validate():
|
||||
# Copy form fields to user_profile fields
|
||||
form.populate_obj(current_user)
|
||||
|
||||
@ -45,8 +45,8 @@ def user_profile_page(username):
|
||||
db.session.commit()
|
||||
|
||||
# Redirect to home page
|
||||
return redirect(url_for('home_page'))
|
||||
return redirect(url_for("home_page"))
|
||||
|
||||
# Process GET or invalid POST
|
||||
return render_template('users/user_profile_page.html',
|
||||
return render_template("users/user_profile_page.html",
|
||||
user=user, form=form)
|
||||
|
@ -1,3 +1,3 @@
|
||||
from app import app
|
||||
|
||||
app.run(host='0.0.0.0', port=5000, debug=True)
|
||||
app.run(host="127.0.0.1", port=5000, debug=True)
|
||||
|
3
runprod.py
Normal file
3
runprod.py
Normal file
@ -0,0 +1,3 @@
|
||||
from app import app
|
||||
|
||||
app.run(host="0.0.0.0", port=5123, debug=False)
|
5
setup.py
5
setup.py
@ -17,6 +17,11 @@ if not os.path.isfile("db.sqlite"):
|
||||
ruben.rank = UserRank.EDITOR
|
||||
db.session.add(ruben)
|
||||
|
||||
ez = User("Shara")
|
||||
ez.github_username = "Ezhh"
|
||||
ez.rank = UserRank.EDITOR
|
||||
db.session.add(ez)
|
||||
|
||||
jeija = User("Jeija")
|
||||
jeija.github_username = "Jeija"
|
||||
db.session.add(jeija)
|
||||
|
Loading…
Reference in New Issue
Block a user