mirror of
https://github.com/minetest/contentdb.git
synced 2025-01-03 19:57:29 +01:00
Rename mod to package, add README
This commit is contained in:
parent
358fc4e5da
commit
ae600582a0
31
README.md
Normal file
31
README.md
Normal file
@ -0,0 +1,31 @@
|
||||
# Content Database
|
||||
|
||||
## Setup
|
||||
|
||||
First create a Python virtual env:
|
||||
|
||||
virtualenv env
|
||||
source env/bin/activate
|
||||
|
||||
then use pip:
|
||||
|
||||
pip install -r requirements.txt
|
||||
|
||||
## Running
|
||||
|
||||
You need to enter the virtual environment if you haven't yet in
|
||||
the current session:
|
||||
|
||||
source env/bin/activate
|
||||
|
||||
Reset the database like so:
|
||||
|
||||
python setup.py -d
|
||||
|
||||
Then run the server:
|
||||
|
||||
python rundebug.py
|
||||
|
||||
Then view in your web browser:
|
||||
|
||||
http://localhost:5000/
|
@ -35,7 +35,7 @@ class User(db.Model, UserMixin):
|
||||
display_name = db.Column(db.String(100), nullable=False, server_default='')
|
||||
|
||||
# Content
|
||||
mods = db.relationship('Mod', backref='author', lazy='dynamic')
|
||||
packages = db.relationship('Package', backref='author', lazy='dynamic')
|
||||
|
||||
def __init__(self, username):
|
||||
import datetime
|
||||
@ -57,7 +57,7 @@ class UserRoles(db.Model):
|
||||
user_id = db.Column(db.Integer(), db.ForeignKey('user.id', ondelete='CASCADE'))
|
||||
role_id = db.Column(db.Integer(), db.ForeignKey('role.id', ondelete='CASCADE'))
|
||||
|
||||
class Mod(db.Model):
|
||||
class Package(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
|
||||
# Basic details
|
||||
|
@ -7,12 +7,12 @@ from app.models import *
|
||||
@app.route('/mods/')
|
||||
@menu.register_menu(app, '.mods', 'Mods')
|
||||
def mods_page():
|
||||
packages = Mod.query.all()
|
||||
packages = Package.query.all()
|
||||
return render_template('packages.html', title="Mods", packages=packages)
|
||||
|
||||
@app.route("/<type>s/<author>/<name>/")
|
||||
def package_page(type, author, name):
|
||||
package = Mod.query.filter_by(name=name).first()
|
||||
package = Package.query.filter_by(name=name).first()
|
||||
if package is None:
|
||||
abort(404)
|
||||
|
6
setup.py
6
setup.py
@ -1,6 +1,6 @@
|
||||
import os, datetime
|
||||
import os, sys, datetime
|
||||
|
||||
delete_db = False
|
||||
delete_db = len(sys.argv) >= 2 and sys.argv[1].strip() == "-d"
|
||||
|
||||
if delete_db and os.path.isfile("db.sqlite"):
|
||||
os.remove("db.sqlite")
|
||||
@ -16,7 +16,7 @@ if not os.path.isfile("db.sqlite"):
|
||||
ruben.github_username = "rubenwardy"
|
||||
db.session.add(ruben)
|
||||
|
||||
mod1 = Mod()
|
||||
mod1 = Package()
|
||||
mod1.name = "awards"
|
||||
mod1.title = "Awards"
|
||||
mod1.author = ruben
|
||||
|
Loading…
Reference in New Issue
Block a user