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

Fix #935: Conditional attributes not exported during download process #1083

Merged
merged 1 commit into from
Feb 9, 2017

Conversation

bjohare
Copy link
Contributor

@bjohare bjohare commented Jan 31, 2017

Proposed changes in this pull request

Fix #935: Conditional attributes not exported during download process

This PR adds support for the export of conditional attributes. It makes use of the SchemaSelectorMixin added in PR #1076.

  • Upgraded openpyxl to version 2.4.1
  • Refactored the write_items methods of ShapeExporter and XLSExporter to export all attributes
  • Refactored the make_download method of XLSExporter to use a streaming WriteOnlyWorksheet which streams rows to the spreadsheet rather than holding all data in memory before writing. This should help with improvements proposed in the Asynchronous Import/Export DR
  • Refactored the get_values method of the base Exporter to return a dict of values instead of a list
  • Added a method get_conditional_selector to the SchemaSelectorMixin to return the conditional selector for a particular ContentType if one exists

When should this PR be merged

This has been rebased from #1076 so should be merged after this.

Risks

Low risk.

Follow up actions

Reprovision VM's to pull in updates to dependencies.

Checklist (for reviewing)

General

  • Is this PR explained thoroughly? All code changes must be accounted for in the PR description.
  • Is the PR labeled correctly? It should have the migration label if a new migration is added.
    Is the risk level assessment sufficient? The risks section should contain all risks that might be introduced with the PR and which actions we need to take to mitigate these risks. Possible risks are database migrations, new libraries that need to be installed or changes to deployment scripts.

Functionality

  • Are all requirements met? Compare implemented functionality with the requirements specification.
  • Does the UI work as expected? There should be no Javascript errors in the console; all resources should load. There should be no unexpected errors. Deliberately try to break the feature to find out if there are corner cases that are not handled.

Code

  • Do you fully understand the introduced changes to the code? If not ask for clarification, it might uncover ways to solve a problem in a more elegant and efficient way.
  • Does the PR introduce any inefficient database requests? Use the debug server to check for duplicate requests.
  • Are all necessary strings marked for translation? All strings that are exposed to users via the UI must be marked for translation.

Tests

  • Are there sufficient test cases? Ensure that all components are tested individually; models, forms, and serializers should be tested in isolation even if a test for a view covers these components.
  • If this is a bug fix, are tests for the issue in place There must be a test case for the bug to ensure the issue won’t regress. Make sure that the tests break without the new code to fix the issue.

Documentation

  • Are changes to the UI documented in the platform docs? If this PR introduces new platform site functionality or changes existing ones, the changes must be documented in the Cadasta Platform Documentation.
  • Are changes to the API documented in the API docs? If this PR introduces new API functionality or changes existing ones, the changes must be documented in the API docs.
  • Are reusable components documented? If this PR introduces components that are relevant to other developers (for instance a mixin for a view or a generic form) they should be documented in the Wiki.

@oliverroick
Copy link
Member

@seav We will put the review for this on hold until #1076 is merged. This branch is currently based on bugfix/#761, which will make it difficult to review the changes that were actually introduced with this branch.

@seav
Copy link
Contributor

seav commented Feb 3, 2017

@oliverroick: I haven't actually started reviewing this PR since I'm doing my own unsolicited review of PR #1076. But I hope reviewing that PR helps me understand this PR.

@bjohare bjohare force-pushed the bugfix/#935 branch 3 times, most recently from 8e97c74 to 3217687 Compare February 3, 2017 14:20
@bjohare bjohare force-pushed the bugfix/#935 branch 2 times, most recently from e1e27f1 to 54ce28e Compare February 7, 2017 17:23
Copy link
Member

@oliverroick oliverroick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The export to XLS doesn't seem to work. I had a project with a standard questionnaire and some data. Exporting to shape works, all information is in the SHP and the CSV files. Exporting to XLS however returns empty spreadsheets; both for data and resources. (This could also be a problem with Apple Numbers; I don't have Excel on my machine).

@oliverroick
Copy link
Member

@linzjax Eugene is at a conference these days. Would you be able to jump in for the second review so we can get this sorted timely?

@seav
Copy link
Contributor

seav commented Feb 8, 2017

I did already start reviewing this PR but nothing weird jumped out for me so far. My biggest observation is that I will need to base my search export feature code on this branch. Otherwise I'd have to wrangle with rebasing my work if I based it on the current master.

@linzjax linzjax self-requested a review February 8, 2017 17:13
@linzjax linzjax removed the request for review from seav February 8, 2017 17:13
Copy link
Contributor

@seav seav left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I finished looking at the code changes and aside from a single comment, I didn't find anything wrong. Note also that I didn't test the download files this update is producing in my VM.

@@ -114,6 +114,14 @@ def get_model_attributes(self, project, content_type):
attributes_for_models = self.get_attributes(project)
return attributes_for_models[content_type]

def get_conditional_selector(self, content_type):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is an example of how I feel the code seems to currently cater to the party entity being the only one right now to have a conditional selector. Maybe it is a good database design to have the conditional selector be a field of the model instead of a foreign field, but I kinda feel iffy with basing the decision on whether we have a conditional selector hinge on the presence of a period on the last schema selector.

Note that this is just an observation and should not be a blocker for the PR's approval.

@amplifi amplifi merged commit 6930623 into master Feb 9, 2017
@amplifi amplifi deleted the bugfix/#935 branch February 9, 2017 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'Conditional' attributes not exported during download process
5 participants