-
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
198 students invisible when joining second classroom #206
198 students invisible when joining second classroom #206
Conversation
…sible-when-joining-second-classroom
are you talking about this? It s ok how you're doing it. Although every commit takes a bit of time. We could try to create a rule of thumb that says that something like:
or
So in this case then the However, I'm not sure that there won't be exceptions from these rules. |
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.
that was quite a bit of work.
looks good overall.
minor asks and we're ready to deploy.
from zeeguu.core.model import db | ||
|
||
""" | ||
set the native language of the user in session |
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.
this comment is off?
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 didn't edit it, seems like it has been this way for 6 years - but I can remove it - I think it came in the diff due to the formatting.
@@ -26,18 +26,23 @@ | |||
@api.route("/basic_user_info/<id>", methods=["GET"]) | |||
@requires_session | |||
def basic_user_info(id): | |||
# This method doesn't seem to be used by the frontend |
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.
really? then maybe we should remove it?
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.
cohort_id = int(cohort_id) | ||
UserCohortMap.query.filter(UserCohortMap.user_id == self.id).filter( | ||
UserCohortMap.cohort_id == cohort_id | ||
).delete() |
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.
Whoa! you can do that w/o a session :)
Yes, it's just that in the code you can see in the addition I do the commit in the method in add user, while in the delete I am doing it in the API call rather than the User.Method, where it just adds the value to be deleted to the session, it can then be deleted at the API level. I think that it creates a bit of a conflict in the semantics of add/delete user, if the user is not really added or deleted. What do you think we commit, and if we decide to use sessions, maybe we should call the method "mark_for_delete/add" - so it's more explicit it doesn't delete the user right away. |
- Decided to reflect what the method states: Remove / add should remove/add the user from the cohort, and not leave it for the API call to add it to the session and remove it.
this is an interesting idea, but i wonder if it won't make our method names too long?
the more we discuss the more I think that somebody who gets a session should not commit it.
alternative would be to not pass the session at all anymore, but instead such methods that aim to modify the DB model always return the objects that have to be added to the session and committed? e.g.
then the caller, probably the api endpoint who already has a session handy does
do you see what I mean? surely, this might become complicated, because when you want to add multiple objects then you have to have to create a temporary array to which you add all these objects, and then you return it. So probably the solution above with passing the session and adding directly to it is still the most concise. And functionally it's exactly the same as the one with returning the objects to be added. However, in a sense it's more clear that things have to be added to the session. |
I do see it - and generally I feel like it makes more sense that things are added rather than commited immediately especially if we were to do bulk updates, then it would be much better to store it in session. I think returning the altered object could be a good solution for this - and we can slowly start implementing it. Should I create an issue where we can track it? |
Just to be on the same page, I still think the best approach would be to simply pass the session, and add things to it. To be sure that we're on the same page with this, I've created a Discussion category called Coding Guidelines and also a separate file Coding Conventions. |
Change to support the UI changes to allow multiple classrooms for one user (zeeguu/web#526)
Changelist
cohort_id
from the user table, instead a mapping table was introduced to track this relationship.cohort_id
into the mapping table, so users remain in their current classrooms.is_member_of_cohort
which expects an ID and checks that mapping exists for the user.basic_user_info
now sends a list of cohorts if the user is in multiple classrooms.Question:
(Before commiting @mircealungu)