-
Notifications
You must be signed in to change notification settings - Fork 12
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
gold task #125
gold task #125
Conversation
Pull Request Test Coverage Report for Build 1045
💛 - Coveralls |
de51e18
to
c22e571
Compare
ee1b415
to
2b114bc
Compare
pybossa/api/task.py
Outdated
@@ -72,6 +76,13 @@ def _preprocess_post_data(self, data): | |||
if invalid_fields: | |||
raise BadRequest('Missing or incorrect required fields: {}' | |||
.format(','.join(invalid_fields))) | |||
if data.get('gold_answers', None): |
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 remove None
pybossa/api/task.py
Outdated
if data.get('gold_answers', None): | ||
try: | ||
gold_answers = data['gold_answers'] | ||
if type(gold_answers) is dict and json.dumps(gold_answers): |
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.
what is the purpose of json.dumps
?
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.
for json validity
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.
What cold go wrong? Isn't the data already parsed from json?
pybossa/api/task.py
Outdated
current_user.id in get_project_data(project_id)['owners_ids']): | ||
return data | ||
else: | ||
tmp = copy.deepcopy(data) |
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 deepcopy
?
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.
so as to not update the actual object and pass to regular user an object w/o gold_ans in it
pybossa/importers/csv.py
Outdated
elif headers[idx].endswith('_gold'): | ||
if 'gold_answers' not in task_data: | ||
task_data['gold_answers'] = {} | ||
task_data['gold_answers'][headers[idx].strip('_gold')] = cell |
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.
.strip
removes all the characters in the '_gold'
string, so that's not what you want here, e.g. 'old_gold'.strip('_gold') == ''
test/test_api/test_task_api.py
Outdated
@patch('pybossa.api.task.validate_required_fields') | ||
def test_task_post_api_exceptions(self, inv_field, dup): | ||
"""Get a list of tasks using a list of project_ids.""" | ||
[admin, subadminowner, subadmin, reguser] = UserFactory.create_batch(4) |
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.
Do you need all these? Looks like only admin and subadminonwner are used
pybossa/importers/importer.py
Outdated
def validate_gold_answers(task): | ||
try: | ||
if task.gold_answers: | ||
json.dumps(task.gold_answers) |
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.
needed?
2b114bc
to
ec7765a
Compare
updated |
ec7765a
to
dadee8d
Compare
No description provided.