-
Notifications
You must be signed in to change notification settings - Fork 22
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
Allow registered users to edit their reviews #67
base: master
Are you sure you want to change the base?
Conversation
review = { | ||
"professor": escape(Professor.unfiltered.get(pk=model_obj.professor_id).name), | ||
"rating": model_obj.rating, | ||
"anonymous": model_obj.anonymous, | ||
"course": None if not model_obj.course_id else {"id": model_obj.course_id, "name": Course.unfiltered.get(pk=model_obj.course_id).name}, | ||
"grade": None if not model_obj.grade else model_obj.grade, | ||
"id": model_obj.pk, | ||
"content": escape(model_obj.content) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't looked into this deeply, but this is sketch. I would expect model_obj
to already be a Review
here - why go through all this trouble instead of dumping model_obj
?
Django's serializers should have a built-in way to follow and dump foreign keys as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
model_obj
is an instance of a Review but without any of the related fields. All such fields are just the pk to the column in the corresponding table, which is not what we want here.
By default, django serializers don't actually forward foreign keys and m2m relationships; the pk is used instead and we are required to add natural keys to our model managers to change this behavior. If you think this is worth the effort and is better than the current approach then I'll go ahead and do it.
Errors when trying to view another user's profile as admin due to not passing an PlanetTerp/home/views/basic.py Line 161 in 73cb435
We'll likely need to pull the same |
Something weird is suddenly going on with the tabs on the profile page and the settings now appear at the bottom of the reviews tab when clicked. I compared the changes made to profile.html in this PR to the version on master and I can't see any changes that would cause this behavior. Other than that, this PR is ready for review! |
Registered users will be able to edit all aspects of a review except the professor's name and the course, if there is one. If there is no course, one can be added.
If the content of the review (the text) is edited, then the review will be marked as pending for admins to approve. This applies to reviews with any status (verified, pending, rejected). Any other edit will be reflected immediately without the need for admins to approve.