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

Issue 4 #34

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Issue 4 #34

wants to merge 3 commits into from

Conversation

HugoLMFbd
Copy link
Contributor

No description provided.

Comment on lines +36 to +48
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')
Copy link
Contributor

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?

Copy link
Contributor Author

@HugoLMFbd HugoLMFbd Jul 12, 2022

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.

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