]> git.lizzy.rs Git - cheatdb.git/blob - app/default_data.py
Fix typo
[cheatdb.git] / app / default_data.py
1 from .models import *
2 from .utils import make_flask_user_password
3
4
5 def populate(session):
6         admin_user = User("Fleckenstein")
7         admin_user.active = True
8         admin_user.password = make_flask_user_password("tuckfrump")
9         admin_user.github_username = "EliasFleckenstein03"
10         admin_user.forums_username = "Fleckenstein"
11         admin_user.rank = UserRank.ADMIN
12         session.add(admin_user)
13
14         tags = {}
15         for tag in ["Render", "World", "Player", \
16                         "Chat", "Exploit", "Inventory", "Movement", \
17                         "Combat", "Bot", "GUI", \
18                         "MineClone", "Any Game", "CTF", "Minetest Game"]:
19                 row = Tag(tag)
20                 tags[row.name] = row
21                 session.add(row)
22
23         licenses = {}
24         for license in ["GPLv2.1", "GPLv3", "LGPLv2.1", "LGPLv3", "AGPLv2.1", "AGPLv3",
25                                         "Apache", "BSD 3-Clause", "BSD 2-Clause", "CC0", "CC-BY-SA",
26                                         "CC-BY", "MIT", "ZLib", "Other (Free)"]:
27                 row = License(license)
28                 licenses[row.name] = row
29                 session.add(row)
30
31         for license in ["CC-BY-NC-SA", "Other (Non-free)"]:
32                 row = License(license, False)
33                 licenses[row.name] = row
34                 session.add(row)
35
36
37 def populate_test_data(session):
38         licenses = { x.name : x for x in License.query.all() }
39         tags = { x.name : x for x in Tag.query.all() }
40         admin_user = User.query.filter_by(rank=UserRank.ADMIN).first()
41
42         cora = User("cora")
43         cora.github_username = "corarona"
44         cora.rank = UserRank.EDITOR
45         session.add(cora)
46
47         not1 = Notification(admin_user, cora, "Schematicas Approved", "/packages/Fleckenstein/schematicas/")
48         session.add(not1)
49
50         anon5 = User("anon5")
51         anon5.github_username = "anon55555"
52         session.add(anon5)
53
54         mod = Package()
55         mod.state = PackageState.APPROVED
56         mod.name = "perlin"
57         mod.title = "Perlin Terraforming"
58         mod.license = licenses["GPLv3"]
59         mod.media_license = licenses["GPLv3"]
60         mod.type = PackageType.MOD
61         mod.author = admin_user
62         mod.tags.append(tags["world"])
63         mod.tags.append(tags["any_game"])
64         mod.repo = "https://github.com/EliasFleckenstein03/perlin"
65         mod.issueTracker = "https://github.com/EliasFleckenstein03/perlin/issues"
66         mod.short_desc = "A dragonfire CSM that does terraforming automatically using perlin noise."
67         mod.desc = ""
68         session.add(mod)
69
70         rel = PackageRelease()
71         rel.package = mod
72         rel.title = "v1.0.0"
73         rel.url = "https://github.com/EliasFleckenstein03/perlin/archive/master.zip"
74         rel.approved = True
75         session.add(rel)
76
77         mod = Package()
78         mod.state = PackageState.APPROVED
79         mod.name = "warp"
80         mod.title = "Warps"
81         mod.license = licenses["GPLv3"]
82         mod.media_license = licenses["GPLv3"]
83         mod.type = PackageType.MOD
84         mod.author = admin_user
85         mod.tags.append(tags["movement"])
86         mod.tags.append(tags["exploit"])
87         mod.tags.append(tags["gui"])
88         mod.tags.append(tags["any_game"])
89         mod.repo = "https://github.com/EliasFleckenstein03/warp"
90         mod.issueTracker = "https://github.com/EliasFleckenstein03/warp/issues"
91         mod.short_desc = "A dragonfire CSM to set warps in the world and use the teleport exploit."
92         mod.desc = ""
93         session.add(mod)
94
95         rel = PackageRelease()
96         rel.package = mod
97         rel.title = "v1.0.0"
98         rel.url = "https://github.com/EliasFleckenstein03/warp/archive/master.zip"
99         rel.approved = True
100         session.add(rel)
101
102         mod = Package()
103         mod.state = PackageState.APPROVED
104         mod.name = "pathfinding"
105         mod.title = "Pathfinding"
106         mod.license = licenses["GPLv3"]
107         mod.media_license = licenses["GPLv3"]
108         mod.type = PackageType.MOD
109         mod.author = admin_user
110         mod.tags.append(tags["movement"])
111         mod.tags.append(tags["bot"])
112         mod.tags.append(tags["any_game"])
113         mod.repo = "https://github.com/EliasFleckenstein03/pathfinding"
114         mod.issueTracker = "https://github.com/EliasFleckenstein03/pathfinding/issues"
115         mod.short_desc = "A dragonfire CSM that adds .goto command."
116         mod.desc = ""
117         session.add(mod)
118
119         rel = PackageRelease()
120         rel.package = mod
121         rel.title = "v1.0.0"
122         rel.url = "https://github.com/EliasFleckenstein03/pathfinding/archive/master.zip"
123         rel.approved = True
124         session.add(rel)
125
126         mod = Package()
127         mod.state = PackageState.APPROVED
128         mod.name = "schematicas"
129         mod.title = "Schematicas"
130         mod.license = licenses["GPLv3"]
131         mod.media_license = licenses["GPLv3"]
132         mod.type = PackageType.MOD
133         mod.author = admin_user
134         mod.tags.append(tags["world"])
135         mod.tags.append(tags["bot"])
136         mod.tags.append(tags["any_game"])
137         mod.repo = "https://github.com/EliasFleckenstein03/schematicas/"
138         mod.issueTracker = "https://github.com/EliasFleckenstein03/schematicas/issues"
139         mod.short_desc = "Dragonfire CSM for saving structures and building them automatically."
140         mod.desc = ""
141         session.add(mod)
142         
143         rel = PackageRelease()
144         rel.package = mod
145         rel.title = "v1.0.0"
146         rel.url = "https://github.com/EliasFleckenstein03/schematicas/archive/master.zip"
147         rel.approved = True
148         session.add(rel)
149         
150         txp = Package()
151         txp.state = PackageState.APPROVED
152         txp.name = "mc_textures"
153         txp.title = "Minecraft Textures"
154         txp.license = licenses["Other (Non-free)"]
155         txp.media_license = licenses["Other (Non-free)"]
156         txp.type = PackageType.TXP
157         txp.author = admin_user
158         txp.tags.append(tags["mineclone"])
159         txp.repo = "https://github.com/EliasFleckenstein03/mc-textures/"
160         txp.issueTracker = "https://github.com/EliasFleckenstein03/mc-textures/issues"
161         txp.short_desc = "MineClone2 Texture Pack containing the original minecraft textures."
162         txp.desc = ""
163         session.add(txp)
164         
165         rel = PackageRelease()
166         rel.package = txp
167         rel.title = "v1.0.0"
168         rel.url = "https://github.com/EliasFleckenstein03/mc-textures/master.zip"
169         rel.approved = True
170         session.add(rel)
171
172         
173
174         session.commit()
175
176         metas = {}
177         for package in Package.query.filter_by(type=PackageType.MOD).all():
178                 meta = None
179                 try:
180                         meta = metas[package.name]
181                 except KeyError:
182                         meta = MetaPackage(package.name)
183                         session.add(meta)
184                         metas[package.name] = meta
185                 package.provides.append(meta)