2018-03-19 18:25:13 +00:00
|
|
|
import os, sys, datetime
|
2018-03-18 17:43:30 +00:00
|
|
|
|
2018-03-19 18:25:13 +00:00
|
|
|
delete_db = len(sys.argv) >= 2 and sys.argv[1].strip() == "-d"
|
2018-03-18 17:43:30 +00:00
|
|
|
|
2018-03-19 18:08:41 +00:00
|
|
|
if delete_db and os.path.isfile("db.sqlite"):
|
|
|
|
os.remove("db.sqlite")
|
2018-03-18 17:43:30 +00:00
|
|
|
|
2018-03-19 18:08:41 +00:00
|
|
|
if not os.path.isfile("db.sqlite"):
|
2018-03-18 18:05:53 +00:00
|
|
|
from app.models import *
|
2018-03-18 17:43:30 +00:00
|
|
|
|
|
|
|
print("Creating database tables...")
|
2018-03-18 18:05:53 +00:00
|
|
|
db.create_all()
|
2018-03-18 17:43:30 +00:00
|
|
|
print("Filling database...")
|
2018-03-18 18:05:53 +00:00
|
|
|
|
|
|
|
ruben = User("rubenwardy")
|
|
|
|
ruben.github_username = "rubenwardy"
|
|
|
|
db.session.add(ruben)
|
2018-03-19 18:08:41 +00:00
|
|
|
|
2018-03-19 18:25:13 +00:00
|
|
|
mod1 = Package()
|
2018-03-19 18:08:41 +00:00
|
|
|
mod1.name = "awards"
|
|
|
|
mod1.title = "Awards"
|
2018-03-20 00:44:47 +00:00
|
|
|
mod1.type = PackageType.MOD
|
2018-03-19 18:08:41 +00:00
|
|
|
mod1.author = ruben
|
2018-03-20 02:17:33 +00: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 18:08:41 +00: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 18:05:53 +00:00
|
|
|
db.session.commit()
|
2018-03-18 17:43:30 +00:00
|
|
|
else:
|
|
|
|
print("Database already exists")
|