Skip to content

Commit

Permalink
Improve docs, don't expose user_id
Browse files Browse the repository at this point in the history
  • Loading branch information
mureytasroc committed Oct 26, 2023
1 parent c8ffbe4 commit b164f9f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion backend/plan/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ class PrimaryScheduleSerializer(serializers.ModelSerializer):

class Meta:
model = PrimarySchedule
fields = ["user", "user_id", "schedule_id", "schedule"]
fields = ["user", "schedule"]
3 changes: 2 additions & 1 deletion backend/plan/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ def get_queryset(self):
response_codes={
"primary-schedules-list": {
"GET": {
200: "Primary schedule (and friend's schedules) retrieved successfully.",
200: "[DESCRIBE_RESPONSE_SCHEMA]Primary schedule (and friend's schedules) "
"retrieved successfully.",
},
"POST": {
201: "Primary schedule updated successfully.",
Expand Down
10 changes: 4 additions & 6 deletions backend/tests/plan/test_primary_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,15 @@ def assert_primary_schedule_id(self, client, user, schedule_id, num_primary=None
if num_primary is not None:
self.assertEqual(len(response.json()), num_primary)
if schedule_id is not None:
self.assertIn(schedule_id, [p["schedule_id"] for p in response.json()])
self.assertIn(schedule_id, [p["schedule"]["id"] for p in response.json()])

def test_post_primary_schedule(self):
response = self.client.post(primary_schedule_url, {"schedule_id": self.s.id})
self.assertEqual(response.status_code, 200)
self.assert_primary_schedule_id(self.client, self.u1, self.s.id, num_primary=1)

def test_invalid_schedule_id(self):
response = self.client.post(
primary_schedule_url, {"schedule_id": self.deleted_schedule_id}
)
response = self.client.post(primary_schedule_url, {"schedule_id": self.deleted_schedule_id})
self.assertEqual(response.status_code, 400)
self.assert_primary_schedule_id(self.client, self.u1, None, num_primary=0)

Expand Down Expand Up @@ -113,8 +111,8 @@ def test_primary_schedule_friends(self):
response = self.client.get(primary_schedule_url)
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.json()), 2)
self.assertIn(self.s.id, [p["schedule_id"] for p in response.json()])
self.assertIn(u2_s.id, [p["schedule_id"] for p in response.json()])
self.assertIn(self.s.id, [p["schedule"]["id"] for p in response.json()])
self.assertIn(u2_s.id, [p["schedule"]["id"] for p in response.json()])

Friendship.objects.create(sender=self.u1, recipient=u3, status=Friendship.Status.ACCEPTED)
u3_s = Schedule(
Expand Down
2 changes: 1 addition & 1 deletion frontend/plan/actions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ export const findOwnPrimarySchedule = (user) => (dispatch) => {
})
.then((foundSched) => {
dispatch(
setPrimaryScheduleIdOnFrontend(foundSched?.schedule_id)
setPrimaryScheduleIdOnFrontend(foundSched?.schedule.id)
);
})
.catch((error) => {
Expand Down

0 comments on commit b164f9f

Please sign in to comment.