rest of files, not sorted
This commit is contained in:
4266
docs - Kopie/database.html
Normal file
4266
docs - Kopie/database.html
Normal file
File diff suppressed because it is too large
Load Diff
327
docs - Kopie/database.md
Normal file
327
docs - Kopie/database.md
Normal file
@@ -0,0 +1,327 @@
|
||||
Module database
|
||||
===============
|
||||
|
||||
Classes
|
||||
-------
|
||||
|
||||
`Database(db_path: str = None)`
|
||||
: Initialize the database and create the tables if they do not exist.
|
||||
|
||||
Default constructor for the database class
|
||||
|
||||
Args:
|
||||
db_path (str, optional): Optional Path for testing / specific purposes. Defaults to None.
|
||||
|
||||
### Methods
|
||||
|
||||
`addBookToDatabase(self, bookdata: src.logic.dataclass.BookData, app_id: str, prof_id: str)`
|
||||
: Add books to the database. Both app_id and prof_id are required to add the book to the database, as the app_id and prof_id are used to select the books later on.
|
||||
|
||||
Args:
|
||||
bookdata (BookData): The metadata of the book to be added
|
||||
app_id (str): The apparat id where the book should be added to
|
||||
prof_id (str): The id of the professor where the book should be added to.
|
||||
|
||||
`addMessage(self, message: dict, user, appnr)`
|
||||
:
|
||||
|
||||
`changePassword(self, user, new_password)`
|
||||
:
|
||||
|
||||
`checkApparatExists(self, apparat_name)`
|
||||
:
|
||||
|
||||
`checkApparatExistsById(self, apparat_id)`
|
||||
:
|
||||
|
||||
`checkUsername(self, user)`
|
||||
:
|
||||
|
||||
`close_connection(self, conn: sqlite3.Connection)`
|
||||
: closes the connection to the database
|
||||
|
||||
Args:
|
||||
----
|
||||
- conn (sql.Connection): the connection to be closed
|
||||
|
||||
`connect(self) ‑> sqlite3.Connection`
|
||||
: Connect to the database
|
||||
|
||||
Returns:
|
||||
sql.Connection: The active connection to the database
|
||||
|
||||
`createApparat(self, apparat: src.logic.dataclass.ApparatData) ‑> Union[src.errors.DatabaseErrors.AppPresentError, ForwardRef(None), int]`
|
||||
:
|
||||
|
||||
`createProf(self, prof_details: dict)`
|
||||
:
|
||||
|
||||
`createUser(self, user, password, role, salt)`
|
||||
: Create a user based on passed data.
|
||||
|
||||
Args:
|
||||
----
|
||||
- username (str): Username to be used
|
||||
- password (str): the salted password
|
||||
- role (str): Role of the user
|
||||
- salt (str): a random salt for the user
|
||||
|
||||
`create_tables(self)`
|
||||
: Create the tables in the database
|
||||
|
||||
`deleteApparat(self, appnr, semester)`
|
||||
:
|
||||
|
||||
`deleteBook(self, book_id)`
|
||||
: Delete a book from the database
|
||||
|
||||
Args:
|
||||
book_id (str): ID of the book
|
||||
|
||||
`deleteMessage(self, message_id)`
|
||||
:
|
||||
|
||||
`deleteUser(self, user)`
|
||||
:
|
||||
|
||||
`getAllAparats(self, deleted=0)`
|
||||
:
|
||||
|
||||
`getApparatCountBySemester(self) ‑> tuple[list[str], list[int]]`
|
||||
:
|
||||
|
||||
`getApparatData(self, appnr, appname) ‑> src.logic.dataclass.ApparatData`
|
||||
:
|
||||
|
||||
`getApparatId(self, apparat_name)`
|
||||
:
|
||||
|
||||
`getApparatName(self, app_id, prof_id)`
|
||||
:
|
||||
|
||||
`getApparatsByProf(self, prof_id: int) ‑> list[tuple]`
|
||||
:
|
||||
|
||||
`getApparatsBySemester(self, semester: str) ‑> dict`
|
||||
:
|
||||
|
||||
`getBlob(self, filename, app_id)`
|
||||
: Get a blob from the database
|
||||
|
||||
Args:
|
||||
filename (str): The name of the file
|
||||
app_id (str): ID of the apparat
|
||||
|
||||
Returns:
|
||||
bytes: The file stored in
|
||||
|
||||
`getBook(self, book_id: int) ‑> src.logic.dataclass.BookData`
|
||||
: Get the book based on the id in the database
|
||||
|
||||
Args:
|
||||
book_id (int): The id of the book
|
||||
|
||||
Returns:
|
||||
BookData: The metadata of the book wrapped in a BookData object
|
||||
|
||||
`getBookBasedOnSignature(self, app_id: str, prof_id: str, signature: str) ‑> src.logic.dataclass.BookData`
|
||||
: Get the book based on the signature of the book.
|
||||
|
||||
Args:
|
||||
app_id (str): The apparat id the book should be associated with
|
||||
prof_id (str): The professor id the book should be associated with
|
||||
signature (str): The signature of the book
|
||||
|
||||
Returns:
|
||||
BookData: The total metadata of the book wrapped in a BookData object
|
||||
|
||||
`getBookId(self, bookdata: src.logic.dataclass.BookData, app_id, prof_id) ‑> int`
|
||||
: Get the id of a book based on the metadata of the book
|
||||
|
||||
Args:
|
||||
bookdata (BookData): The wrapped metadata of the book
|
||||
app_id (str): The apparat id the book should be associated with
|
||||
prof_id (str): The professor id the book should be associated with
|
||||
|
||||
Returns:
|
||||
int: ID of the book
|
||||
|
||||
`getBookIdBasedOnSignature(self, app_id: str, prof_id: str, signature: str) ‑> int`
|
||||
: Get a book id based on the signature of the book.
|
||||
|
||||
Args:
|
||||
app_id (str): The apparat id the book should be associated with
|
||||
prof_id (str): The professor id the book should be associated with
|
||||
signature (str): The signature of the book
|
||||
|
||||
Returns:
|
||||
int: The id of the book
|
||||
|
||||
`getBooks(self, app_id, prof_id, deleted=0) ‑> list[dict[int, src.logic.dataclass.BookData, int]]`
|
||||
: Get the Books based on the apparat id and the professor id
|
||||
|
||||
Args:
|
||||
app_id (str): The ID of the apparat
|
||||
prof_id (str): The ID of the professor
|
||||
deleted (int, optional): The state of the book. Set to 1 to include deleted ones. Defaults to 0.
|
||||
|
||||
Returns:
|
||||
list[dict[int, BookData, int]]: A list of dictionaries containing the id, the metadata of the book and the availability of the book
|
||||
|
||||
`getFacultyMember(self, name: str)`
|
||||
:
|
||||
|
||||
`getFacultyMembers(self)`
|
||||
:
|
||||
|
||||
`getFiles(self, app_id: int, prof_id: int) ‑> list[tuple]`
|
||||
:
|
||||
|
||||
`getLastBookId(self) ‑> int`
|
||||
: Get the last book id in the database
|
||||
|
||||
Returns:
|
||||
int: ID of the last book in the database
|
||||
|
||||
`getMessages(self, date: str)`
|
||||
:
|
||||
|
||||
`getProfByName(self, prof_name: str)`
|
||||
:
|
||||
|
||||
`getProfData(self, profname: str)`
|
||||
:
|
||||
|
||||
`getProfId(self, prof_name: str)`
|
||||
: getProfId _summary_
|
||||
|
||||
:param prof_name: _description_
|
||||
:type prof_name: str
|
||||
:return: _description_
|
||||
:rtype: _type_
|
||||
|
||||
`getProfNameById(self, prof_id: int, add_title: bool = False)`
|
||||
:
|
||||
|
||||
`getProfs(self)`
|
||||
:
|
||||
|
||||
`getRole(self, user)`
|
||||
:
|
||||
|
||||
`getRoles(self)`
|
||||
:
|
||||
|
||||
`getSemersters(self)`
|
||||
:
|
||||
|
||||
`getSpecificProfData(self, prof_id: int, fields: List[str])`
|
||||
: getSpecificProfData _summary_
|
||||
|
||||
|
||||
|
||||
Args:
|
||||
----
|
||||
- prof_id (int): _description_
|
||||
- fields (List[str]): _description_
|
||||
|
||||
Returns:
|
||||
-------
|
||||
- _type_: _description_
|
||||
|
||||
`getSubjects(self)`
|
||||
:
|
||||
|
||||
`getTitleById(self, prof_id: int)`
|
||||
:
|
||||
|
||||
`getUnavailableApparatNumbers(self) ‑> List[int]`
|
||||
: getUnavailableApparatNumbers returns a list of all currently used ApparatNumbers
|
||||
|
||||
|
||||
|
||||
Returns:
|
||||
-------
|
||||
- number(List[int]): a list of all currently used apparat numbers
|
||||
|
||||
`getUser(self)`
|
||||
:
|
||||
|
||||
`getUsers(self)`
|
||||
:
|
||||
|
||||
`get_db_contents(self) ‑> Optional[List[Tuple]]`
|
||||
: Get the contents of the
|
||||
|
||||
Returns:
|
||||
Union[List[Tuple], None]: _description_
|
||||
|
||||
`insertFile(self, file: list[dict], app_id: int, prof_id)`
|
||||
:
|
||||
|
||||
`insertInto(self, query: str, params: Tuple) ‑> None`
|
||||
: Insert sent data into the database
|
||||
|
||||
Args:
|
||||
query (str): The query to be executed
|
||||
params (Tuple): the parameters to be inserted into the database
|
||||
|
||||
`isEternal(self, id)`
|
||||
:
|
||||
|
||||
`login(self, user, hashed_password)`
|
||||
:
|
||||
|
||||
`query_db(self, query: str, args: Tuple = (), one: bool = False) ‑> Union[Tuple, List[Tuple]]`
|
||||
: Query the Database for the sent query.
|
||||
|
||||
Args:
|
||||
query (str): The query to be executed
|
||||
args (Tuple, optional): The arguments for the query. Defaults to ().
|
||||
one (bool, optional): Return the first result only. Defaults to False.
|
||||
|
||||
Returns:
|
||||
Union[Typle|List[Tuple]]: Returns the result of the query
|
||||
|
||||
`recreateFile(self, filename, app_id, filetype)`
|
||||
:
|
||||
|
||||
`searchBook(self, data: dict[str, str]) ‑> list[tuple[src.logic.dataclass.BookData, int]]`
|
||||
: Search a book in the database based on the sent data.
|
||||
|
||||
Args:
|
||||
data (dict[str, str]): A dictionary containing the data to be searched for. The dictionary can contain the following:
|
||||
- signature: The signature of the book
|
||||
- title: The title of the book
|
||||
|
||||
Returns:
|
||||
list[tuple[BookData, int]]: A list of tuples containing the wrapped Metadata and the id of the book
|
||||
|
||||
`setAvailability(self, book_id: str, available: str)`
|
||||
: Set the availability of a book in the database
|
||||
|
||||
Args:
|
||||
book_id (str): The id of the book
|
||||
available (str): The availability of the book
|
||||
|
||||
`setNewSemesterDate(self, appnr, newDate, dauerapp=False)`
|
||||
:
|
||||
|
||||
`statistic_request(self, **kwargs: Any)`
|
||||
:
|
||||
|
||||
`updateApparat(self, apparat_data: src.logic.dataclass.ApparatData)`
|
||||
:
|
||||
|
||||
`updateBookdata(self, book_id, bookdata: src.logic.dataclass.BookData)`
|
||||
: Update the bookdata in the database
|
||||
|
||||
Args:
|
||||
book_id (str): The id of the book
|
||||
bookdata (BookData): The new metadata of the book
|
||||
|
||||
`updateFacultyMember(self, data, oldlname, oldfname)`
|
||||
:
|
||||
|
||||
`updateUser(self, username, data: dict[str, str])`
|
||||
:
|
||||
132
docs - Kopie/db.html
Normal file
132
docs - Kopie/db.html
Normal file
@@ -0,0 +1,132 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
|
||||
<meta name="generator" content="pdoc 0.10.0" />
|
||||
<title>db API documentation</title>
|
||||
<meta name="description" content="" />
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
|
||||
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
|
||||
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
|
||||
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
|
||||
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
|
||||
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
|
||||
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
|
||||
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
|
||||
</head>
|
||||
<body>
|
||||
<main>
|
||||
<article id="content">
|
||||
<header>
|
||||
<h1 class="title">Module <code>db</code></h1>
|
||||
</header>
|
||||
<section>
|
||||
<p>Module <code>db</code> provides the database schema for the semesterapparat application.</p>
|
||||
</section>
|
||||
<section id="section-intro">
|
||||
<details class="source" open="">
|
||||
<summary>
|
||||
<span>Expand source code</span>
|
||||
</summary>
|
||||
<pre><code class="python">CREATE_TABLE_APPARAT = """CREATE TABLE semesterapparat (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
name TEXT,
|
||||
prof_id INTEGER,
|
||||
fach TEXT,
|
||||
appnr INTEGER,
|
||||
erstellsemester TEXT,
|
||||
verlängert_am TEXT,
|
||||
dauer BOOLEAN,
|
||||
verlängerung_bis TEXT,
|
||||
deletion_status INTEGER,
|
||||
deleted_date TEXT,
|
||||
apparat_id_adis INTEGER,
|
||||
prof_id_adis INTEGER,
|
||||
konto INTEGER REFERENCES app_kontos (id),
|
||||
FOREIGN KEY (prof_id) REFERENCES prof (id)
|
||||
)"""
|
||||
CREATE_TABLE_MEDIA = """CREATE TABLE media (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
bookdata BLOB,
|
||||
app_id INTEGER,
|
||||
prof_id INTEGER,
|
||||
deleted INTEGER DEFAULT (0),
|
||||
available BOOLEAN,
|
||||
reservation BOOLEAN,
|
||||
FOREIGN KEY (prof_id) REFERENCES prof (id),
|
||||
FOREIGN KEY (app_id) REFERENCES semesterapparat (id)
|
||||
)"""
|
||||
CREATE_TABLE_APPKONTOS = """CREATE TABLE app_kontos (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
app_id INTEGER,
|
||||
konto INTEGER,
|
||||
passwort TEXT,
|
||||
FOREIGN KEY (app_id) REFERENCES semesterapparat (id)
|
||||
)"""
|
||||
CREATE_TABLE_FILES = """CREATE TABLE files (
|
||||
id INTEGER PRIMARY KEY,
|
||||
filename TEXT,
|
||||
fileblob BLOB,
|
||||
app_id INTEGER,
|
||||
filetyp TEXT,
|
||||
prof_id INTEGER REFERENCES prof (id),
|
||||
FOREIGN KEY (app_id) REFERENCES semesterapparat (id)
|
||||
)"""
|
||||
CREATE_TABLE_MESSAGES = """CREATE TABLE messages (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
created_at date NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
message TEXT NOT NULL,
|
||||
remind_at date NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
user_id INTEGER NOT NULL,
|
||||
appnr INTEGER,
|
||||
FOREIGN KEY (user_id) REFERENCES user (id)
|
||||
)"""
|
||||
CREATE_TABLE_PROF = """CREATE TABLE prof (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
titel TEXT,
|
||||
fname TEXT,
|
||||
lname TEXT,
|
||||
fullname TEXT NOT NULL UNIQUE,
|
||||
mail TEXT,
|
||||
telnr TEXT
|
||||
)"""
|
||||
CREATE_TABLE_USER = """CREATE TABLE user (
|
||||
id integer NOT NULL PRIMARY KEY AUTOINCREMENT,
|
||||
created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
username TEXT NOT NULL UNIQUE,
|
||||
password TEXT NOT NULL,
|
||||
salt TEXT NOT NULL,
|
||||
role TEXT NOT NULL,
|
||||
email TEXT UNIQUE,
|
||||
name TEXT
|
||||
)"""
|
||||
CREATE_TABLE_SUBJECTS = """CREATE TABLE subjects (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
name TEXT NOT NULL UNIQUE
|
||||
)"""</code></pre>
|
||||
</details>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
<section>
|
||||
</section>
|
||||
</article>
|
||||
<nav id="sidebar">
|
||||
<h1>Index</h1>
|
||||
<div class="toc">
|
||||
<ul></ul>
|
||||
</div>
|
||||
<ul id="index">
|
||||
</ul>
|
||||
</nav>
|
||||
</main>
|
||||
<footer id="footer">
|
||||
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
|
||||
</footer>
|
||||
</body>
|
||||
</html>
|
||||
0
docs - Kopie/db.md
Normal file
0
docs - Kopie/db.md
Normal file
18
docs - Kopie/index.md
Normal file
18
docs - Kopie/index.md
Normal file
@@ -0,0 +1,18 @@
|
||||
# Welcome to MkDocs
|
||||
|
||||
For full documentation visit [mkdocs.org](https://www.mkdocs.org).
|
||||
|
||||
## Commands
|
||||
|
||||
* `mkdocs new [dir-name]` - Create a new project.
|
||||
* `mkdocs serve` - Start the live-reloading docs server.
|
||||
* `mkdocs build` - Build the documentation site.
|
||||
* `mkdocs -h` - Print help message and exit.
|
||||
|
||||
## Project layout
|
||||
|
||||
mkdocs.yml # The configuration file.
|
||||
docs/
|
||||
index.md # The documentation homepage.
|
||||
database.md # Documentation of the Database and it's tables
|
||||
... # Other markdown pages, images and other files.
|
||||
Reference in New Issue
Block a user