Skip to content

Commit

Permalink
Merge pull request #22 from Clubs-Council-IIITH/cc_approver
Browse files Browse the repository at this point in the history
Added cc_approver functionality in the progress event
  • Loading branch information
Dileepadari authored Mar 23, 2024
2 parents 10431b6 + 38e584d commit 512370f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ class Event_Status:
# budget: Event_Budget_Status = Event_Budget_Status.unapproved
room: bool = False
budget: bool = False
cc_approver: str | None = None
slo_approver: str | None = None
slc_approver: str | None = None

# def __init__ (self, state: Event_State_Status = None, room: Event_Room_Status = None, budget: Event_Budget_Status = None) :
# self.state: Event_State_Status = Event_State_Status.incomplete if state is None else state
Expand All @@ -65,10 +68,16 @@ def __init__(
state: Event_State_Status = Event_State_Status.incomplete,
room: bool = False,
budget: bool = False,
cc_approver: str | None = None,
slo_approver: str | None = None,
slc_approver: str | None = None,
):
self.state = state
self.room = room
self.budget = budget
self.cc_approver = cc_approver
self.slo_approver = slo_approver
self.slc_approver = slc_approver


# Event Modes
Expand Down
20 changes: 20 additions & 0 deletions mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def progressEvent(
info: Info,
cc_progress_budget: bool | None = None,
cc_progress_room: bool | None = None,
cc_approver: str | None = None,
) -> EventType:
"""
progress the event state status for different users
Expand Down Expand Up @@ -259,6 +260,9 @@ def progressEvent(
"room": False,
# or len(event_instance.location) == 0,
"state": Event_State_Status.pending_cc.value,
"cc_approver": event_instance.status.cc_approver,
"slc_approver": event_instance.status.slc_approver,
"slo_approver": event_instance.status.slo_approver,
}

elif event_instance.status.state == Event_State_Status.pending_cc:
Expand All @@ -269,11 +273,18 @@ def progressEvent(
# or sum([b.amount for b in event_instance.budget]) == 0,
"room": event_instance.status.room,
# or len(event_instance.location) == 0,
"cc_approver": user["uid"],
"slc_approver": event_instance.status.slc_approver,
"slo_approver": event_instance.status.slo_approver,
}
if cc_progress_budget is not None:
updation["budget"] = cc_progress_budget
if cc_progress_room is not None:
updation["room"] = cc_progress_room
if cc_approver is not None:
updation["cc_approver"] = cc_approver
else:
raise Exception("CC Approver is required to progress the event.")

if not updation["budget"]:
updation["state"] = Event_State_Status.pending_budget.value
Expand All @@ -290,6 +301,9 @@ def progressEvent(
"budget": True,
"room": event_instance.status.room,
# | len(event_instance.location) == 0,
"slc_approver": user["uid"],
"slo_approver": event_instance.status.slo_approver,
"cc_approver": event_instance.status.cc_approver,
}

if not updation["room"]:
Expand All @@ -306,6 +320,9 @@ def progressEvent(
"budget": event_instance.status.budget,
"room": True,
"state": Event_State_Status.approved.value,
"slo_approver": user["uid"],
"slc_approver": event_instance.status.slc_approver,
"cc_approver": event_instance.status.cc_approver,
}

elif event_instance.status.state == Event_State_Status.approved:
Expand All @@ -318,6 +335,9 @@ def progressEvent(
"budget": event_instance.status.budget,
"room": event_instance.status.room,
"state": Event_State_Status.approved.value,
"cc_approver": event_instance.status.cc_approver,
"slc_approver": event_instance.status.slc_approver,
"slo_approver": event_instance.status.slo_approver,
}

upd_ref = eventsdb.update_one({"_id": eventid}, {"$set": {"status": updation}})
Expand Down

0 comments on commit 512370f

Please sign in to comment.