]> git.lizzy.rs Git - cheatdb.git/blobdiff - setup.py
Add migration to add hard/softdeps to packagepropertykeys
[cheatdb.git] / setup.py
index 3f4925d94ca4f641e8b15407f5f91c72bcf565d7..d910db74b0601a89450307f28e61923da4fd2c7b 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -1,56 +1,66 @@
+# Content DB
+# Copyright (C) 2018  rubenwardy
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
+
+
 import os, sys, datetime
 
 if not "FLASK_CONFIG" in os.environ:
        os.environ["FLASK_CONFIG"] = "../config.cfg"
 
-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")
-
-if not os.path.isfile("db.sqlite"):
-       from app.models import *
+test_data = len(sys.argv) >= 2 and sys.argv[1].strip() == "-t"
 
-       print("Creating database tables...")
-       db.create_all()
-       print("Filling database...")
-
-       ruben = User("rubenwardy")
-       ruben.github_username = "rubenwardy"
-       ruben.rank = UserRank.ADMIN
-       db.session.add(ruben)
+from app.models import *
 
+def defineDummyData(licenses, tags, ruben):
        ez = User("Shara")
        ez.github_username = "Ezhh"
+       ez.forums_username = "Shara"
        ez.rank = UserRank.EDITOR
        db.session.add(ez)
 
+       not1 = Notification(ruben, ez, "Awards approved", "/packages/rubenwardy/awards/")
+       db.session.add(not1)
+
        jeija = User("Jeija")
        jeija.github_username = "Jeija"
        db.session.add(jeija)
 
-       sam = User("fillthisinlater")
-       sam.github_username = "fillthisinlater"
-       sam.rank = UserRank.EDITOR
-       db.session.add(sam)
-
-       tags = {}
-       for tag in ["Inventory", "Mapgen", "Building", \
-                       "Mobs and NPCs", "Tools", "Player effects", \
-                       "Environment", "Transport", "Maintenance", "Plants and farming", \
-                       "PvP", "PvE", "Survival", "Creative", "Puzzle", "Multiplayer", "Singleplayer"]:
-               row = Tag(tag)
-               tags[row.name] = row
-               db.session.add(row)
-
 
+       mod = Package()
+       mod.approved = True
+       mod.name = "alpha"
+       mod.title = "Alpha Test"
+       mod.license = licenses["MIT"]
+       mod.type = PackageType.MOD
+       mod.author = ruben
+       mod.tags.append(tags["mapgen"])
+       mod.tags.append(tags["environment"])
+       mod.repo = "https://github.com/ezhh/other_worlds"
+       mod.issueTracker = "https://github.com/ezhh/other_worlds/issues"
+       mod.forums = 16015
+       mod.shortDesc = "The content library should not be used yet as it is still in alpha"
+       mod.desc = "This is the long desc"
+       db.session.add(mod)
 
-       licenses = {}
-       for license in ["LGPLv2.1", "LGPLv3", "GPLv2.1", "GPLv3", "AGPLv2.1", "AGPLv3",
-                                       "MIT", "Apache", "BSD", "ZLib", "CC0", "CC-BY-SA", "CC-BY", "CC-BY-NC-SA"]:
-               row = License(license)
-               licenses[row.name] = row
-               db.session.add(row)
+       rel = PackageRelease()
+       rel.package = mod
+       rel.title = "v1.0.0"
+       rel.url = "https://github.com/ezhh/handholds/archive/master.zip"
+       rel.approved = True
+       db.session.add(rel)
 
        mod1 = Package()
        mod1.approved = True
@@ -188,7 +198,7 @@ No warranty is provided, express or implied, for any part of the project.
        mod = Package()
        mod.approved = True
        mod.name = "handholds"
-       mod.title = "Mountain Climbing"
+       mod.title = "Handholds"
        mod.license = licenses["MIT"]
        mod.type = PackageType.MOD
        mod.author = ez
@@ -236,6 +246,7 @@ No warranty is provided, express or implied, for any part of the project.
        mod.forums = 2960
        mod.shortDesc = "Adds lots of food and an API to manage ingredients"
        mod.desc = "This is the long desc"
+       food = mod
        db.session.add(mod)
 
        mod = Package()
@@ -244,6 +255,7 @@ No warranty is provided, express or implied, for any part of the project.
        mod.title = "Sweet Foods"
        mod.license = licenses["CC0"]
        mod.type = PackageType.MOD
+       mod.harddeps.append(food)
        mod.author = ruben
        mod.tags.append(tags["player_effects"])
        mod.repo = "https://github.com/rubenwardy/food_sweet/"
@@ -275,7 +287,66 @@ Uses the CTF PvP Engine.
 
        db.session.add(game1)
 
+       rel = PackageRelease()
+       rel.package = game1
+       rel.title = "v1.0.0"
+       rel.url = "https://github.com/rubenwardy/capturetheflag/archive/master.zip"
+       rel.approved = True
+       db.session.add(rel)
+
+
+       mod = Package()
+       mod.approved = True
+       mod.name = "pixelbox"
+       mod.title = "PixelBOX Reloaded"
+       mod.license = licenses["CC0"]
+       mod.type = PackageType.TXP
+       mod.author = ruben
+       mod.forums = 14132
+       mod.shortDesc = "This is an update of the original PixelBOX texture pack by the brillant artist Gambit"
+       mod.desc = "This is the long desc"
+       db.session.add(mod)
+
+       rel = PackageRelease()
+       rel.package = mod
+       rel.title = "v1.0.0"
+       rel.url = "http://mamadou3.free.fr/Minetest/PixelBOX.zip"
+       rel.approved = True
+       db.session.add(rel)
+
+
+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")
 
-       db.session.commit()
-else:
-       print("Database already exists")
+print("Creating database tables...")
+db.create_all()
+print("Filling database...")
+
+ruben = User("rubenwardy")
+ruben.github_username = "rubenwardy"
+ruben.forums_username = "rubenwardy"
+ruben.rank = UserRank.ADMIN
+db.session.add(ruben)
+
+tags = {}
+for tag in ["Inventory", "Mapgen", "Building", \
+               "Mobs and NPCs", "Tools", "Player effects", \
+               "Environment", "Transport", "Maintenance", "Plants and farming", \
+               "PvP", "PvE", "Survival", "Creative", "Puzzle", "Multiplayer", "Singleplayer"]:
+       row = Tag(tag)
+       tags[row.name] = row
+       db.session.add(row)
+
+licenses = {}
+for license in ["GPLv2.1", "GPLv3", "LGPLv2.1", "LGPLv3", "AGPLv2.1", "AGPLv3",
+                               "Apache", "BSD 3-Clause", "BSD 2-Clause", "CC0", "CC-BY-SA",
+                               "CC-BY", "CC-BY-NC-SA", "MIT", "ZLib"]:
+       row = License(license)
+       licenses[row.name] = row
+       db.session.add(row)
+
+if test_data:
+       defineDummyData(licenses, tags, ruben)
+
+db.session.commit()