From 241b947f926848d556da4f723ca52bde031dfa49 Mon Sep 17 00:00:00 2001 From: augustin64 Date: Sat, 13 Aug 2022 16:28:57 +0200 Subject: [PATCH] Initial commit --- .gitignore | 9 +++++++++ make.sh | 30 ++++++++++++++++++++++++++++++ partitioncloud/schema.sql | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+) create mode 100644 .gitignore create mode 100755 make.sh create mode 100644 partitioncloud/schema.sql diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5626294 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# cache +**/__pycache__ + +# config +.vscode + +# data +partitioncloud/partitioncloud.db + diff --git a/make.sh b/make.sh new file mode 100755 index 0000000..ff7e3ad --- /dev/null +++ b/make.sh @@ -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; diff --git a/partitioncloud/schema.sql b/partitioncloud/schema.sql new file mode 100644 index 0000000..7a3ab8a --- /dev/null +++ b/partitioncloud/schema.sql @@ -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) +);