-
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 #8 from 3nd3r1/main
v1.0.0
- Loading branch information
Showing
54 changed files
with
2,410 additions
and
572 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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,42 @@ | ||
"""protaskinate/entities/activity_log.py""" | ||
|
||
from dataclasses import dataclass | ||
from datetime import datetime | ||
from enum import Enum | ||
from typing import TypedDict | ||
|
||
from protaskinate.utils.validation import validate_enum, validate_type | ||
|
||
|
||
class ActivityLogAction(Enum): | ||
"""Enumeration representing the action of an activity log""" | ||
|
||
CREATE_TASK = "create_task" | ||
UPDATE_TASK = "update_task" | ||
DELETE_TASK = "delete_task" | ||
UPDATE_PROJECT = "update_project" | ||
|
||
class NewActivityLog(TypedDict): | ||
"""Type representing the data required to create a new activity log""" | ||
|
||
user_id: int | ||
project_id: int | ||
created_at: datetime | ||
action: ActivityLogAction | ||
|
||
@dataclass | ||
class ActivityLog: | ||
"""Class representing an activity log""" | ||
|
||
id: int | ||
user_id: int | ||
project_id: int | ||
created_at: datetime | ||
action: ActivityLogAction | ||
|
||
def __post_init__(self): | ||
validate_type(self.id, int, "id") | ||
validate_type(self.user_id, int, "user_id") | ||
validate_type(self.project_id, int, "project_id") | ||
validate_type(self.created_at, datetime, "created_at") | ||
self.action = validate_enum(self.action, ActivityLogAction, "action") |
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ | |
@dataclass | ||
class Comment: | ||
"""Class representing a comment""" | ||
|
||
id: int | ||
task_id: int | ||
creator_id: int | ||
|
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 |
---|---|---|
@@ -1,21 +1,61 @@ | ||
"""protaskinate/entities/project.py""" | ||
|
||
from dataclasses import dataclass | ||
from datetime import datetime | ||
from enum import Enum | ||
from typing import Optional | ||
|
||
from protaskinate.entities.user import User | ||
from protaskinate.utils.validation import validate_enum, validate_type | ||
|
||
|
||
class ProjectRole(Enum): | ||
"""Enumeration representing the role of a user in a project""" | ||
|
||
READER = "reader" | ||
WRITER = "writer" | ||
ADMIN = "admin" | ||
|
||
|
||
@dataclass | ||
class Project: | ||
"""Class representing a project""" | ||
|
||
id: int | ||
name: str | ||
creator_id: int | ||
created_at: datetime | ||
updated_at: datetime | ||
description: Optional[str] = None | ||
|
||
def __post_init__(self): | ||
if not isinstance(self.id, int): | ||
raise ValueError(f"Invalid id: {self.id}") | ||
validate_type(self.id, int, "id") | ||
validate_type(self.name, str, "name") | ||
validate_type(self.creator_id, int, "creator_id") | ||
validate_type(self.created_at, datetime, "created_at") | ||
validate_type(self.updated_at, datetime, "updated_at") | ||
validate_type(self.description, str, "description", allow_none=True) | ||
|
||
|
||
@dataclass | ||
class ProjectWithRole: | ||
"""Class representing a project with the current user's role""" | ||
|
||
if not isinstance(self.name, str): | ||
raise ValueError(f"Invalid name: {self.name}") | ||
project: Project | ||
role: ProjectRole | ||
|
||
if not isinstance(self.creator_id, int): | ||
raise ValueError(f"Invalid creator_id: {self.creator_id}") | ||
def __post_init__(self): | ||
validate_type(self.project, Project, "project") | ||
self.role = validate_enum(self.role, ProjectRole, "role") | ||
|
||
|
||
@dataclass | ||
class ProjectUser: | ||
"""Class representing a user in a project""" | ||
|
||
user: User | ||
role: ProjectRole | ||
|
||
def __post_init__(self): | ||
validate_type(self.user, User, "user") | ||
self.role = validate_enum(self.role, ProjectRole, "role") |
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
Oops, something went wrong.