Giter Club home page Giter Club logo

spartan's Introduction

Spartan

Personal activity tracker for both strength and cardio (GPS tracked) excercises.

Live version is here: http://145.239.84.96 (I couldn't find any cool domain, sorry :))

Deployment and development

Spartan is built into single Docker image which serve the application and static files on port 8000. There is also a Makefile for common tasks so you won't need to remember all those docker parameters. Obviously you need to have Docker installed. On newest Ubuntu you can do this through sudo apt install docker.io.

Tests

Spartan has two level of testing. Unit tests lives near application modules, eg training/tests/test_hexagons.py while higher level testing are in global tests directory.

All of them are managed by pytest which is integrated with django. The easiest way to run them is to use make test as it will handle all docker stuff.

How to run locally

You can start debug server using docker-compose:

docker-compose up

It will run the same docker image that is used in production but with DEBUG environment variable passed into the container. DEBUG will change some things.

  • Python logger is set to debug level
  • SQLite is used as database, db.sqlite3 will be created in current directory

After starting, application will be available on port 8000.

Deployment

Spartan image doesn't come with the database (except the SQLite which is used only in DEBUG mode) so you have to install it manually (on your host OS or by using docker aswell - docker-compose might be usefull in this case).

When you have your database ready, you can pass its configuration though environment variables: DB_ENGINE DB_NAME DB_USER DB_PASSWORD DB_HOST. You can check django documentation to find out what to put in here.

When you have those covered, you can start the container and leave the management to Docker by using --restart always flag to run command. This way, the container will be running on your machine all the time.

At this point, you database is most likely empty so before using the application, you have to migrate the models.

[TODO]

Deployment (new)

Spartan comes with docker-compose configuration which should be preferred way to start the application.

docker-compose build
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d

Django models are migrated at each startup in dokcer-entrypoint.sh.

spartan's People

Contributors

podusowski avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

spartan's Issues

crash after importing endo

