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
Fix #13162: Add schema and introduce new approach for saving multiple images in suggestion handler. #14063
Fix #13162: Add schema and introduce new approach for saving multiple images in suggestion handler. #14063
Conversation
* change is an object of diff domain types
Hi @DubeySandeep, could you please add the appropriate changelog label to this pull request? Thanks! |
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.
@chiragbaid7 Left one question for clarification.
Thank you
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.
Thanks! the overall design looks good. Left a few comments.
from core.domain import state_domain | ||
|
||
from typing import Dict, Optional, Union | ||
|
||
|
||
def validate_change(obj): |
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.
def validate_change(obj): | |
def validate_exploration_or_question_change(obj): |
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.
Done.
from core.domain import state_domain | ||
|
||
from typing import Dict, Optional, Union | ||
|
||
|
||
def validate_change(obj): | ||
"""Validates Exploration and Question domain change. |
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.
"""Validates Exploration and Question domain change. | |
"""Validates Exploration or Question change. |
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.
Done.
exp_domain.ExplorationChange(obj) | ||
elif obj['cmd'] in feconf.LIST_CMD_QUESTION_CHANGE: | ||
question_domain.QuestionSuggestionChange(obj) |
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.
Should we call validate
explicitly?
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.
Are you talking about validation method in the schema for change param?
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.
Nevermind. Can you just add a comment that the change is validated when the object is created?
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.
Done.
core/controllers/suggestion.py
Outdated
'target_version_at_submission': | ||
{ |
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.
'target_version_at_submission': | |
{ | |
'target_version_at_submission': { |
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.
Done
core/controllers/suggestion.py
Outdated
except utils.ValidationError as e: | ||
raise self.InvalidInputException(e) |
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.
Can this still happen?
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.
Yes this can be removed as validation is being performed,
core/feconf.py
Outdated
# Constants defining various domain commands. | ||
CMD_ADD_WRITTEN_TRANSLATION = 'add_written_translation' | ||
CMD_EDIT_STATE_PROPERTY = 'edit_state_property' | ||
CMD_CREATE_NEW_FULLY_SPECIFIED_QUESTION = 'create_new_fully_specified_question' | ||
|
||
# Possible allowed commands for exploration change. | ||
LIST_CMD_EXPLORATION_CHANGE = [ | ||
CMD_ADD_WRITTEN_TRANSLATION, | ||
CMD_EDIT_STATE_PROPERTY | ||
] | ||
|
||
# Possible allowed commands for question change. | ||
LIST_CMD_QUESTION_CHANGE = [ | ||
CMD_CREATE_NEW_FULLY_SPECIFIED_QUESTION | ||
] |
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.
Why are we redefining these?
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.
The above constants are to check which domain the passed change object's parameter cmd belongs,
The object value cmd is then compared with possibles commands in the list and then corresponding domain object is called accordingly.
if obj['cmd'] in feconf.LIST_CMD_EXPLORATION_CHANGE:
exp_domain.ExplorationChange(obj)
elif obj['cmd'] in feconf.LIST_CMD_QUESTION_CHANGE:
question_domain.QuestionSuggestionChange(obj)
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.
Yeah, but these commands are already defined in another file, we shouldn't redefine them, we should import them one way or the other.
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.
OK, I have created a list of possible allowed commands in question_domain and exp_domain and removed the redefined constants from feconf.
…iragbaid7/oppia into add-schema-suggestion-handler
PTAL @seanlip |
Unassigning @chiragbaid7 since a re-review was requested. @chiragbaid7, please make sure you have addressed all review comments. Thanks! |
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.
LGTM for my codeowner file. Thanks @chiragbaid7!
@DubeySandeep PTAL |
Hi @chiragbaid7, the build of this PR is stale and this could result in tests failing in develop. Please update this pull request with the latest changes from develop. Thanks! |
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.
LGTM for the changes in core/domain/image_validation_services.py
Unassigning @DubeySandeep since they have already approved the PR. |
…ving multiple images in suggestion handler. (oppia#14063)" This reverts commit e400be5.
Heads-up -- it looks like this PR inadvertently broke a key workflow in the contributor dashboard. See #15101. @chiragbaid7 @vojtechjelinek would it be possible to make a fix quickly? We will need to hotfix this. Thanks! |
@chiragbaid7 Is working on the fix. |
Overview
Essential Checklist
Proof that changes are correct
suggestion-handler.mp4
Suggestion.images.mp4
Translate.images.suggestion.mp4
PR Pointers