Skip to content

Commit

Permalink
fix: member projects association
Browse files Browse the repository at this point in the history
  • Loading branch information
vugonz committed Nov 17, 2024
1 parent b939957 commit dd442dd
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def create_app(config_class=Config):
register_error_handlers(flask_app)
register_commands(flask_app)

if (frontend_uri := flask_app.config.get("FRONTEND_ORIGIN", "")) != "":
if (frontend_uri := flask_app.config.get("FRONTEND_URI", "")) != "":
CORS(flask_app, origins=[frontend_uri], supports_credentials=True)

setup_logger(flask_app)
Expand Down
2 changes: 1 addition & 1 deletion app/commands/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def populate_admin_user():
admin = Member(
username=admin_username,
password=admin_password,
ist_id="ist"+admin_username,
ist_id="ist1"+admin_username,
member_number=0,
name=admin_username,
join_date="1970-01-01",
Expand Down
2 changes: 1 addition & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Config:

LOGS_PATH = os.path.join(basedir, _get_env_or_default("LOGS_PATH", ""))

FRONTEND_ORIGIN = _get_env_or_default("FRONTEND_ORIGIN", "http://localhost:3000")
FRONTEND_URI = _get_env_or_default("FRONTEND_URI", "http://localhost:3000")

ADMIN_USERNAME = _get_env_or_default("ADMIN_USERNAME", "")
ADMIN_PASSWORD = _get_env_or_default("ADMIN_PASSWORD", "")
Expand Down
8 changes: 4 additions & 4 deletions app/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def check_invariants(self):
if not isinstance(self.ist_id, str) or not self.ist_id or \
len(self.ist_id) < 4 or len(self.ist_id) > 20 or \
not self.ist_id.startswith("ist1"):
raise ValueError("Field 'ist_id' must be a valid IST student number.")
raise ValueError(f"Field 'ist_id' must be a valid IST student number.")

# name
if not isinstance(self.name, str) or not self.name or \
Expand All @@ -121,7 +121,7 @@ def check_invariants(self):
raise ValueError("Field 'course' must be a non-empty string with max 8 characters.")

# member_number
if not isinstance(self.member_number, int) or self.member_number <= 0:
if not isinstance(self.member_number, int) or self.member_number < 0:
raise ValueError("Field 'member_number' must be a positive integer.")

# join_date
Expand Down Expand Up @@ -269,8 +269,8 @@ def check_invariants(self):

def to_dict(self):
return {
"member_id": self.member_id,
"project_id": self.project_id,
"username": self.member_username,
"project_name": self.project_name,
"entry_date": self.entry_date,
"contributions": self.contributions,
"exit_date": self.exit_date
Expand Down
6 changes: 3 additions & 3 deletions app/services/member_project_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def delete_project_member(

return member.id

def get_member_projects(member: Member) -> List[Project]:
return [assoc.project for assoc in member.projects if assoc.project]
def get_member_projects(member: Member) -> List[MemberProjects]:
return [assoc for assoc in member.projects if assoc.project]

def get_project_members(project: Project) -> List[Member]:
return [assoc.member for assoc in project.members if assoc.member]
return [assoc for assoc in project.members if assoc.member]

0 comments on commit dd442dd

Please sign in to comment.