[Tue Jul 25 09:35:06.016325 2017] [wsgi:error] [pid 16676:tid 139925326391040] ERROR:django.request:Internal Server Error: /dashboard
[Tue Jul 25 09:35:06.016356 2017] [wsgi:error] [pid 16676:tid 139925326391040] Traceback (most recent call last):
[Tue Jul 25 09:35:06.016360 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/core/handlers/exception.py", line 41, in inner
[Tue Jul 25 09:35:06.016364 2017] [wsgi:error] [pid 16676:tid 139925326391040] response = get_response(request)
[Tue Jul 25 09:35:06.016367 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
[Tue Jul 25 09:35:06.016370 2017] [wsgi:error] [pid 16676:tid 139925326391040] response = self._get_response(request)
[Tue Jul 25 09:35:06.016373 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Tue Jul 25 09:35:06.016376 2017] [wsgi:error] [pid 16676:tid 139925326391040] response = self.process_exception_by_middleware(e, request)
[Tue Jul 25 09:35:06.016392 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 185, in _get_response
[Tue Jul 25 09:35:06.016396 2017] [wsgi:error] [pid 16676:tid 139925326391040] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Tue Jul 25 09:35:06.016399 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/contrib/auth/decorators.py", line 23, in _wrapped_view
[Tue Jul 25 09:35:06.016402 2017] [wsgi:error] [pid 16676:tid 139925326391040] return view_func(request, *args, **kwargs)
[Tue Jul 25 09:35:06.016405 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/training/views.py", line 53, in dashboard
[Tue Jul 25 09:35:06.016408 2017] [wsgi:error] [pid 16676:tid 139925326391040] 'goals': goals})
[Tue Jul 25 09:35:06.016411 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/shortcuts.py", line 30, in render
[Tue Jul 25 09:35:06.016414 2017] [wsgi:error] [pid 16676:tid 139925326391040] content = loader.render_to_string(template_name, context, request, using=using)
[Tue Jul 25 09:35:06.016416 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/loader.py", line 68, in render_to_string
[Tue Jul 25 09:35:06.016419 2017] [wsgi:error] [pid 16676:tid 139925326391040] return template.render(context, request)
[Tue Jul 25 09:35:06.016422 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/backends/django.py", line 66, in render
[Tue Jul 25 09:35:06.016425 2017] [wsgi:error] [pid 16676:tid 139925326391040] return self.template.render(context)
[Tue Jul 25 09:35:06.016427 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 207, in render
[Tue Jul 25 09:35:06.016430 2017] [wsgi:error] [pid 16676:tid 139925326391040] return self._render(context)
[Tue Jul 25 09:35:06.016433 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 199, in _render
[Tue Jul 25 09:35:06.016435 2017] [wsgi:error] [pid 16676:tid 139925326391040] return self.nodelist.render(context)
[Tue Jul 25 09:35:06.016438 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 990, in render
[Tue Jul 25 09:35:06.016441 2017] [wsgi:error] [pid 16676:tid 139925326391040] bit = node.render_annotated(context)
[Tue Jul 25 09:35:06.016444 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 957, in render_annotated
[Tue Jul 25 09:35:06.016446 2017] [wsgi:error] [pid 16676:tid 139925326391040] return self.render(context)
[Tue Jul 25 09:35:06.016449 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/loader_tags.py", line 177, in render
[Tue Jul 25 09:35:06.016452 2017] [wsgi:error] [pid 16676:tid 139925326391040] return compiled_parent._render(context)
[Tue Jul 25 09:35:06.016454 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 199, in _render
[Tue Jul 25 09:35:06.016457 2017] [wsgi:error] [pid 16676:tid 139925326391040] return self.nodelist.render(context)
[Tue Jul 25 09:35:06.016460 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 990, in render
[Tue Jul 25 09:35:06.016462 2017] [wsgi:error] [pid 16676:tid 139925326391040] bit = node.render_annotated(context)
[Tue Jul 25 09:35:06.016465 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 957, in render_annotated
[Tue Jul 25 09:35:06.016471 2017] [wsgi:error] [pid 16676:tid 139925326391040] return self.render(context)
[Tue Jul 25 09:35:06.016474 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/loader_tags.py", line 72, in render
[Tue Jul 25 09:35:06.016477 2017] [wsgi:error] [pid 16676:tid 139925326391040] result = block.nodelist.render(context)
[Tue Jul 25 09:35:06.016479 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 990, in render
[Tue Jul 25 09:35:06.016482 2017] [wsgi:error] [pid 16676:tid 139925326391040] bit = node.render_annotated(context)
[Tue Jul 25 09:35:06.016485 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 957, in render_annotated
[Tue Jul 25 09:35:06.016487 2017] [wsgi:error] [pid 16676:tid 139925326391040] return self.render(context)
[Tue Jul 25 09:35:06.016490 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/defaulttags.py", line 216, in render
[Tue Jul 25 09:35:06.016493 2017] [wsgi:error] [pid 16676:tid 139925326391040] nodelist.append(node.render_annotated(context))
[Tue Jul 25 09:35:06.016496 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 957, in render_annotated
[Tue Jul 25 09:35:06.016498 2017] [wsgi:error] [pid 16676:tid 139925326391040] return self.render(context)
[Tue Jul 25 09:35:06.016501 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/defaulttags.py", line 216, in render
[Tue Jul 25 09:35:06.016504 2017] [wsgi:error] [pid 16676:tid 139925326391040] nodelist.append(node.render_annotated(context))
[Tue Jul 25 09:35:06.016506 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 957, in render_annotated
[Tue Jul 25 09:35:06.016509 2017] [wsgi:error] [pid 16676:tid 139925326391040] return self.render(context)
[Tue Jul 25 09:35:06.016512 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/defaulttags.py", line 216, in render
[Tue Jul 25 09:35:06.016515 2017] [wsgi:error] [pid 16676:tid 139925326391040] nodelist.append(node.render_annotated(context))
[Tue Jul 25 09:35:06.016517 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 957, in render_annotated
[Tue Jul 25 09:35:06.016520 2017] [wsgi:error] [pid 16676:tid 139925326391040] return self.render(context)
[Tue Jul 25 09:35:06.016523 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 1046, in render
[Tue Jul 25 09:35:06.016525 2017] [wsgi:error] [pid 16676:tid 139925326391040] return render_value_in_context(output, context)
[Tue Jul 25 09:35:06.016528 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/template/base.py", line 1024, in render_value_in_context
[Tue Jul 25 09:35:06.016531 2017] [wsgi:error] [pid 16676:tid 139925326391040] value = force_text(value)
[Tue Jul 25 09:35:06.016534 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/env/lib/python3.4/site-packages/django/utils/encoding.py", line 76, in force_text
[Tue Jul 25 09:35:06.016536 2017] [wsgi:error] [pid 16676:tid 139925326391040] s = six.text_type(s)
[Tue Jul 25 09:35:06.016539 2017] [wsgi:error] [pid 16676:tid 139925326391040] File "/var/www/spartan/training/units.py", line 57, in str
[Tue Jul 25 09:35:06.016544 2017] [wsgi:error] [pid 16676:tid 139925326391040] if self.type == Volume.Type.DISTANCE:
[Tue Jul 25 09:35:06.016549 2017] [wsgi:error] [pid 16676:tid 139925326391040] AttributeError: 'Volume' object has no attribute 'type'

DivisionByZero when viewing statistics

Template error:
In template /home/kasia/Development/spartan/statistics/templates/statistics/workout.html, error at line 7
   division by zero   1 : {% extends "statistics/base.html" %}
   2 : 
   3 : {% block content %}
   4 : 
   5 : <section>
   6 :     <h2>{{ workout.name }}</h2>
   7 :      {% for name, value in workout.metrics.items %} 
   8 :         <dl class="metric-long">
   9 :             <dt>{{ name }}</dt>
   10 :             <dd>{{ value }}</dd>
   11 :         </dl>
   12 :     {% endfor %}
   13 : </section>
   14 : 
   15 : <section>
   16 :     <h2>goal</h2>
   17 :     {% if goal %}


Traceback:

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  39.             response = get_response(request)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "/home/kasia/Development/spartan/statistics/views.py" in workout
  22.     return render(request, 'statistics/workout.html', {'workout': workout, 'goal': goal})

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/shortcuts.py" in render
  30.     content = loader.render_to_string(template_name, context, request, using=using)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/loader.py" in render_to_string
  68.     return template.render(context, request)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/backends/django.py" in render
  66.             return self.template.render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in render
  208.                     return self._render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/loader_tags.py" in render
  174.         return compiled_parent._render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/loader_tags.py" in render
  174.         return compiled_parent._render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in _render
  199.         return self.nodelist.render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/loader_tags.py" in render
  70.                 result = block.nodelist.render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in render
  994.                 bit = node.render_annotated(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in render_annotated
  961.             return self.render(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/defaulttags.py" in render
  159.                 values = self.sequence.resolve(context, True)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in resolve
  711.                 obj = self.var.resolve(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in resolve
  852.             value = self._resolve_lookup(context)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/template/base.py" in _resolve_lookup
  915.                             current = current()

File "/home/kasia/Development/spartan/statistics/statistics.py" in metrics
  79.                 result.update(app_statistics.workout(self.user, self.name))

File "/home/kasia/Development/spartan/activities/strength/local_statistics.py" in workout
  26.             ('average reps per series', round(reps / series)),

Exception Type: ZeroDivisionError at /statistics/workout/ef
Exception Value: division by zero

exception when syncing endomondo

Traceback:  

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  39.             response = get_response(request)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _legacy_get_response
  249.             response = self._get_response(request)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  187.                 response = self.process_exception_by_middleware(e, request)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  185.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
  23.                 return view_func(request, *args, **kwargs)

File "/home/kasia/Development/spartan/env/lib/python3.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/home/kasia/Development/spartan/activities/gps/views.py" in synchronize_endomondo_ajax
  66.     count = endo.synchronize_endomondo(request.user, 10)

File "/home/kasia/Development/spartan/activities/gps/endomondo.py" in synchronize_endomondo
  54.         if not gps_workout.exists(user,

Exception Type: NameError at /gps/synchronize_endomondo_ajax/
Exception Value: name 'gps_workout' is not defined

wallpapers

use some cool photos as page background

"new workout" page

New page for starting strength workout or importing it from gpx/endomondo. There should be no "start workout" button which adds something to db.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.