Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Priority field to Post/Polls + Refactor #246

Merged
merged 3 commits into from
Feb 27, 2024
Merged

Conversation

vcai122
Copy link
Contributor

@vcai122 vcai122 commented Feb 27, 2024

No description provided.

Copy link

sentry-io bot commented Feb 27, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: backend/portal/views.py

Function Unhandled Issue
browse KeyError: 'student' /api/portal/polls/browse/
Event Count: 1

Did you find this useful? React with a 👍 or 👎

Copy link

codecov bot commented Feb 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.42%. Comparing base (7180d4a) to head (8fc9548).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #246      +/-   ##
==========================================
- Coverage   91.45%   91.42%   -0.03%     
==========================================
  Files          59       59              
  Lines        2504     2496       -8     
==========================================
- Hits         2290     2282       -8     
  Misses        214      214              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@judtinzhang judtinzhang left a comment

Choose a reason for hiding this comment

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

LGTM! Just one comment worth considering

@@ -37,15 +37,22 @@ class Poll(models.Model):
)

club_code = models.CharField(max_length=255, blank=True)
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, not entirely sure of this myself. What are people's thoughts on having club_code and club_comment here? Do you think this is general enough for future models or should we push this back down to the Poll and Post models.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wait what future models were you thinking of? I was thinking Content is just the "superclass" to Post/Polls, so has all the shared stuff. I guess you're thinking of a different "meaning" to Content?

Copy link
Member

Choose a reason for hiding this comment

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

Hm that is fair. Yea I think posts and polls are really all that is it. I was thinking maybe Ashley's Events could also inherit but thinking about it some more that wouldn't make sense. Okay down to merge haha

priority = models.IntegerField(default=0)

class Meta:
abstract = True
Copy link
Member

Choose a reason for hiding this comment

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

Good stuff haha

@@ -99,7 +99,7 @@ def get_queryset(self):
)
)

@action(detail=False, methods=["post"])
@action(detail=False, methods=["post"]) # WHY IS THIS POST
Copy link
Member

Choose a reason for hiding this comment

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

POST because the devices send us a id_hash which is a hash based on device id. This is because we want to associate votes based on this rather than pennkey to keep users anonymous. For this, if the user voted we don't given them the ability to vote again (based on if id_hash already voted)

Copy link
Contributor Author

@vcai122 vcai122 Feb 27, 2024

Choose a reason for hiding this comment

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

wait wat, but i don't see any posting going on here. am i blind? it looks like its just retreiving stuff

Copy link
Member

Choose a reason for hiding this comment

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

L108 id_hash = request.data["id_hash"]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but there's no up updating to our models going on? like can't we just use a get request for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh wait nvm. https://stackoverflow.com/questions/19637459/rest-api-using-post-instead-of-get. so we can send through the body im assuming?

Copy link
Member

Choose a reason for hiding this comment

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

Yea right. I think generally I like sending things via POST body as opposed to query params if it isn't literally for a non trivial query

@judtinzhang judtinzhang self-requested a review February 27, 2024 04:46
@vcai122 vcai122 merged commit a31640b into master Feb 27, 2024
9 checks passed
@vcai122 vcai122 deleted the portal-post-priority branch February 27, 2024 06:14
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.

2 participants