Skip to content

✨ Add applications and project members functionality with schema updates#68

Merged
andiazdi merged 7 commits intomainfrom
almaz/apply-to-project
Jul 9, 2025
Merged

✨ Add applications and project members functionality with schema updates#68
andiazdi merged 7 commits intomainfrom
almaz/apply-to-project

Conversation

@andiazdi
Copy link
Collaborator

@andiazdi andiazdi commented Jul 9, 2025

Closes #64
Closes #65
Closes #66

@andiazdi andiazdi requested a review from Copilot July 9, 2025 13:32

This comment was marked as outdated.

@andiazdi andiazdi requested a review from Copilot July 9, 2025 13:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements application and project member functionality by extending the database schema, models, service logic, routes, and schemas to support apply/approve workflows and adds new project attributes.

  • Adds Application and ProjectMember models, migrations, and data-access methods for project applications and members
  • Extends ProjectService, routes, and Pydantic schemas to handle apply, list, and approve operations
  • Updates database dependency to centralize commits and refines user ID typing in auth services

Reviewed Changes

Copilot reviewed 23 out of 23 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
backend/app/models/applications.py New Application model for user-project applications
backend/app/models/project_member.py New ProjectMember model for approved project members
backend/app/models/projects.py Added ceo_id, is_opensource, is_dead, and __repr__
backend/app/models/users.py Made role column nullable
backend/app/routes/api/project/schemas.py Extended project, application, and member schemas
backend/app/routes/api/project/data_access.py Added data-access logic and custom exception for applications
backend/app/routes/api/project/service.py Service methods for apply, list, and approve workflows
backend/app/routes/api/project/router.py New routes for project application endpoints
backend/app/dependencies/database.py Moved commit into DB dependency
backend/app/services/auth.py Updated get_user_by_username return type
backend/app/schemas/user.py Added optional id field to UserInDB
Comments suppressed due to low confidence (2)

backend/app/routes/api/project/schemas.py:38

  • [nitpick] ProjectMemberSchema omits created_at even though the model records it. Add created_at: datetime (or date) to the schema for consistency.
class ProjectMemberSchema(BaseModel):

backend/app/models/users.py:22

  • [nitpick] The role column was made nullable, potentially allowing users without a role. For data integrity, consider keeping it non-nullable or adding a default.
        nullable=True,

status_code=403,
detail="You cannot approve your own application.",
)
await self.data_access.approve_application(
Copy link

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approve_application call in service can raise ProjectNotFoundError and is not caught, resulting in a 500. Catch this exception and convert to an HTTPException with a 404 status.

Copilot uses AI. Check for mistakes.
is_dead: bool


class ProjectSchema(NewProjectSchema):
Copy link

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests reference a status field on ProjectSchema (e.g., status="active"), but ProjectSchema does not define status. Add status: str to the schema.

Copilot uses AI. Check for mistakes.


class ProjectsDataClass:
class ProjectNotFoundError(Exception):
Copy link

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The exception ProjectNotFoundError is used for missing application records. Consider renaming it to ApplicationNotFoundError for clarity.

Suggested change
class ProjectNotFoundError(Exception):
class ApplicationNotFoundError(Exception):

Copilot uses AI. Check for mistakes.

project_id = Column(Integer, ForeignKey("projects.id"))
user_id = Column(Integer, ForeignKey("users.id"))
created_at = Column(Date, default=func.current_date())
Copy link

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ApplicationSchema.created_at is typed as datetime but the model uses SQL Date. Either change the column to DateTime or update the schema to date.

Suggested change
created_at = Column(Date, default=func.current_date())
created_at = Column(DateTime, default=func.current_timestamp())

Copilot uses AI. Check for mistakes.
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixing

except Exception as e:
await session.rollback()
raise e
await session.commit()
Copy link

Copilot AI Jul 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Committing in the DB dependency will commit after all operations, including GET requests. Consider committing only in write operations or in service methods.

Suggested change
await session.commit()

Copilot uses AI. Check for mistakes.
@andiazdi andiazdi merged commit 440913f into main Jul 9, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🗃️ Add more fields to project model ✨ Implement apply to project system

2 participants