Initial commit

This commit is contained in:
augustin64 2022-08-13 16:28:57 +02:00
commit 241b947f92
3 changed files with 75 additions and 0 deletions

9
.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
# cache
**/__pycache__
# config
.vscode
# data
partitioncloud/partitioncloud.db

30
make.sh Executable file
View File

@ -0,0 +1,30 @@
#!/bin/bash
init () {
if [ ! -x partitioncloud/partitioncloud.db ]; then
printf "Souhaitez vous supprimer la base de données existante ? [y/n] "
read -r CONFIRMATION
fi
[[ $CONFIRMATION == y ]] || exit 1
sqlite3 "partitioncloud/partitioncloud.db" '.read partitioncloud/schema.sql'
echo "Base de données initialisée"
}
start () {
flask run
}
usage () {
echo "Usage:"
echo -e "\t$0 init"
echo -e "\t$0 start"
}
if [[ $1 && $(type "$1") = *"is a"*"function"* || $(type "$1") == *"est une fonction"* ]]; then
$1 ${*:2} # Call the function
else
usage
echo $(type "$1")
exit 1
fi;

36
partitioncloud/schema.sql Normal file
View File

@ -0,0 +1,36 @@
DROP TABLE IF EXISTS user;
DROP TABLE IF EXISTS partition;
DROP TABLE IF EXISTS album;
DROP TABLE IF EXISTS contient_partition;
DROP TABLE IF EXISTS contient_user;
CREATE TABLE user (
id INTEGER PRIMARY KEY AUTOINCREMENT,
username TEXT UNIQUE NOT NULL,
password TEXT NOT NULL,
access_level INTEGER NOT NULL DEFAULT 0
);
CREATE TABLE partition (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
author TEXT,
body TEXT
);
CREATE TABLE album (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL
);
CREATE TABLE contient_partition (
partition_id INTEGER NOT NULL,
album_id INTEGER NOT NULL,
PRIMARY KEY (partition_id, album_id)
);
CREATE TABLE contient_user (
user_id INTEGER NOT NULL,
album_id INTEGER NOT NULL,
PRIMARY KEY (user_id, album_id)
);