Skip to content

Commit

Permalink
➕ Add basic repo functions for invite codes
Browse files Browse the repository at this point in the history
  • Loading branch information
devmount committed Apr 16, 2024
1 parent 4887ea4 commit 50f6068
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Thunderbird Appointment Backend

This is the backend component of Thunderbird Appointment written in Python using FastAPI, SQLAlchemy, and pytest.
This is the backend component of Thunderbird Appointment written in Python using FastAPI, SQLAlchemy, and pytest.

## Installation / Running

Expand All @@ -20,7 +20,7 @@ You will want to ensure any variable ending with `_SECRET` has a secret value as

### Authentication

This project is deployed with Mozilla Accounts (known as fxa in the code.) Since Mozilla Accounts is for internal use you will need to use password authentication. Note: password authentication does not currently have a registration flow.
This project is deployed with Mozilla Accounts (known as fxa in the code.) Since Mozilla Accounts is for internal use you will need to use password authentication. Note: password authentication does not currently have a registration flow.

## Commands

Expand Down
28 changes: 27 additions & 1 deletion backend/src/appointment/database/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,33 @@ def schedule_has_slot(db: Session, schedule_id: int, slot_id: int):
return db_slot and db_slot.schedule_id == schedule_id


"""External Connections repository functions"""
"""INVITES repository functions
"""


def use_invite_code(db: Session, code: str, subscriber_id: int):
"""set existing invite code status to revoked"""
db_invite = db.query(models.Invite).filter(models.Invite.code == code).first()
if db_invite.status == models.InviteStatus.active:
db_invite.subscriber_id = subscriber_id
db.commit()
db.refresh(db_invite)
return True
else:
return False


def revoke_invite_code(db: Session, code: str):
"""set existing invite code status to revoked"""
db_invite = db.query(models.Invite).filter(models.Invite.code == code).first()
db_invite.status = models.InviteStatus.revoked
db.commit()
db.refresh(db_invite)
return True


"""External Connections repository functions
"""


def create_subscriber_external_connection(db: Session, external_connection: ExternalConnection):
Expand Down

0 comments on commit 50f6068

Please sign in to comment.