Display graph for 1rm evolution
This commit is contained in:
parent
7f676068f8
commit
098d9d821c
6 changed files with 207 additions and 55 deletions
1
Pipfile
1
Pipfile
|
@ -14,6 +14,7 @@ gunicorn = "*"
|
|||
dj-database-url = "*"
|
||||
"psycopg2-binary" = "*"
|
||||
django-dotenv = "*"
|
||||
plotly = "*"
|
||||
|
||||
|
||||
[dev-packages]
|
||||
|
|
183
Pipfile.lock
generated
183
Pipfile.lock
generated
|
@ -1,20 +1,7 @@
|
|||
{
|
||||
"_meta": {
|
||||
"hash": {
|
||||
"sha256": "22b4bfbc1d497b2f1f362b483254e91ae7164879bf4c072932b36e9f9bbe91b9"
|
||||
},
|
||||
"host-environment-markers": {
|
||||
"implementation_name": "cpython",
|
||||
"implementation_version": "3.6.4",
|
||||
"os_name": "posix",
|
||||
"platform_machine": "x86_64",
|
||||
"platform_python_implementation": "CPython",
|
||||
"platform_release": "17.4.0",
|
||||
"platform_system": "Darwin",
|
||||
"platform_version": "Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64",
|
||||
"python_full_version": "3.6.4",
|
||||
"python_version": "3.6",
|
||||
"sys_platform": "darwin"
|
||||
"sha256": "9ce7378867a2feadabf9c87acdbede4038951b69db00e0e920576af5070c37b4"
|
||||
},
|
||||
"pipfile-spec": 6,
|
||||
"requires": {},
|
||||
|
@ -27,31 +14,56 @@
|
|||
]
|
||||
},
|
||||
"default": {
|
||||
"certifi": {
|
||||
"hashes": [
|
||||
"sha256:14131608ad2fd56836d33a71ee60fa1c82bc9d2c8d98b7bdbc631fe1b3cd1296",
|
||||
"sha256:edbc3f203427eef571f79a7692bb160a2b0f7ccaa31953e99bd17e307cf63f7d"
|
||||
],
|
||||
"version": "==2018.1.18"
|
||||
},
|
||||
"chardet": {
|
||||
"hashes": [
|
||||
"sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae",
|
||||
"sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"
|
||||
],
|
||||
"version": "==3.0.4"
|
||||
},
|
||||
"decorator": {
|
||||
"hashes": [
|
||||
"sha256:7d46dd9f3ea1cf5f06ee0e4e1277ae618cf48dfb10ada7c8427cd46c42702a0e",
|
||||
"sha256:94d1d8905f5010d74bbbd86c30471255661a14187c45f8d7f3e5aa8540fdb2e5"
|
||||
],
|
||||
"version": "==4.2.1"
|
||||
},
|
||||
"dj-database-url": {
|
||||
"hashes": [
|
||||
"sha256:851785365761ebe4994a921b433062309eb882fedd318e1b0fcecc607ed02da9",
|
||||
"sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163"
|
||||
"sha256:4aeaeb1f573c74835b0686a2b46b85990571159ffc21aa57ecd4d1e1cb334163",
|
||||
"sha256:851785365761ebe4994a921b433062309eb882fedd318e1b0fcecc607ed02da9"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.5.0"
|
||||
},
|
||||
"django": {
|
||||
"hashes": [
|
||||
"sha256:7c8ff92285406fb349e765e9ade685eec7271d6f5c3f918e495a74768b765c99",
|
||||
"sha256:dc3b61d054f1bced64628c62025d480f655303aea9f408e5996c339a543b45f0"
|
||||
"sha256:3d9916515599f757043c690ae2b5ea28666afa09779636351da505396cbb2f19",
|
||||
"sha256:769f212ffd5762f72c764fa648fca3b7f7dd4ec27407198b68e7c4abf4609fd0"
|
||||
],
|
||||
"version": "==2.0.2"
|
||||
"index": "pypi",
|
||||
"version": "==2.0.3"
|
||||
},
|
||||
"django-bootstrap4": {
|
||||
"hashes": [
|
||||
"sha256:6db4a27b33851833e68b96344f9df063150dcace8d4787ebfc21eceb55196945"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==0.0.6"
|
||||
},
|
||||
"django-dotenv": {
|
||||
"hashes": [
|
||||
"sha256:a9b1b40a70bd321acd231926acedb9bd2c5e873e33a1873b34a7276d196a765e",
|
||||
"sha256:3812bb0f4876cf31f902aad140f0645e120e51ee30eb7c40c22050f58a0e4adb"
|
||||
"sha256:3812bb0f4876cf31f902aad140f0645e120e51ee30eb7c40c22050f58a0e4adb",
|
||||
"sha256:a9b1b40a70bd321acd231926acedb9bd2c5e873e33a1873b34a7276d196a765e"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==1.4.2"
|
||||
},
|
||||
"djangorestframework": {
|
||||
|
@ -59,6 +71,7 @@
|
|||
"sha256:1f6baf40ed456ed2af6bd1a4ff8bbc3503cebea16509993aea2b7085bc097766",
|
||||
"sha256:9f9e94e8d22b100ed3a43cee8c47a7ff7b185e778a1f2da9ec5c73fc4e081b87"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==3.7.7"
|
||||
},
|
||||
"gunicorn": {
|
||||
|
@ -66,53 +79,125 @@
|
|||
"sha256:75af03c99389535f218cc596c7de74df4763803f7b63eb09d77e92b3956b36c6",
|
||||
"sha256:eee1169f0ca667be05db3351a0960765620dad53f53434262ff8901b68a1b622"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==19.7.1"
|
||||
},
|
||||
"idna": {
|
||||
"hashes": [
|
||||
"sha256:2c6a5de3089009e3da7c5dde64a141dbc8551d5b7f6cf4ed7c2568d0cc520a8f",
|
||||
"sha256:8c7309c718f94b3a625cb648ace320157ad16ff131ae0af362c9f21b80ef6ec4"
|
||||
],
|
||||
"version": "==2.6"
|
||||
},
|
||||
"ipython-genutils": {
|
||||
"hashes": [
|
||||
"sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8",
|
||||
"sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8"
|
||||
],
|
||||
"version": "==0.2.0"
|
||||
},
|
||||
"jsonschema": {
|
||||
"hashes": [
|
||||
"sha256:000e68abd33c972a5248544925a0cae7d1125f9bf6c58280d37546b946769a08",
|
||||
"sha256:6ff5f3180870836cae40f06fa10419f557208175f13ad7bc26caa77beb1f6e02"
|
||||
],
|
||||
"version": "==2.6.0"
|
||||
},
|
||||
"jupyter-core": {
|
||||
"hashes": [
|
||||
"sha256:927d713ffa616ea11972534411544589976b2493fc7e09ad946e010aa7eb9970",
|
||||
"sha256:ba70754aa680300306c699790128f6fbd8c306ee5927976cbe48adacf240c0b7"
|
||||
],
|
||||
"version": "==4.4.0"
|
||||
},
|
||||
"nbformat": {
|
||||
"hashes": [
|
||||
"sha256:b9a0dbdbd45bb034f4f8893cafd6f652ea08c8c1674ba83f2dc55d3955743b0b",
|
||||
"sha256:f7494ef0df60766b7cabe0a3651556345a963b74dbc16bc7c18479041170d402"
|
||||
],
|
||||
"version": "==4.4.0"
|
||||
},
|
||||
"plotly": {
|
||||
"hashes": [
|
||||
"sha256:9dd816c36271cf81d82c854fba866c743cbd8cc71f1c95384195307def859a69"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.5.1"
|
||||
},
|
||||
"psycopg2-binary": {
|
||||
"hashes": [
|
||||
"sha256:b287ddf4cafcfb632974907d1e7862119e36bb758228bdb07dd247553e4cdfc0",
|
||||
"sha256:d1dd3eb8edd354083f5d27b968c5a17854c41347ba5a480b520be85ec1a8495c",
|
||||
"sha256:cf3911fba0c47fc1313b5783183cda301032b14637a0b7a336766ae46998c7ee",
|
||||
"sha256:b039f51bca1ddd70234cc3f84f94f42ad43861b931bdfb497f887c60c39a6565",
|
||||
"sha256:83af04029bcb4b56c852e5876fef71340dcb465fa44fc99f80bac72e10fb0b74",
|
||||
"sha256:3a14baeabcebd4662f12f4bff03e0574a2369a2e41baf829e6fb4a24c95cf88b",
|
||||
"sha256:cb07184a4bfad304831f0a88b1c13fbd8cf9fcdf1f11e71c477dd6d7b1b078a0",
|
||||
"sha256:d0972f062c73956332e9681dfdb133168618f0abfecc96e89f0205ac89cd454b",
|
||||
"sha256:ab1db8f3e96570d9f7ebc45133ce2574804b2280499baade178e163d022107b5",
|
||||
"sha256:d51c7ed810fce1e50464088c37cc8da05534de8afb12a732500827ebcc480081",
|
||||
"sha256:b6b2b26590304d97ef2af28d153ee99ace6fe0806934f4618edfc87216c77f91",
|
||||
"sha256:9b5ddbed85ec73293695d7116589d956ef0dd3fcf7bf3b2a3bc1e8e54c1d543a",
|
||||
"sha256:02eb674e3d5810e19b4d5d00720b17130e182da1ba259dda608aaf33d787347d",
|
||||
"sha256:3a14baeabcebd4662f12f4bff03e0574a2369a2e41baf829e6fb4a24c95cf88b",
|
||||
"sha256:436a503eda41f6adb08f292f40a3784fce0a5f351b6ae7b19a911904db53af93",
|
||||
"sha256:8014c06a9ed7b78ba81beff3ae71acd78c212390f8ed839e9ce22735880bd5b4",
|
||||
"sha256:c4c6004d410c77bfa5389ae9485498ce32805447a67afbfe8db0d247a5c88fa1",
|
||||
"sha256:d8940b5104588d6313315e037f0f5ed68d2e5f62ccc1c429d3cff11d2ba6de3f",
|
||||
"sha256:c606bff0978ee4858d86d40f6b6ab0c4cac4474f627bd054683dc03a4fc1a366",
|
||||
"sha256:9305d7cbc802aaefac5c75a3df725f2654797369f32b18d4d0adb382dfab6c09",
|
||||
"sha256:4a1a5ea2fa4b53191637b162873a82822d92a85a08beefe28296b8eb5cf2fea5",
|
||||
"sha256:a3d2cc0cb0b988dbfd0d11f7fac34058b25a6ce533ed5b8e88d6cb315e77d54a",
|
||||
"sha256:86c0d2587f56776f25d52cca8e275adf495c8e01933fbfc2ca23b124610ab761",
|
||||
"sha256:77a2fc622a1f2d08a707673c9be5769d521f03d867d305f172bb417fa7882754",
|
||||
"sha256:4a4f23a08fbccbe40ecdb5384d807bcb469ea71dd87e6be2e80b036b8e6d47df",
|
||||
"sha256:c8220c521a408b41c4f14036004a621ed0d965941286b978cd2ea2623fabd755",
|
||||
"sha256:465ff1d427ed42c31e456dbbd9edab3552be18a0edaef7450c5b3e6fee745052",
|
||||
"sha256:4a1a5ea2fa4b53191637b162873a82822d92a85a08beefe28296b8eb5cf2fea5",
|
||||
"sha256:4a4f23a08fbccbe40ecdb5384d807bcb469ea71dd87e6be2e80b036b8e6d47df",
|
||||
"sha256:77a2fc622a1f2d08a707673c9be5769d521f03d867d305f172bb417fa7882754",
|
||||
"sha256:8014c06a9ed7b78ba81beff3ae71acd78c212390f8ed839e9ce22735880bd5b4",
|
||||
"sha256:83af04029bcb4b56c852e5876fef71340dcb465fa44fc99f80bac72e10fb0b74",
|
||||
"sha256:86c0d2587f56776f25d52cca8e275adf495c8e01933fbfc2ca23b124610ab761",
|
||||
"sha256:9305d7cbc802aaefac5c75a3df725f2654797369f32b18d4d0adb382dfab6c09",
|
||||
"sha256:9b5ddbed85ec73293695d7116589d956ef0dd3fcf7bf3b2a3bc1e8e54c1d543a",
|
||||
"sha256:a3d2cc0cb0b988dbfd0d11f7fac34058b25a6ce533ed5b8e88d6cb315e77d54a",
|
||||
"sha256:ab1db8f3e96570d9f7ebc45133ce2574804b2280499baade178e163d022107b5",
|
||||
"sha256:b039f51bca1ddd70234cc3f84f94f42ad43861b931bdfb497f887c60c39a6565",
|
||||
"sha256:b287ddf4cafcfb632974907d1e7862119e36bb758228bdb07dd247553e4cdfc0",
|
||||
"sha256:b6b2b26590304d97ef2af28d153ee99ace6fe0806934f4618edfc87216c77f91",
|
||||
"sha256:c4c6004d410c77bfa5389ae9485498ce32805447a67afbfe8db0d247a5c88fa1",
|
||||
"sha256:c606bff0978ee4858d86d40f6b6ab0c4cac4474f627bd054683dc03a4fc1a366",
|
||||
"sha256:c8220c521a408b41c4f14036004a621ed0d965941286b978cd2ea2623fabd755",
|
||||
"sha256:cb07184a4bfad304831f0a88b1c13fbd8cf9fcdf1f11e71c477dd6d7b1b078a0",
|
||||
"sha256:cf3911fba0c47fc1313b5783183cda301032b14637a0b7a336766ae46998c7ee",
|
||||
"sha256:d0972f062c73956332e9681dfdb133168618f0abfecc96e89f0205ac89cd454b",
|
||||
"sha256:d1dd3eb8edd354083f5d27b968c5a17854c41347ba5a480b520be85ec1a8495c",
|
||||
"sha256:d51c7ed810fce1e50464088c37cc8da05534de8afb12a732500827ebcc480081",
|
||||
"sha256:d8940b5104588d6313315e037f0f5ed68d2e5f62ccc1c429d3cff11d2ba6de3f",
|
||||
"sha256:de4f88f823037a71ea5ef3c1041d96b8a68d73343133edda684fd42f575bd9d7"
|
||||
],
|
||||
"index": "pypi",
|
||||
"version": "==2.7.4"
|
||||
},
|
||||
"pytz": {
|
||||
"hashes": [
|
||||
"sha256:ed6509d9af298b7995d69a440e2822288f2eca1681b8cce37673dbb10091e5fe",
|
||||
"sha256:f93ddcdd6342f94cea379c73cddb5724e0d6d0a1c91c9bdef364dc0368ba4fda",
|
||||
"sha256:61242a9abc626379574a166dc0e96a66cd7c3b27fc10868003fa210be4bff1c9",
|
||||
"sha256:ba18e6a243b3625513d85239b3e49055a2f0318466e0b8a92b8fb8ca7ccdf55f",
|
||||
"sha256:07edfc3d4d2705a20a6e99d97f0c4b61c800b8232dc1c04d87e8554f130148dd",
|
||||
"sha256:3a47ff71597f821cd84a162e71593004286e5be07a340fd462f0d33a760782b5",
|
||||
"sha256:410bcd1d6409026fbaa65d9ed33bf6dd8b1e94a499e32168acfc7b332e4095c0",
|
||||
"sha256:5bd55c744e6feaa4d599a6cbd8228b4f8f9ba96de2c38d56f08e534b3c9edf0d",
|
||||
"sha256:61242a9abc626379574a166dc0e96a66cd7c3b27fc10868003fa210be4bff1c9",
|
||||
"sha256:887ab5e5b32e4d0c86efddd3d055c1f363cbaa583beb8da5e22d2fa2f64d51ef",
|
||||
"sha256:410bcd1d6409026fbaa65d9ed33bf6dd8b1e94a499e32168acfc7b332e4095c0"
|
||||
"sha256:ba18e6a243b3625513d85239b3e49055a2f0318466e0b8a92b8fb8ca7ccdf55f",
|
||||
"sha256:ed6509d9af298b7995d69a440e2822288f2eca1681b8cce37673dbb10091e5fe",
|
||||
"sha256:f93ddcdd6342f94cea379c73cddb5724e0d6d0a1c91c9bdef364dc0368ba4fda"
|
||||
],
|
||||
"version": "==2018.3"
|
||||
},
|
||||
"requests": {
|
||||
"hashes": [
|
||||
"sha256:6a1b267aa90cac58ac3a765d067950e7dbbf75b1da07e895d1f594193a40a38b",
|
||||
"sha256:9c443e7324ba5b85070c4a818ade28bfabedf16ea10206da1132edaa6dda237e"
|
||||
],
|
||||
"version": "==2.18.4"
|
||||
},
|
||||
"six": {
|
||||
"hashes": [
|
||||
"sha256:70e8a77beed4562e7f14fe23a786b54f6296e34344c23bc42f07b15018ff98e9",
|
||||
"sha256:832dc0e10feb1aa2c68dcc57dbb658f1c7e65b9b61af69048abc87a2db00a0eb"
|
||||
],
|
||||
"version": "==1.11.0"
|
||||
},
|
||||
"traitlets": {
|
||||
"hashes": [
|
||||
"sha256:9c4bd2d267b7153df9152698efb1050a5d84982d3384a37b2c1f7723ba3e7835",
|
||||
"sha256:c6cb5e6f57c5a9bdaa40fa71ce7b4af30298fbab9ece9815b5d995ab6217c7d9"
|
||||
],
|
||||
"version": "==4.3.2"
|
||||
},
|
||||
"urllib3": {
|
||||
"hashes": [
|
||||
"sha256:06330f386d6e4b195fbfc736b297f58c5a892e4440e54d294d7004e3a9bbea1b",
|
||||
"sha256:cc44da8e1145637334317feebd728bd869a35285b93cbb4cca2577da7e62db4f"
|
||||
],
|
||||
"version": "==1.22"
|
||||
}
|
||||
},
|
||||
"develop": {}
|
||||
|
|
|
@ -9,13 +9,15 @@
|
|||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h2>Max théorique</h2>
|
||||
{% if equipment.theoretical_maxs.all %}
|
||||
{% if equipment.last_theoretical_max %}
|
||||
<ul class="list-group">
|
||||
{% for max in equipment.theoretical_maxs.all %}
|
||||
<li class="list-group-item">
|
||||
{{ max }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li class="list-group-item">
|
||||
{{ equipment.last_theoretical_max }}
|
||||
</li>
|
||||
<a href="{% url 'theoretical-max-list' equipment.pk %}"
|
||||
class="list-group-item list-group-item-action">
|
||||
Voir tous...
|
||||
</a>
|
||||
</ul>
|
||||
{% else %}
|
||||
<p>Pas de max théorique pour le moment.</p>
|
||||
|
|
23
gym/templates/gym/theoretical_max_list.html
Normal file
23
gym/templates/gym/theoretical_max_list.html
Normal file
|
@ -0,0 +1,23 @@
|
|||
{% extends 'gym/base.html' %}
|
||||
{% load bootstrap4 %}
|
||||
|
||||
{% block title %}Max théoriques - {{ equipment }}{% endblock %}
|
||||
{% block h1 %}Max théoriques <small>{{ equipment }}</small>{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h2>Données</h2>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<ul class="list-group">
|
||||
{% for max in maxs %}
|
||||
<li class="list-group-item">{{ max }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
{{ graph|safe }}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -9,6 +9,7 @@ urlpatterns = [
|
|||
path('rooms/<int:pk>/', views.RoomDetailView.as_view(), name='room-detail'),
|
||||
path('equipment/add/', views.EquipmentCreateView.as_view(), name='equipment-create'),
|
||||
path('equipment/<int:pk>/', views.EquipmentDetailView.as_view(), name='equipment-detail'),
|
||||
path('equipment/<int:pk>/maxs', views.TheoreticalMaxListView.as_view(), name='theoretical-max-list'),
|
||||
path('setting/add/', views.SettingCreateView.as_view(), name='setting-create'),
|
||||
path('setting/<int:pk>/', views.SettingUpdateView.as_view(), name='setting-edit'),
|
||||
path('setting/<int:pk>/delete/', views.SettingDeleteView.as_view(), name='setting-delete'),
|
||||
|
|
40
gym/views.py
40
gym/views.py
|
@ -1,5 +1,7 @@
|
|||
import datetime
|
||||
|
||||
import plotly
|
||||
import plotly.graph_objs as go
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.urls import reverse
|
||||
|
@ -267,6 +269,44 @@ class TheoreticalMaxCreateView(LoginRequiredMixin, QuickActionsMixin, generic.Cr
|
|||
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
||||
|
||||
|
||||
class TheoreticalMaxListView(LoginRequiredMixin, QuickActionsMixin, generic.ListView):
|
||||
model = TheoreticalMax
|
||||
template_name = 'gym/theoretical_max_list.html'
|
||||
context_object_name = 'maxs'
|
||||
equipment = None
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
pk = self.kwargs.pop('pk')
|
||||
self.equipment = get_object_or_404(Equipment, pk=pk)
|
||||
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_queryset(self):
|
||||
return TheoreticalMax.objects.filter(equipment=self.equipment).order_by('date')
|
||||
|
||||
def get_quick_actions(self):
|
||||
return [
|
||||
{
|
||||
'url': reverse('equipment-detail', args=(self.equipment.pk,)),
|
||||
'category': 'secondary',
|
||||
'display': 'Retourner à la machine'
|
||||
},
|
||||
]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
graph = plotly.offline.plot({
|
||||
"data": [go.Scatter(x=[max.date for max in self.get_queryset()], y=[max.value for max in self.get_queryset()])],
|
||||
"layout": go.Layout(title="Évolution du max théorique",
|
||||
yaxis={"title": "Charge ({})".format(self.equipment.unit.name)},
|
||||
xaxis={"title": "Date"}),
|
||||
}, auto_open=False, output_type='div')
|
||||
|
||||
context['graph'] = graph
|
||||
context['equipment'] = self.equipment
|
||||
return context
|
||||
|
||||
|
||||
class SessionCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||
model = Session
|
||||
fields = ['room', 'start', 'default_theoretical_max_percentage']
|
||||
|
|
Loading…
Reference in a new issue