contentdb/setup.py

48 lines
1.3 KiB
Python
Raw Normal View History

2018-03-19 19:25:13 +01:00
import os, sys, datetime
2018-03-18 18:43:30 +01:00
2018-03-19 19:25:13 +01:00
delete_db = len(sys.argv) >= 2 and sys.argv[1].strip() == "-d"
2018-03-18 18:43:30 +01:00
2018-03-19 19:08:41 +01:00
if delete_db and os.path.isfile("db.sqlite"):
os.remove("db.sqlite")
2018-03-18 18:43:30 +01:00
2018-03-19 19:08:41 +01:00
if not os.path.isfile("db.sqlite"):
2018-03-18 19:05:53 +01:00
from app.models import *
2018-03-18 18:43:30 +01:00
print("Creating database tables...")
2018-03-18 19:05:53 +01:00
db.create_all()
2018-03-18 18:43:30 +01:00
print("Filling database...")
2018-03-18 19:05:53 +01:00
ruben = User("rubenwardy")
ruben.github_username = "rubenwardy"
db.session.add(ruben)
2018-03-19 19:08:41 +01:00
2018-03-19 19:25:13 +01:00
mod1 = Package()
2018-03-19 19:08:41 +01:00
mod1.name = "awards"
mod1.title = "Awards"
2018-03-20 01:44:47 +01:00
mod1.type = PackageType.MOD
2018-03-19 19:08:41 +01:00
mod1.author = ruben
2018-03-20 03:17:33 +01:00
mod1.shortDesc = "Adds achievements and an API to register new ones."
mod1.desc = """
Majority of awards are back ported from Calinou's old fork in Carbone, under same license.
```
awards.register_achievement("award_mesefind",{
title = "First Mese Find",
description = "Found some Mese!",
trigger = {
type = "dig", -- award is given when
node = "default:mese", -- this type of node has been dug
target = 1, -- this number of times
},
})
```
"""
2018-03-19 19:08:41 +01:00
mod1.repo = "https://github.com/rubenwardy/awards"
mod1.issueTracker = "https://github.com/rubenwardy/awards/issues"
mod1.forums = "https://forum.minetest.net/viewtopic.php?t=4870"
db.session.add(mod1)
2018-03-18 19:05:53 +01:00
db.session.commit()
2018-03-18 18:43:30 +01:00
else:
print("Database already exists")