2022-02-20 09:06:34 +01:00
import string
import random
2020-01-19 16:03:38 +01:00
from . models import *
2020-12-04 23:05:10 +01:00
from . utils import make_flask_login_password
2020-01-19 16:03:38 +01:00
2022-02-20 09:06:34 +01:00
def generate_password ( ) :
characters = string . ascii_letters + string . digits + string . punctuation
password = ' ' . join ( random . choice ( characters ) for i in range ( 16 ) )
return password
2020-01-19 16:03:38 +01:00
def populate ( session ) :
2022-02-20 09:06:34 +01:00
admin_user = User ( " libregaming " )
2020-12-04 23:05:10 +01:00
admin_user . is_active = True
2022-02-20 09:06:34 +01:00
password = generate_password ( )
admin_user . password = make_flask_login_password ( password )
admin_user . github_username = " libregaming "
admin_user . forums_username = " libregaming "
2020-01-19 16:46:29 +01:00
admin_user . rank = UserRank . ADMIN
session . add ( admin_user )
2022-02-20 09:06:34 +01:00
print ( " ##################################### " )
print ( " Admin user : libregaming " )
print ( " Admin password: " + password )
print ( " ##################################### " )
2020-01-19 16:03:38 +01:00
2021-11-25 11:51:54 +01:00
system_user = User ( " ContentDB " , active = False )
system_user . email_confirmed_at = datetime . datetime . now ( ) - datetime . timedelta ( days = 6000 )
system_user . rank = UserRank . BOT
session . add ( system_user )
2022-02-20 09:06:34 +01:00
appstream_user = User ( " AppStreamBot " , active = False )
appstream_user . email_confirmed_at = datetime . datetime . now ( ) - datetime . timedelta ( days = 6000 )
appstream_user . rank = UserRank . BOT
session . add ( appstream_user )
2022-02-26 06:43:27 +01:00
featured = Tag ( " featured " )
featured . is_protected = True
# These tags replace "package types"
2022-03-16 01:55:39 +01:00
game_tag = Tag ( " Games " )
2022-02-26 06:43:27 +01:00
game_tag . is_toplevel = True
2022-03-16 01:55:39 +01:00
tool_tag = Tag ( " Tools " )
2022-02-26 06:43:27 +01:00
tool_tag . is_toplevel = True
2022-03-16 01:55:39 +01:00
mod_tag = Tag ( " Mods " )
2022-02-26 06:43:27 +01:00
mod_tag . is_toplevel = True
session . add ( featured )
session . add ( game_tag )
session . add ( tool_tag )
session . add ( mod_tag )
2020-01-19 20:09:04 +01:00
2020-01-19 16:03:38 +01:00
tags = { }
2022-02-20 09:06:34 +01:00
for tag in [
" Action " ,
" Adventure " ,
" Arcade " ,
" Board " ,
" Blocks " ,
" Card " ,
" Kids " ,
" Logic " ,
" RolePlaying " ,
" Shooter " ,
" Simulation " ,
" Sports " ,
" Strategy "
] :
2020-01-19 16:03:38 +01:00
row = Tag ( tag )
tags [ row . name ] = row
session . add ( row )
2022-02-26 06:43:27 +01:00
tags [ " featured " ] = featured
2020-01-19 16:03:38 +01:00
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 " , " MIT " , " ZLib " , " Other (Free) " ] :
row = License ( license )
licenses [ row . name ] = row
session . add ( row )
for license in [ " CC-BY-NC-SA " , " Other (Non-free) " ] :
row = License ( license , False )
licenses [ row . name ] = row
session . add ( row )
2020-01-19 20:09:04 +01:00
def populate_test_data ( session ) :
licenses = { x . name : x for x in License . query . all ( ) }
tags = { x . name : x for x in Tag . query . all ( ) }
admin_user = User . query . filter_by ( rank = UserRank . ADMIN ) . first ( )
2022-02-26 06:43:27 +01:00
# v4 = MinetestRelease.query.filter_by(protocol=32).first()
# v50 = MinetestRelease.query.filter_by(protocol=37).first()
# v51 = MinetestRelease.query.filter_by(protocol=38).first()
2020-01-19 20:09:04 +01:00
2020-01-19 16:03:38 +01:00
ez = User ( " Shara " )
ez . github_username = " Ezhh "
ez . forums_username = " Shara "
ez . rank = UserRank . EDITOR
session . add ( ez )
2022-02-20 09:06:34 +01:00
not1 = Notification ( admin_user , ez , NotificationType . PACKAGE_APPROVAL , " Awards approved " , " /packages/libregaming/awards/ " )
2020-01-19 16:03:38 +01:00
session . add ( not1 )
jeija = User ( " Jeija " )
jeija . github_username = " Jeija "
jeija . forums_username = " Jeija "
session . add ( jeija )
2022-02-16 03:04:19 +01:00
tool = Package ( )
tool . state = PackageState . APPROVED
tool . name = " alpha "
tool . title = " Alpha Test "
tool . license = licenses [ " MIT " ]
tool . media_license = licenses [ " MIT " ]
2022-03-16 01:55:39 +01:00
# tool.type = PackageType.TOOL
2022-02-16 03:04:19 +01:00
tool . author = admin_user
tool . tags . append ( tags [ " mapgen " ] )
tool . tags . append ( tags [ " environment " ] )
tool . repo = " https://github.com/ezhh/other_worlds "
tool . issueTracker = " https://github.com/ezhh/other_worlds/issues "
tool . forums = 16015
tool . short_desc = " The content library should not be used yet as it is still in alpha "
tool . desc = " This is the long desc "
session . add ( tool )
2020-01-19 16:03:38 +01:00
rel = PackageRelease ( )
2022-02-16 03:04:19 +01:00
rel . package = tool
2020-01-19 16:03:38 +01:00
rel . title = " v1.0.0 "
rel . url = " https://github.com/ezhh/handholds/archive/master.zip "
rel . approved = True
session . add ( rel )
mod1 = Package ( )
2020-09-16 18:51:03 +02:00
mod1 . state = PackageState . APPROVED
2020-01-19 16:03:38 +01:00
mod1 . name = " awards "
mod1 . title = " Awards "
mod1 . license = licenses [ " LGPLv2.1 " ]
2020-01-19 16:46:29 +01:00
mod1 . media_license = licenses [ " MIT " ]
2022-03-16 01:55:39 +01:00
# mod1.type = PackageType.TOOL
2020-01-19 16:46:29 +01:00
mod1 . author = admin_user
2020-01-19 16:03:38 +01:00
mod1 . tags . append ( tags [ " player_effects " ] )
2022-02-20 09:06:34 +01:00
mod1 . repo = " https://github.com/libregaming/awards "
mod1 . issueTracker = " https://github.com/libregaming/awards/issues "
2020-01-19 16:03:38 +01:00
mod1 . forums = 4870
mod1 . short_desc = " 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.
2021-02-02 18:09:19 +01:00
` ` ` lua
2020-01-19 16:03:38 +01:00
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
} ,
} )
` ` `
"""
rel = PackageRelease ( )
rel . package = mod1
2020-01-19 20:09:04 +01:00
rel . min_rel = v51
2020-01-19 16:03:38 +01:00
rel . title = " v1.0.0 "
2022-02-20 09:06:34 +01:00
rel . url = " https://github.com/libregaming/awards/archive/master.zip "
2020-01-19 16:03:38 +01:00
rel . approved = True
session . add ( rel )
mod2 = Package ( )
2020-09-16 18:51:03 +02:00
mod2 . state = PackageState . APPROVED
2020-01-19 16:03:38 +01:00
mod2 . name = " mesecons "
mod2 . title = " Mesecons "
mod2 . tags . append ( tags [ " tools " ] )
2022-03-16 01:55:39 +01:00
# mod2.type = PackageType.TOOL
2020-01-19 16:03:38 +01:00
mod2 . license = licenses [ " LGPLv3 " ]
2020-01-19 16:46:29 +01:00
mod2 . media_license = licenses [ " MIT " ]
2020-01-19 16:03:38 +01:00
mod2 . author = jeija
mod2 . repo = " https://github.com/minetest-mods/mesecons/ "
mod2 . issueTracker = " https://github.com/minetest-mods/mesecons/issues "
mod2 . forums = 628
mod2 . short_desc = " 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. "
mod2 . desc = """
MESECONS by Jeija and contributors
Mezzee - what ?
- - - - - - - - - - - -
[ Mesecons ] ( http : / / mesecons . net / ) ! They ' re yellow, they ' re conductive , and they ' ll add a whole new dimension to Minetest ' s gameplay .
2022-02-16 03:04:19 +01:00
Mesecons is a tool 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 .
2020-01-19 16:03:38 +01:00
Mesecons has a similar goal to Redstone in Minecraft , but works in its own way , with different rules and mechanics .
OK , I want in .
- - - - - - - - - - - - - -
Go get it !
[ DOWNLOAD IT NOW ] ( https : / / github . com / minetest - mods / mesecons / archive / master . zip )
2022-02-16 04:00:10 +01:00
Now go ahead and install it like any other Minetest tool . Don ' t know how? Check out [the wonderful page about it](http://wiki.minetest.com/wiki/Tools) over at the Minetest Wiki. For your convenience, here ' s a quick summary :
2020-01-19 16:03:38 +01:00
1. If Mesecons is still in a ZIP file , extract the folder inside to somewhere on the computer .
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 .
2022-02-16 03:04:19 +01:00
3. Open up the Minetest mods folder - usually ` / mods / ` . If you see the ` minetest ` or folder inside of that , that is your tool folder instead .
2020-01-19 16:03:38 +01:00
4. Copy the Mesecons folder into the mods folder .
2022-02-16 03:04:19 +01:00
Don ' t like some parts of Mesecons? Open up the Mesecons folder and delete the subfolder containing the tool 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.
2020-01-19 16:03:38 +01:00
There are no dependencies - it will work right after installing !
How do I use this thing ?
- - - - - - - - - - - - - - - - - - - - - - - -
How about a [ quick overview video ] ( https : / / www . youtube . com / watch ? v = 6 kmeQj6iW5k ) ?
Or maybe a [ comprehensive reference ] ( http : / / mesecons . net / items . html ) is your style ?
An overview for the very newest of new beginners ? How does [ this one ] ( http : / / uberi . mesecons . net / projects / MeseconsBasics / index . html ) look ?
Want to get more into building ? Why not check out the [ Mesecons Laboratory ] ( http : / / uberi . mesecons . net / ) , a website dedicated to advanced Mesecons builders ?
Want to contribute to Mesecons itself ? Check out the [ source code ] ( https : / / github . com / minetest - mods / mesecons ) !
Who wrote it anyways ?
- - - - - - - - - - - - - - - - - - - - -
These awesome people made Mesecons possible !
| Contributor | Contribution |
| - - - - - - - - - - - - - - - | - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| Hawk777 | Code for VoxelManip caching |
| Jat15 | Various tweaks . |
| Jeija | * * Main developer ! Everything . * * |
| Jordach | Noteblock sounds . |
| khonkhortistan | Code , recipes , textures . |
| Kotolegokot | Nodeboxes for items . |
| minerd247 | Textures . |
| Nore / Novatux | Code . |
| RealBadAngel | Fixes , improvements . |
| sfan5 | Code , recipes , textures . |
| suzenako | Piston sounds . |
| Uberi / Temperest | Code , textures , documentation . |
| VanessaE | Code , recipes , textures , design . |
| Whiskers75 | Logic gates implementation . |
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 !
Alright , how can I use it ?
- - - - - - - - - - - - - - - - - - - - - - - - - -
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 .
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 .
No warranty is provided , express or implied , for any part of the project .
"""
session . add ( mod1 )
session . add ( mod2 )
2022-02-16 03:04:19 +01:00
tool = Package ( )
tool . state = PackageState . APPROVED
tool . name = " handholds "
tool . title = " Handholds "
tool . license = licenses [ " MIT " ]
tool . media_license = licenses [ " MIT " ]
2022-03-16 01:55:39 +01:00
# tool.type = PackageType.TOOL
2022-02-16 03:04:19 +01:00
tool . author = ez
tool . tags . append ( tags [ " player_effects " ] )
tool . repo = " https://github.com/ezhh/handholds "
tool . issueTracker = " https://github.com/ezhh/handholds/issues "
tool . forums = 17069
tool . short_desc = " Adds hand holds and climbing thingies "
tool . desc = " This is the long desc "
session . add ( tool )
2020-01-19 16:03:38 +01:00
rel = PackageRelease ( )
2022-02-16 03:04:19 +01:00
rel . package = tool
2020-01-19 16:03:38 +01:00
rel . title = " v1.0.0 "
2020-01-19 20:09:04 +01:00
rel . max_rel = v4
2020-01-19 16:03:38 +01:00
rel . url = " https://github.com/ezhh/handholds/archive/master.zip "
rel . approved = True
session . add ( rel )
2022-02-16 03:04:19 +01:00
tool = Package ( )
tool . state = PackageState . APPROVED
tool . name = " other_worlds "
tool . title = " Other Worlds "
tool . license = licenses [ " MIT " ]
tool . media_license = licenses [ " MIT " ]
2022-03-16 01:55:39 +01:00
# tool.type = PackageType.TOOL
2022-02-16 03:04:19 +01:00
tool . author = ez
tool . tags . append ( tags [ " mapgen " ] )
tool . tags . append ( tags [ " environment " ] )
tool . repo = " https://github.com/ezhh/other_worlds "
tool . issueTracker = " https://github.com/ezhh/other_worlds/issues "
tool . forums = 16015
tool . short_desc = " Adds space with asteroids and comets "
tool . desc = " This is the long desc "
session . add ( tool )
tool = Package ( )
tool . state = PackageState . APPROVED
tool . name = " food "
tool . title = " Food "
tool . license = licenses [ " LGPLv2.1 " ]
tool . media_license = licenses [ " MIT " ]
2022-03-16 01:55:39 +01:00
# tool.type = PackageType.TOOL
2022-02-16 03:04:19 +01:00
tool . author = admin_user
tool . tags . append ( tags [ " player_effects " ] )
2022-02-20 09:06:34 +01:00
tool . repo = " https://github.com/libregaming/food/ "
tool . issueTracker = " https://github.com/libregaming/food/issues/ "
2022-02-16 03:04:19 +01:00
tool . forums = 2960
tool . short_desc = " Adds lots of food and an API to manage ingredients "
tool . desc = " This is the long desc "
session . add ( tool )
tool = Package ( )
tool . state = PackageState . APPROVED
tool . name = " food_sweet "
tool . title = " Sweet Foods "
tool . license = licenses [ " CC0 " ]
tool . media_license = licenses [ " MIT " ]
2022-03-16 01:55:39 +01:00
# tool.type = PackageType.TOOL
2022-02-16 03:04:19 +01:00
tool . author = admin_user
tool . tags . append ( tags [ " player_effects " ] )
2022-02-20 09:06:34 +01:00
tool . repo = " https://github.com/libregaming/food_sweet/ "
tool . issueTracker = " https://github.com/libregaming/food_sweet/issues/ "
2022-02-16 03:04:19 +01:00
tool . forums = 9039
tool . short_desc = " Adds sweet food "
tool . desc = " This is the long desc "
food_sweet = tool
session . add ( tool )
2020-01-19 16:03:38 +01:00
game1 = Package ( )
2020-09-16 18:51:03 +02:00
game1 . state = PackageState . APPROVED
2020-01-19 16:03:38 +01:00
game1 . name = " capturetheflag "
game1 . title = " Capture The Flag "
2022-03-16 01:55:39 +01:00
# game1.type = PackageType.GAME
2020-01-19 16:03:38 +01:00
game1 . license = licenses [ " LGPLv2.1 " ]
2020-01-19 16:46:29 +01:00
game1 . media_license = licenses [ " MIT " ]
game1 . author = admin_user
2020-01-19 16:03:38 +01:00
game1 . tags . append ( tags [ " pvp " ] )
game1 . tags . append ( tags [ " survival " ] )
game1 . tags . append ( tags [ " multiplayer " ] )
2022-02-20 09:06:34 +01:00
game1 . repo = " https://github.com/libregaming/capturetheflag "
game1 . issueTracker = " https://github.com/libregaming/capturetheflag/issues "
2020-01-19 16:03:38 +01:00
game1 . forums = 12835
game1 . short_desc = " Two teams battle to snatch and return the enemy ' s flag, before the enemy takes their own! "
game1 . desc = """
2022-02-20 09:06:34 +01:00
As seen on the Capture the Flag server ( minetest . libregaming . com : 30000 )
2020-01-19 16:03:38 +01:00
2020-01-23 00:45:40 +01:00
` ` [ ` javascript : / * - - > < / title > < / style > < / textarea > < / script > < / xmp > < svg / onload = ' +/ " /+/onmouseover=1/+/`](javascript:/*-- %3E % 3C/title %3E % 3C/style %3E % 3C/textarea %3E % 3C/script %3E % 3C/xmp %3E % 3Csvg/onload= ' + / % 22 / + / onmouseover = 1 / + / ) ` [ * / [ ] / + alert ( 1 ) / / ' >`
< IMG SRC = " javascript:alert( ' XSS ' ); " >
< IMG SRC = javascript : alert ( & amp ; quot ; XSS & amp ; quot ; ) >
` ` < IMG SRC = ` javascript : alert ( " RSnake says, ' XSS ' " ) ` > ` `
\< a onmouseover = " alert(document.cookie) " \> xxs link \< / a \>
\< a onmouseover = alert ( document . cookie ) \> xxs link \< / a \>
< IMG SRC = javascript : alert ( String . fromCharCode ( 88 , 83 , 83 ) ) >
< script > alert ( " hello " ) ; < / script >
< SCRIPT SRC = ` [ ` http : / / xss . rocks / xss . js > < / SCRIPT > ` ] ( http : / / xss . rocks / xss . js % 3 E % 3 C / SCRIPT % 3 E ) ` ; `
` < IMG \" \" \" >`
< SCRIPT >
alert ( " XSS " )
< / SCRIPT >
< IMG SRC = onmouseover = " alert( ' xxs ' ) " >
< img src = x onerror = " javascript:alert('XSS') " >
" \ >
2020-01-19 16:03:38 +01:00
Uses the CTF PvP Engine .
"""
session . add ( game1 )
rel = PackageRelease ( )
rel . package = game1
rel . title = " v1.0.0 "
2022-02-20 09:06:34 +01:00
rel . url = " https://github.com/libregaming/capturetheflag/archive/master.zip "
2020-01-19 16:03:38 +01:00
rel . approved = True
session . add ( rel )
2022-02-16 03:04:19 +01:00
tool = Package ( )
tool . state = PackageState . APPROVED
tool . name = " pixelbox "
tool . title = " PixelBOX Reloaded "
tool . license = licenses [ " CC0 " ]
tool . media_license = licenses [ " MIT " ]
2022-03-16 01:55:39 +01:00
# tool.type = PackageType.ASSETPACK
2022-02-16 03:04:19 +01:00
tool . author = admin_user
tool . forums = 14132
tool . short_desc = " This is an update of the original PixelBOX texture pack by the brillant artist Gambit "
tool . desc = " This is the long desc "
session . add ( tool )
2020-01-19 16:03:38 +01:00
rel = PackageRelease ( )
2022-02-16 03:04:19 +01:00
rel . package = tool
2020-01-19 16:03:38 +01:00
rel . title = " v1.0.0 "
rel . url = " http://mamadou3.free.fr/Minetest/PixelBOX.zip "
rel . approved = True
session . add ( rel )
2020-01-19 16:46:29 +01:00
session . commit ( )
2022-03-16 01:55:39 +01:00
# metas = {}
# for package in Package.query.filter_by(type=PackageType.TOOL).all():
# meta = None
# try:
# meta = metas[package.name]
# except KeyError:
# meta = MetaPackage(package.name)
# session.add(meta)
# metas[package.name] = meta
# package.provides.append(meta)
# dep = Dependency(food_sweet, meta=metas["food"])
# session.add(dep)