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

feat: Translations Downloads as zip #5624

Merged
merged 12 commits into from Mar 28, 2019

Conversation

mrsaicharan1
Copy link
Member

@mrsaicharan1 mrsaicharan1 commented Feb 20, 2019

Fixes #5619

Checklist

  • I have read the Contribution & Best practices Guide and my PR follows them.
  • My branch is up-to-date with the Upstream development branch.
  • The unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)
  • All the functions created/modified in this PR contain relevant docstrings.

Short description of what this resolves:

  • Added route for translation downloads
  • Implemented removal of .zip file as an asynchronous celery task(30mins countdown)

Changes proposed in this pull request:

  • zip messages.po files and uuid append
  • Downloading them at the same time
  • Task for removing the generated zip file as a part of garbage collection

app/api/admin_translations.py Outdated Show resolved Hide resolved
app/api/admin_translations.py Outdated Show resolved Hide resolved
app/api/admin_translations.py Outdated Show resolved Hide resolved
app/api/admin_translations.py Outdated Show resolved Hide resolved
app/api/admin_translations.py Outdated Show resolved Hide resolved
app/api/admin_translations.py Outdated Show resolved Hide resolved
app/api/admin_translations.py Outdated Show resolved Hide resolved
app/api/admin_translations.py Outdated Show resolved Hide resolved
app/api/admin_translations.py Outdated Show resolved Hide resolved
app/api/admin_translations.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Feb 20, 2019

Codecov Report

Merging #5624 into development will decrease coverage by 0.03%.
The diff coverage is 48%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #5624      +/-   ##
===============================================
- Coverage        64.31%   64.28%   -0.04%     
===============================================
  Files              273      274       +1     
  Lines            13178    13203      +25     
===============================================
+ Hits              8476     8488      +12     
- Misses            4702     4715      +13
Impacted Files Coverage Δ
app/__init__.py 83.81% <100%> (+0.18%) ⬆️
app/api/helpers/tasks.py 17.16% <20%> (+0.04%) ⬆️
app/api/admin_translations.py 50% <50%> (ø)

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 f08b9ab...c7d4429. Read the comment docs.

@fossasia fossasia deleted a comment Feb 21, 2019
@fossasia fossasia deleted a comment Feb 21, 2019
@fossasia fossasia deleted a comment Feb 21, 2019
@fossasia fossasia deleted a comment Feb 21, 2019
@fossasia fossasia deleted a comment Feb 21, 2019
@fossasia fossasia deleted a comment Feb 21, 2019
@fossasia fossasia deleted a comment Feb 21, 2019
@mrsaicharan1 mrsaicharan1 changed the title Translations fix feat: Translations Downloads as zip Feb 21, 2019
@mrsaicharan1 mrsaicharan1 force-pushed the translations-fix branch 2 times, most recently from e709baf to 4bce795 Compare February 21, 2019 22:03
@fossasia fossasia deleted a comment Feb 21, 2019
@fossasia fossasia deleted a comment Feb 21, 2019
@fossasia fossasia deleted a comment Feb 21, 2019
@fossasia fossasia deleted a comment Feb 21, 2019
@mrsaicharan1
Copy link
Member Author

@iamareebjamal Can you please review this?

@mrsaicharan1
Copy link
Member Author

I've kept remove_file under the after_this_request context. Codacy pulls up a coding standard error because of that. @iamareebjamal Any suggestions on how to go about this?

@iamareebjamal
Copy link
Member

Ignore codacy

def remove_file(response):
os.remove(os.path.join(app_dir, 'translations.zip'))
return response
return send_file('translations.zip', mimetype='application/zip',
Copy link
Member

Choose a reason for hiding this comment

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

Move this line to correct place

Copy link
Member Author

Choose a reason for hiding this comment

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

@after_this_request is getting skipped if I move the line upwards. You were referring to move the return send_file('translations.zip', mimetype='application/zip', as_attachment=True, attachment_filename='translations.zip'),above @after_this_request, right? Did I get you wrong ?

Copy link
Member

Choose a reason for hiding this comment

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

Yes I was referring to that

Copy link
Member Author

Choose a reason for hiding this comment

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

Alright, will do it.

@fossasia fossasia deleted a comment Mar 16, 2019
@iamareebjamal
Copy link
Member

How can we obtain a human-readable message to log?

You simply write "Error while deleting translations zip file "

app/api/admin_translations.py Outdated Show resolved Hide resolved
@mrsaicharan1 mrsaicharan1 force-pushed the translations-fix branch 3 times, most recently from cdee44e to 5e83dfc Compare March 18, 2019 16:27
app/api/helpers/tasks.py Outdated Show resolved Hide resolved
app/api/helpers/tasks.py Outdated Show resolved Hide resolved
app/api/helpers/tasks.py Outdated Show resolved Hide resolved
@mrsaicharan1 mrsaicharan1 changed the title feat: Translations Downloads as zip [WIP]feat: Translations Downloads as zip Mar 19, 2019
@fossasia fossasia deleted a comment Mar 19, 2019
@fossasia fossasia deleted a comment Mar 19, 2019
Blueprint registration
@mrsaicharan1 mrsaicharan1 changed the title [WIP]feat: Translations Downloads as zip feat: Translations Downloads as zip Mar 21, 2019
@mrsaicharan1
Copy link
Member Author

@iamareebjamal Here is the updated PR

@@ -13,8 +13,9 @@ def download_translations():
"""Admin Translations Downloads"""
uuid_literal = uuid.uuid4()
zip_file = "translations{}".format(uuid_literal)
zip_file_ext = zip_file+'.zip'
shutil.make_archive(zip_file, "zip", translations_dir)
Copy link
Member

Choose a reason for hiding this comment

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

Pass zip_file_ext in this function

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. Sending a PR right now.

@mrsaicharan1
Copy link
Member Author

mrsaicharan1 commented Mar 28, 2019

@CosmicCoder96 Please review.

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.

Translations download not working for Admin(.po messages)
4 participants