Skip to content

Commit

Permalink
Merge pull request #2058 from DSD-DBS/realistic-project-mock-name
Browse files Browse the repository at this point in the history
chore(storybook): Use "In-Flight Entertainment" as default mockProject
  • Loading branch information
MoritzWeber0 authored Dec 3, 2024
2 parents b81c92c + 7dad38a commit 5f230dd
Show file tree
Hide file tree
Showing 24 changed files with 106 additions and 54 deletions.
2 changes: 1 addition & 1 deletion backend/capellacollab/core/authentication/injectables.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _is_internal_project_accessible(
self, project: projects_models.DatabaseProject
) -> bool:
return (
project.visibility == projects_models.Visibility.INTERNAL
project.visibility == projects_models.ProjectVisibility.INTERNAL
and self.required_role
== projects_users_models.ProjectUserRole.USER
and self.required_permission
Expand Down
6 changes: 3 additions & 3 deletions backend/capellacollab/core/database/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def initialize_capellambse_test_project(db: orm.Session):
db=db,
name="Melody Model Test",
description="Group of test models of the capellambse Python library",
visibility=project_models.Visibility.INTERNAL,
visibility=project_models.ProjectVisibility.INTERNAL,
)
create_capellambse_test_models(db, project)
LOGGER.info("Initialized project '%s'", project.name)
Expand Down Expand Up @@ -476,7 +476,7 @@ def initialize_coffee_machine_project(db: orm.Session):
db=db,
name="Coffee Machine",
description="Contains the Capella Coffee Machine sample model",
visibility=project_models.Visibility.INTERNAL,
visibility=project_models.ProjectVisibility.INTERNAL,
)
create_coffee_machine_model(db, project)
LOGGER.info("Initialized project '%s'", project.name)
Expand Down Expand Up @@ -521,7 +521,7 @@ def initialize_ife_project(db: orm.Session):
db=db,
name="In-Flight Entertainment",
description="Contains the Capella In-Flight Entertainment System sample model",
visibility=project_models.Visibility.INTERNAL,
visibility=project_models.ProjectVisibility.INTERNAL,
)
create_ife_model(db, project)
LOGGER.info("Initialized project '%s'", project.name)
Expand Down
5 changes: 3 additions & 2 deletions backend/capellacollab/projects/crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def get_internal_projects(
return (
db.execute(
sa.select(models.DatabaseProject).where(
models.DatabaseProject.visibility == models.Visibility.INTERNAL
models.DatabaseProject.visibility
== models.ProjectVisibility.INTERNAL
)
)
.scalars()
Expand Down Expand Up @@ -88,7 +89,7 @@ def create_project(
db: orm.Session,
name: str,
description: str = "",
visibility: models.Visibility = models.Visibility.PRIVATE,
visibility: models.ProjectVisibility = models.ProjectVisibility.PRIVATE,
type: models.ProjectType = models.ProjectType.GENERAL,
) -> models.DatabaseProject:
project = models.DatabaseProject(
Expand Down
14 changes: 7 additions & 7 deletions backend/capellacollab/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UserMetadata(core_pydantic.BaseModel):
subscribers: int


class Visibility(enum.Enum):
class ProjectVisibility(enum.Enum):
PRIVATE = "private"
INTERNAL = "internal"

Expand All @@ -43,7 +43,7 @@ class Project(core_pydantic.BaseModel):
name: str
slug: str
description: str | None = None
visibility: Visibility
visibility: ProjectVisibility
type: ProjectType
users: UserMetadata
is_archived: bool
Expand Down Expand Up @@ -94,22 +94,22 @@ class SimpleProject(core_pydantic.BaseModel):
id: int
name: str
slug: str
visibility: Visibility
visibility: ProjectVisibility
type: ProjectType


class PatchProject(core_pydantic.BaseModel):
name: str | None = None
description: str | None = None
visibility: Visibility | None = None
visibility: ProjectVisibility | None = None
type: ProjectType | None = None
is_archived: bool | None = None


class PostProjectRequest(core_pydantic.BaseModel):
name: str
description: str | None = None
visibility: Visibility = Visibility.PRIVATE
visibility: ProjectVisibility = ProjectVisibility.PRIVATE
type: ProjectType = ProjectType.GENERAL


Expand All @@ -124,8 +124,8 @@ class DatabaseProject(database.Base):
slug: orm.Mapped[str] = orm.mapped_column(unique=True, index=True)

description: orm.Mapped[str | None] = orm.mapped_column(default=None)
visibility: orm.Mapped[Visibility] = orm.mapped_column(
default=Visibility.PRIVATE
visibility: orm.Mapped[ProjectVisibility] = orm.mapped_column(
default=ProjectVisibility.PRIVATE
)
type: orm.Mapped[ProjectType] = orm.mapped_column(
default=ProjectType.GENERAL
Expand Down
3 changes: 2 additions & 1 deletion backend/capellacollab/projects/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def get_projects(
projects = [
association.project
for association in user.projects
if not association.project.visibility == models.Visibility.INTERNAL
if not association.project.visibility
== models.ProjectVisibility.INTERNAL
]
projects.extend(crud.get_internal_projects(db))
else:
Expand Down
2 changes: 1 addition & 1 deletion backend/capellacollab/projects/users/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_project_user_association_or_raise(
if project_user := crud.get_project_user_association(db, project, user):
return project_user

if project.visibility == projects_models.Visibility.INTERNAL:
if project.visibility == projects_models.ProjectVisibility.INTERNAL:
return models.ProjectUser(
role=models.ProjectUserRole.USER,
permission=models.ProjectUserPermission.READ,
Expand Down
14 changes: 10 additions & 4 deletions backend/tests/projects/test_projects_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def test_get_projects_as_admin(
executor_name: str,
):
project = projects_crud.create_project(
db, "test project", visibility=projects_models.Visibility.PRIVATE
db,
"test project",
visibility=projects_models.ProjectVisibility.PRIVATE,
)
users_crud.create_user(
db, executor_name, executor_name, None, users_models.Role.ADMIN
Expand All @@ -102,7 +104,9 @@ def test_get_internal_projects_as_user(
executor_name: str,
):
project = projects_crud.create_project(
db, "test project", visibility=projects_models.Visibility.INTERNAL
db,
"test project",
visibility=projects_models.ProjectVisibility.INTERNAL,
)
users_crud.create_user(
db, executor_name, executor_name, None, users_models.Role.USER
Expand All @@ -128,7 +132,9 @@ def test_get_internal_projects_as_user_without_duplicates(
db, executor_name, executor_name, None, users_models.Role.USER
)
project = projects_crud.create_project(
db, "test project", visibility=projects_models.Visibility.INTERNAL
db,
"test project",
visibility=projects_models.ProjectVisibility.INTERNAL,
)
projects_users_crud.add_user_to_project(
db,
Expand Down Expand Up @@ -217,7 +223,7 @@ def test_update_project_as_admin(
project = projects_crud.create_project(db, "new project")

assert project.slug == "new-project"
assert project.visibility == projects_models.Visibility.PRIVATE
assert project.visibility == projects_models.ProjectVisibility.PRIVATE
assert project.is_archived is False

response = client.patch(
Expand Down
4 changes: 2 additions & 2 deletions backend/tests/projects/test_projects_users_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def test_current_user_rights_for_internal_project(
db,
project,
projects_models.PatchProject(
visibility=projects_models.Visibility.INTERNAL
visibility=projects_models.ProjectVisibility.INTERNAL
),
)
users_crud.create_user(
Expand All @@ -145,7 +145,7 @@ def test_no_user_rights_on_internal_permissions(
db,
project,
projects_models.PatchProject(
visibility=projects_models.Visibility.PRIVATE
visibility=projects_models.ProjectVisibility.PRIVATE
),
)
users_crud.create_user(
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/openapi/.openapi-generator/FILES

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion frontend/src/app/openapi/model/models.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/src/app/openapi/model/patch-project.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/src/app/openapi/model/post-project-request.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/src/app/openapi/model/project.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions frontend/src/app/openapi/model/simple-project.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5f230dd

Please sign in to comment.