-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from tbmc/feature_add_response_links
feat: add links in event description
- Loading branch information
Showing
45 changed files
with
761 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -164,3 +164,4 @@ data_*.txt | |
|
||
test/ | ||
docs/ | ||
database.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: test | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
paths-ignore: | ||
- 'docs' | ||
- '**.md' | ||
pull_request: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
test_and_lint: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3.11" | ||
- name: Install requirements | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt | ||
- name: Run Black check | ||
run: black --check . | ||
|
||
- name: Run Mypy | ||
run: mypy . | ||
|
||
- name: Run Pytest | ||
run: pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,3 +161,5 @@ cython_debug/ | |
*.ics | ||
|
||
data_*.txt | ||
database.db | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import string | ||
import random | ||
import hashlib | ||
|
||
from calendar_connector.consts import PRESENCE | ||
|
||
_alphabet = string.printable | ||
|
||
|
||
def generate_salt() -> str: | ||
chars: list[str] = [] | ||
for i in range(random.randint(30, 50)): | ||
chars.append(random.choice(_alphabet)) | ||
return "".join(chars) | ||
|
||
|
||
def generate_hash( | ||
team_id: int | str, | ||
event_id: int | str, | ||
user_id: int | str, | ||
username: str, | ||
password: str, | ||
salt: str, | ||
presence: bool, | ||
) -> str: | ||
presence_str = PRESENCE.present if presence else PRESENCE.absent | ||
to_hash = ( | ||
f"{team_id}:{event_id}:{user_id}:{username}:{password}:{salt}:{presence_str}" | ||
) | ||
m = hashlib.sha3_256(to_hash.encode("utf-8")) | ||
return m.hexdigest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from typing import Optional | ||
|
||
|
||
class AttributeNotFoundException(Exception): | ||
def __init__(self, name: str) -> None: | ||
super().__init__(f"{name} is not found") | ||
|
||
|
||
class BadTokenException(Exception): | ||
def __init__(self) -> None: | ||
super().__init__(f"Your token is not valid") | ||
|
||
|
||
class TooManyUsersException(Exception): | ||
def __init__(self, mail: str, n: Optional[int] = None) -> None: | ||
super().__init__( | ||
f'There are too many users with the same mail "{mail}", this should not happen.' | ||
+ ("" if n is None else f"Number of users {n}.") | ||
) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from calendar_connector.database.user import User | ||
|
||
ALL_MODELS = [User] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from peewee import Model | ||
|
||
from calendar_connector.database.db_connector import get_db | ||
|
||
db = get_db() | ||
|
||
|
||
class BaseModel(Model): | ||
class Meta: | ||
database = db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from peewee import SqliteDatabase | ||
|
||
from calendar_connector.database.db_connector import get_db | ||
from calendar_connector.database.all_models import ALL_MODELS | ||
|
||
|
||
def create_db(db: SqliteDatabase) -> None: | ||
db.create_tables(ALL_MODELS) | ||
|
||
|
||
if __name__ == "__main__": | ||
create_db(get_db()) |
Oops, something went wrong.