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

[IN-294] Django-storages assets for providers #8371

Conversation

mfraezz
Copy link
Member

@mfraezz mfraezz commented May 15, 2018

Purpose

Implement something better than dog-food'd files committed to a git repo for branded assets.

Changes

  • django-storages used for uploading static files to Google Cloud Storage
  • Admin module views created to allow product to do this easily
  • API endpoints for assets
  • Relationship added to providers in the the API (so ember can reference and fetch these by name)
    (These two to be done in [IN-302])

QA Notes

These assets won't be visible in the ember UI until collections goes out, but test that the admin module can be used to create/edit/delete them.

Side Effects

None expected

Deployment Notes

A GOOGLE_APPLICATION_CREDENTIALS environment variable must be set. See lookit's helm chart for reference

Ticket

[IN-294]

Copy link
Contributor

@alexschiller alexschiller left a comment

Choose a reason for hiding this comment

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

LGTM: did a quick zoom demo and discussed approach. Some concerns about local development, could use some details about that on the PR.

Other comments very, very minor (spacing/indent/naming)


DEFAULT_FILE_STORAGE = 'storages.backends.gcloud.GoogleCloudStorage'
GS_BUCKET_NAME = os.environ.get('GS_BUCKET_NAME', 'cos-osf-stage-osf-cdn')
# GOOGLE_APPLICATION_CREDENTIALS env var must be set
Copy link
Contributor

Choose a reason for hiding this comment

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

Discussed over zoom. Local dev might be interesting or require everyone to hook up staging key, some details written in the PR description might be nice.


class ProviderAssetFile(BaseModel):
name = models.CharField(max_length=63)
file = models.FileField(upload_to='assets')
Copy link
Contributor

Choose a reason for hiding this comment

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

Stupid minor; I personally don't like file as a name since it technically is a builtin... but we use it all over the place so whatev (https://docs.python.org/2/library/functions.html#file)

Copy link
Member Author

Choose a reason for hiding this comment

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

I had the same mixed feeling about it, but I think it's only bad practice when assigning locals to builtins, as local assignment will override them but attrs/fields/methods will not. Some examples (in addition to yours) would be that any TypedModel has a type field, or that Queryset objects have filter and all methods.

¯\_(ツ)_/¯

{% block content %}
<div class="row">
<div class="col-md-12">
{% if perms.osf.delete_asset_file %}
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 an extra space after {%


{% load static %}
{% block top_includes %}
<link rel="stylesheet" type="text/css" href="/static/css/institutions.css" />
Copy link
Contributor

Choose a reason for hiding this comment

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

inconsistent indent

@mfraezz mfraezz force-pushed the feature/django-storage-assets branch from 29bcd78 to 6f0ff31 Compare May 17, 2018 20:49
Copy link
Contributor

@sloria sloria left a comment

Choose a reason for hiding this comment

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

Looked over code but didn't check out locally. I don't see any blockers.

@mfraezz mfraezz force-pushed the feature/django-storage-assets branch 2 times, most recently from 1542109 to ee3a50b Compare May 18, 2018 14:48
@mfraezz mfraezz force-pushed the feature/django-storage-assets branch from ee3a50b to 5c6b08b Compare May 18, 2018 15:24
mfraezz added a commit to mfraezz/osf.io that referenced this pull request May 30, 2018
@mfraezz mfraezz merged commit 5c6b08b into CenterForOpenScience:release/next-interfaces May 31, 2018
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.

3 participants