]> git.lizzy.rs Git - cheatdb.git/blob - setup.py
Fix CSRF vulnerability on approve/reject links
[cheatdb.git] / setup.py
1 import os, sys, datetime
2
3 if not "FLASK_CONFIG" in os.environ:
4         os.environ["FLASK_CONFIG"] = "../config.cfg"
5
6 delete_db = len(sys.argv) >= 2 and sys.argv[1].strip() == "-d"
7
8 if delete_db and os.path.isfile("db.sqlite"):
9         os.remove("db.sqlite")
10
11 if not os.path.isfile("db.sqlite"):
12         from app.models import *
13
14         print("Creating database tables...")
15         db.create_all()
16         print("Filling database...")
17
18         ruben = User("rubenwardy")
19         ruben.github_username = "rubenwardy"
20         ruben.forums_username = "rubenwardy"
21         ruben.rank = UserRank.ADMIN
22         db.session.add(ruben)
23
24
25         ez = User("Shara")
26         ez.github_username = "Ezhh"
27         ez.forums_username = "Shara"
28         ez.rank = UserRank.EDITOR
29         db.session.add(ez)
30
31         not1 = Notification(ruben, ez, "Awards approved", "/packages/rubenwardy/awards/")
32         db.session.add(not1)
33
34         jeija = User("Jeija")
35         jeija.github_username = "Jeija"
36         db.session.add(jeija)
37
38         sam = User("fillthisinlater")
39         sam.github_username = "fillthisinlater"
40         sam.rank = UserRank.EDITOR
41         db.session.add(sam)
42
43         tags = {}
44         for tag in ["Inventory", "Mapgen", "Building", \
45                         "Mobs and NPCs", "Tools", "Player effects", \
46                         "Environment", "Transport", "Maintenance", "Plants and farming", \
47                         "PvP", "PvE", "Survival", "Creative", "Puzzle", "Multiplayer", "Singleplayer"]:
48                 row = Tag(tag)
49                 tags[row.name] = row
50                 db.session.add(row)
51
52
53         licenses = {}
54         for license in ["GPLv2.1", "GPLv3", "LGPLv2.1", "LGPLv3", "AGPLv2.1", "AGPLv3",
55                                         "Apache", "BSD 3-Clause", "BSD 2-Clause", "CC0", "CC-BY-SA",
56                                         "CC-BY", "CC-BY-NC-SA", "MIT", "ZLib"]:
57                 row = License(license)
58                 licenses[row.name] = row
59                 db.session.add(row)
60
61
62         mod = Package()
63         mod.approved = True
64         mod.name = "alpha"
65         mod.title = "Alpha Test"
66         mod.license = licenses["MIT"]
67         mod.type = PackageType.MOD
68         mod.author = ruben
69         mod.tags.append(tags["mapgen"])
70         mod.tags.append(tags["environment"])
71         mod.repo = "https://github.com/ezhh/other_worlds"
72         mod.issueTracker = "https://github.com/ezhh/other_worlds/issues"
73         mod.forums = 16015
74         mod.shortDesc = "The content library should not be used yet as it is still in alpha"
75         mod.desc = "This is the long desc"
76         db.session.add(mod)
77
78         rel = PackageRelease()
79         rel.package = mod
80         rel.title = "v1.0.0"
81         rel.url = "https://github.com/ezhh/handholds/archive/master.zip"
82         rel.approved = True
83         db.session.add(rel)
84
85         mod1 = Package()
86         mod1.approved = True
87         mod1.name = "awards"
88         mod1.title = "Awards"
89         mod1.license = licenses["LGPLv2.1"]
90         mod1.type = PackageType.MOD
91         mod1.author = ruben
92         mod1.tags.append(tags["player_effects"])
93         mod1.repo = "https://github.com/rubenwardy/awards"
94         mod1.issueTracker = "https://github.com/rubenwardy/awards/issues"
95         mod1.forums = 4870
96         mod1.shortDesc = "Adds achievements and an API to register new ones."
97         mod1.desc = """
98 Majority of awards are back ported from Calinou's old fork in Carbone, under same license.
99
100 ```
101 awards.register_achievement("award_mesefind",{
102     title = "First Mese Find",
103     description = "Found some Mese!",
104     trigger = {
105         type   = "dig",          -- award is given when
106         node   = "default:mese", -- this type of node has been dug
107         target = 1,              -- this number of times
108     },
109 })
110 ```
111 """
112
113         rel = PackageRelease()
114         rel.package = mod1
115         rel.title = "v1.0.0"
116         rel.url = "https://github.com/rubenwardy/awards/archive/master.zip"
117         rel.approved = True
118         db.session.add(rel)
119
120         mod2 = Package()
121         mod2.approved = True
122         mod2.name = "mesecons"
123         mod2.title = "Mesecons"
124         mod2.tags.append(tags["tools"])
125         mod2.type = PackageType.MOD
126         mod2.license = licenses["LGPLv3"]
127         mod2.author = jeija
128         mod2.repo = "https://github.com/minetest-mods/mesecons/"
129         mod2.issueTracker = "https://github.com/minetest-mods/mesecons/issues"
130         mod2.forums = 628
131         mod2.shortDesc = "Mesecons adds everything digital, from all kinds of sensors, switches, solar panels, detectors, pistons, lamps, sound blocks to advanced digital circuitry like logic gates and programmable blocks."
132         mod2.desc = """
133     ########################################################################
134     ##  __    __   _____   _____   _____   _____   _____   _   _   _____  ##
135     ## |  \  /  | |  ___| |  ___| |  ___| |  ___| |  _  | | \ | | |  ___| ##
136     ## |   \/   | | |___  | |___  | |___  | |     | | | | |  \| | | |___  ##
137     ## | |\__/| | |  ___| |___  | |  ___| | |     | | | | |     | |___  | ##
138     ## | |    | | | |___   ___| | | |___  | |___  | |_| | | |\  |  ___| | ##
139     ## |_|    |_| |_____| |_____| |_____| |_____| |_____| |_| \_| |_____| ##
140     ##                                                                    ##
141     ########################################################################
142
143 MESECONS by Jeija and contributors
144
145 Mezzee-what?
146 ------------
147 [Mesecons](http://mesecons.net/)! They're yellow, they're conductive, and they'll add a whole new dimension to Minetest's gameplay.
148
149 Mesecons is a mod for [Minetest](http://minetest.net/) that implements a ton of items related to digital circuitry, such as wires, buttons, lights, and even programmable controllers. Among other things, there are also pistons, solar panels, pressure plates, and note blocks.
150
151 Mesecons has a similar goal to Redstone in Minecraft, but works in its own way, with different rules and mechanics.
152
153 OK, I want in.
154 --------------
155 Go get it!
156
157 [DOWNLOAD IT NOW](https://github.com/minetest-mods/mesecons/archive/master.zip)
158
159 Now go ahead and install it like any other Minetest mod. Don't know how? Check out [the wonderful page about it](http://wiki.minetest.com/wiki/Mods) over at the Minetest Wiki. For your convenience, here's a quick summary:
160
161 1. If Mesecons is still in a ZIP file, extract the folder inside to somewhere on the computer.
162 2. Make sure that when you open the folder, you can directly find `README.md` in the listing. If you just see another folder, move that folder up one level and delete the old one.
163 3. Open up the Minetest mods folder - usually `/mods/`. If you see the `minetest` or folder inside of that, that is your mod folder instead.
164 4. Copy the Mesecons folder into the mods folder.
165
166 Don't like some parts of Mesecons? Open up the Mesecons folder and delete the subfolder containing the mod you don't want. If you didn't want movestones, for example, all you have to do is delete the `mesecons_movestones` folder and they will no longer be available.
167
168 There are no dependencies - it will work right after installing!
169
170 How do I use this thing?
171 ------------------------
172 How about a [quick overview video](https://www.youtube.com/watch?v=6kmeQj6iW5k)?
173
174 Or maybe a [comprehensive reference](http://mesecons.net/items.html) is your style?
175
176 An overview for the very newest of new beginners? How does [this one](http://uberi.mesecons.net/projects/MeseconsBasics/index.html) look?
177
178 Want to get more into building? Why not check out the [Mesecons Laboratory](http://uberi.mesecons.net/), a website dedicated to advanced Mesecons builders?
179
180 Want to contribute to Mesecons itself? Check out the [source code](https://github.com/minetest-mods/mesecons)!
181
182 Who wrote it anyways?
183 ---------------------
184 These awesome people made Mesecons possible!
185
186 | Contributor     | Contribution                     |
187 | --------------- | -------------------------------- |
188 | Hawk777         | Code for VoxelManip caching      |
189 | Jat15           | Various tweaks.                  |
190 | Jeija           | **Main developer! Everything.**  |
191 | Jordach         | Noteblock sounds.                |
192 | khonkhortistan  | Code, recipes, textures.         |
193 | Kotolegokot     | Nodeboxes for items.             |
194 | minerd247       | Textures.                        |
195 | Nore/Novatux    | Code.                            |
196 | RealBadAngel    | Fixes, improvements.             |
197 | sfan5           | Code, recipes, textures.         |
198 | suzenako        | Piston sounds.                   |
199 | Uberi/Temperest | Code, textures, documentation.   |
200 | VanessaE        | Code, recipes, textures, design. |
201 | Whiskers75      | Logic gates implementation.      |
202
203 There are also a whole bunch of other people helping with everything from code to testing and feedback. Mesecons would also not be possible without their help!
204
205 Alright, how can I use it?
206 --------------------------
207 All textures in this project are licensed under the CC-BY-SA 3.0 (Creative Commons Attribution-ShareAlike 3.0 Generic). That means you can distribute and remix them as much as you want to, under the condition that you give credit to the authors and the project, and that if you remix and release them, they must be under the same or similar license to this one.
208
209 All code in this project is licensed under the LGPL version 3 or later. That means you have unlimited freedom to distribute and modify the work however you see fit, provided that if you decide to distribute it or any modified versions of it, you must also use the same license. The LGPL also grants the additional freedom to write extensions for the software and distribute them without the extensions being subject to the terms of the LGPL, although the software itself retains its license.
210
211 No warranty is provided, express or implied, for any part of the project.
212
213 """
214
215         db.session.add(mod1)
216         db.session.add(mod2)
217
218         mod = Package()
219         mod.approved = True
220         mod.name = "handholds"
221         mod.title = "Mountain Climbing"
222         mod.license = licenses["MIT"]
223         mod.type = PackageType.MOD
224         mod.author = ez
225         mod.tags.append(tags["player_effects"])
226         mod.repo = "https://github.com/ezhh/handholds"
227         mod.issueTracker = "https://github.com/ezhh/handholds/issues"
228         mod.forums = 17069
229         mod.shortDesc = "Adds hand holds and climbing thingies"
230         mod.desc = "This is the long desc"
231         db.session.add(mod)
232
233         rel = PackageRelease()
234         rel.package = mod
235         rel.title = "v1.0.0"
236         rel.url = "https://github.com/ezhh/handholds/archive/master.zip"
237         rel.approved = True
238         db.session.add(rel)
239
240         mod = Package()
241         mod.approved = True
242         mod.name = "other_worlds"
243         mod.title = "Other Worlds"
244         mod.license = licenses["MIT"]
245         mod.type = PackageType.MOD
246         mod.author = ez
247         mod.tags.append(tags["mapgen"])
248         mod.tags.append(tags["environment"])
249         mod.repo = "https://github.com/ezhh/other_worlds"
250         mod.issueTracker = "https://github.com/ezhh/other_worlds/issues"
251         mod.forums = 16015
252         mod.shortDesc = "Adds space with asteroids and comets"
253         mod.desc = "This is the long desc"
254         db.session.add(mod)
255
256         mod = Package()
257         mod.approved = True
258         mod.name = "food"
259         mod.title = "Food"
260         mod.license = licenses["LGPLv2.1"]
261         mod.type = PackageType.MOD
262         mod.author = ruben
263         mod.tags.append(tags["player_effects"])
264         mod.repo = "https://github.com/rubenwardy/food/"
265         mod.issueTracker = "https://github.com/rubenwardy/food/issues/"
266         mod.forums = 2960
267         mod.shortDesc = "Adds lots of food and an API to manage ingredients"
268         mod.desc = "This is the long desc"
269         db.session.add(mod)
270
271         mod = Package()
272         mod.approved = True
273         mod.name = "food_sweet"
274         mod.title = "Sweet Foods"
275         mod.license = licenses["CC0"]
276         mod.type = PackageType.MOD
277         mod.author = ruben
278         mod.tags.append(tags["player_effects"])
279         mod.repo = "https://github.com/rubenwardy/food_sweet/"
280         mod.issueTracker = "https://github.com/rubenwardy/food_sweet/issues/"
281         mod.forums = 9039
282         mod.shortDesc = "Adds sweet food"
283         mod.desc = "This is the long desc"
284         db.session.add(mod)
285
286         game1 = Package()
287         game1.approved = True
288         game1.name = "capturetheflag"
289         game1.title = "Capture The Flag"
290         game1.type = PackageType.GAME
291         game1.license = licenses["LGPLv2.1"]
292         game1.author = ruben
293         game1.tags.append(tags["pvp"])
294         game1.tags.append(tags["survival"])
295         game1.tags.append(tags["multiplayer"])
296         game1.repo = "https://github.com/rubenwardy/capturetheflag"
297         game1.issueTracker = "https://github.com/rubenwardy/capturetheflag/issues"
298         game1.forums = 12835
299         game1.shortDesc = "Two teams battle to snatch and return the enemy's flag, before the enemy takes their own!"
300         game1.desc = """
301 As seen on the Capture the Flag server (minetest.rubenwardy.com:30000)
302
303 Uses the CTF PvP Engine.
304 """
305
306         db.session.add(game1)
307
308         rel = PackageRelease()
309         rel.package = game1
310         rel.title = "v1.0.0"
311         rel.url = "https://github.com/rubenwardy/capturetheflag/archive/master.zip"
312         rel.approved = True
313         db.session.add(rel)
314
315
316         mod = Package()
317         mod.approved = True
318         mod.name = "pixelbox"
319         mod.title = "PixelBOX Reloaded"
320         mod.license = licenses["CC0"]
321         mod.type = PackageType.TXP
322         mod.author = ruben
323         mod.forums = 14132
324         mod.shortDesc = "This is an update of the original PixelBOX texture pack by the brillant artist Gambit"
325         mod.desc = "This is the long desc"
326         db.session.add(mod)
327
328         rel = PackageRelease()
329         rel.package = mod
330         rel.title = "v1.0.0"
331         rel.url = "http://mamadou3.free.fr/Minetest/PixelBOX.zip"
332         rel.approved = True
333         db.session.add(rel)
334
335         db.session.commit()
336 else:
337         print("Database already exists")