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

Investment Project Documents #250

Merged
merged 22 commits into from
Jun 22, 2017
Merged

Investment Project Documents #250

merged 22 commits into from
Jun 22, 2017

Conversation

canni
Copy link
Contributor

@canni canni commented Jun 12, 2017

No description provided.

@codecov-io
Copy link

codecov-io commented Jun 19, 2017

Codecov Report

Merging #250 into develop will decrease coverage by 0.27%.
The diff coverage is 85.91%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #250      +/-   ##
===========================================
- Coverage    93.65%   93.38%   -0.28%     
===========================================
  Files           56       58       +2     
  Lines         2049     2115      +66     
  Branches       190      194       +4     
===========================================
+ Hits          1919     1975      +56     
- Misses         109      118       +9     
- Partials        21       22       +1
Impacted Files Coverage Δ
datahub/documents/serializers.py 0% <0%> (ø)
datahub/investment/urls.py 100% <100%> (ø) ⬆️
datahub/investment/admin.py 100% <100%> (ø) ⬆️
datahub/investment/serializers.py 98.94% <100%> (+0.09%) ⬆️
datahub/v2/renderers.py 94.44% <100%> (ø) ⬆️
datahub/core/utils.py 84.21% <100%> (+4.21%) ⬆️
datahub/documents/admin.py 100% <100%> (ø)
datahub/investment/views.py 93.33% <86.2%> (-6.67%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3e97b5...cb6499d. Read the comment docs.

@canni canni changed the title [WIP] Investment Project Documents Investment Project Documents Jun 19, 2017
@canni canni requested a review from reupen June 19, 2017 14:13
Copy link
Contributor

@reupen reupen left a comment

Choose a reason for hiding this comment

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

Still having a look through, but here are my comments so far...

@@ -169,3 +170,9 @@
CHAR_FIELD_MAX_LENGTH = 255
HEROKU = False
BULK_CREATE_BATCH_SIZE = env.int('BULK_CREATE_BATCH_SIZE', default=50000)

AWS_ACCESS = {
Copy link
Contributor

@reupen reupen Jun 20, 2017

Choose a reason for hiding this comment

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

boto3 reads directly from the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables, should we just use those?

Also need to update the README with new environment variables (in the Heroku section...)

[Edit]
Actually, it looks like we're using instance profiles elsewhere which Boto3 will pick up automatically.

'KEY_ID': env('AWS_KEY_ID'),
'KEY_SECRET': env('AWS_KEY_SECRET'),
}
DOCUMENTS_BUCKET = env('DOC_BUCKET')
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep the name of the Python and environment variable consistent?

if not s3:
s3 = boto3.client(
's3',
region_name='eu-west-2',
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice not to hard-code the region. Boto3 will use the AWS_DEFAULT_REGION environment variable.


def sign_s3_url(bucket_name, path, method='get_object', expires=3600):
"""Sign s3 url using global config, and given expiry in seconds."""
s3 = getattr(sign_s3_url, 's3_instance', None)
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be useful to split the the client part into a separate function (e.g. get_s3_client()).

uploaded_on = models.DateTimeField(
null=True, blank=True
)
av_clean = models.BooleanField(default=False)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to store whether the scan has completed or not as well? Also defaulting to False is a bit confusing, since that sounds like it's infected. NullBooleanField might fix both problems...

Copy link
Contributor

Choose a reason for hiding this comment

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

I think something like checked_on would be useful to see performance of the checks and for audit - for example if it turns out file is infected or if we want to check files that has not been checked in let's say two weeks.


@property
def url(self):
"""Generate pre-signed download URL."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Not too much of a fan of generating pre-signed URLs in properties...

Copy link
Contributor

@elcct elcct Jun 21, 2017

Choose a reason for hiding this comment

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

At least property name should inform that the url is signed?

return self.document.upload_url

class Meta: # noqa: D101
verbose_name = 'Investment Project Document'
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't the verbose name meant to be in lower case?



class IProjectDocumentViewSet(CoreViewSetV3):
"""Investment Project Serializer."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Docstring needs updating here

@canni canni merged commit e89452b into develop Jun 22, 2017
@canni canni deleted the feature/documents-upload branch June 22, 2017 11:09
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.

4 participants