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

[Feature #159236209] Export and Import workouts #31

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

wasswa-derick
Copy link
Contributor

What does this PR do?

  • Export workouts
  • Import workouts

Description of Task to be completed?

  • Add buttons to trigger exportation and importation of workouts.
  • Create the export URL action handler.
  • Implement export and import workouts functionality.
  • Reuse the overview URL for the importation of workouts.
  • Test export and import workouts functions
  • Resolve flake8 errors

How should this be manually tested?

  • Clone the project, https://github.com/andela/wg-wits.git.
  • In your terminal, cd wg-wits
  • Checkout to the ft-export-workouts-159236209 branch.
  • In the project directory, create a virtual environment and activate it: run virtualenv -p python3 venv-django then source venv-django/bin/activate
  • Serve the application python manage.py runserver
  • In the browser, visit http://127.0.0.1:8000/en/workout/overview to go to the workouts view.
  • Add some workouts and attempt to export them (a JSON file shall prompt you to download it).
  • Signup as a different user and Import that file.
  • Those workouts shall be imported for that user.

What are the relevant pivotal tracker stories?

#159236209

Screenshots (if appropriate)

  • Export workouts

screen shot 2018-08-29 at 15 35 53

  • Disable Export if no workouts

screen shot 2018-08-29 at 15 37 28

  • Import with not file chosen

screen shot 2018-08-29 at 15 37 43

  • Importation with corrupted JSON file

screen shot 2018-08-29 at 15 37 59

  • Choose JSON file to import

screen shot 2018-08-29 at 15 39 22

  • Importation Result

screen shot 2018-08-29 at 15 39 37

@coveralls
Copy link

coveralls commented Aug 29, 2018

Pull Request Test Coverage Report for Build 532

  • 87 of 116 (75.0%) changed or added relevant lines in 2 files are covered.
  • 13 unchanged lines in 6 files lost coverage.
  • Overall coverage decreased (-0.2%) to 93.01%

Changes Missing Coverage Covered Lines Changed/Added Lines %
wger/manager/views/workout.py 33 62 53.23%
Files with Coverage Reduction New Missed Lines %
wger/exercises/tests/test_equipment.py 1 100.0%
wger/exercises/tests/test_categories.py 1 100.0%
wger/core/tests/base_testcase.py 2 97.4%
wger/manager/forms.py 2 100.0%
wger/manager/views/set.py 3 96.33%
wger/exercises/tests/test_exercise.py 4 100.0%
Totals Coverage Status
Change from base Build 528: -0.2%
Covered Lines: 12788
Relevant Lines: 13749

💛 - Coveralls

{% block options %}
<div class="dropdown">
<button class="btn btn-success dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
Add workout
<span class="caret"></span>
</button>

Copy link
Contributor

Choose a reason for hiding this comment

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

Kindly remove these irrelevant blank lines, you added.

<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a href="{% url 'manager:workout:add' %}?cycle=micro">Microcycle: One week plan</a></li>
<li><a href="{% url 'manager:workout:add' %}?cycle=meso">Mesocycle: Two to six weeks plan</a></li>
<li><a href="{% url 'manager:workout:add' %}?cycle=macro">Macrocycle: One year plan</a></li>
</ul>

Copy link
Contributor

Choose a reason for hiding this comment

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

Kindly remove these irrelevant blank lines, you added.


from django.shortcuts import render, get_object_or_404
from django.shortcuts import render, redirect, get_object_or_404
Copy link
Contributor

Choose a reason for hiding this comment

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

Kindly remove unused import redirect .

@@ -48,6 +64,8 @@
WgerDeleteMixin
)
from wger.utils.helpers import make_token
from django.http import HttpResponse
Copy link
Contributor

Choose a reason for hiding this comment

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

Kindly move these imports to the top of the file.

messages.info(request, 'No File was Chosen for Importation!')
return HttpResponseRedirect('overview')

file = request.FILES['workoutfile']
Copy link
Contributor

Choose a reason for hiding this comment

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

Move file into the try block and use one try block

* Create the export url action handler
* Implement export and import workouts functionality
* Test export and import workouts functions
* Resolve flake8 errors
* Remove unused modules
* Remove unnecessary blank lines
* Correct imports and structure of the try statements

[Delivers #159236209]
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.

None yet

3 participants