-
Notifications
You must be signed in to change notification settings - Fork 4
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
Issue 4 #34
base: main
Are you sure you want to change the base?
Conversation
def confirm_associations(self, institution: object): | ||
try: | ||
if institution.association_requests: | ||
for user_request in institution.association_requests: | ||
institution.associates.append(user_request) | ||
institution.association_requests.pop() | ||
user_request.institution = institution | ||
if not institution.association_requests: | ||
return 'Done' | ||
else: | ||
raise UserControllerError('No confirmation requests') | ||
except TypeError: | ||
raise UserControllerError('There are not user request to confirm') |
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.
Hi Hugo, can you explain this code to me? I understand that you are moving association requests from the institution.association_requests
attribute to the institution.associates
. Why the if inside the for loop? Do you get a message from python telling you that it is dangerous to modify a list inside the for loop where it is being used?
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.
Hi Mathias, my code is trying to confirm by appending the institution in the students attribute institution
cleaning the list of the associates_requests
and moving the requests to the the associates
attribute in institution.
This 'if' inside the loop is to confirm the association_requests
is an empty list, I did that to check my test and the 'assertion'. Perhaps is not necessary line 43 and 44.
And for the question about the 'for' loop I didn't receive any message from python saying that is dangerous to modify a list inside the 'for' loop.
Should I modify the association_requests
and associates
after the for loop? because the for loop is moving all association_requests
to associates
is associating all requests. I'm also didn't tested with more than one user inside the association_requests
.
No description provided.