Refactor code
This commit is contained in:
parent
ff7e12759d
commit
93ffa1ae85
12 changed files with 161 additions and 101 deletions
|
@ -4,3 +4,13 @@ class SessionResetMixin:
|
||||||
del request.session['session_pk']
|
del request.session['session_pk']
|
||||||
|
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
class QuickActionsMixin:
|
||||||
|
def get_quick_actions(self):
|
||||||
|
return []
|
||||||
|
|
||||||
|
def get_context_data(self, **kwargs):
|
||||||
|
context = super().get_context_data(**kwargs)
|
||||||
|
context['quick_actions'] = self.get_quick_actions()
|
||||||
|
return context
|
||||||
|
|
|
@ -22,6 +22,28 @@
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12">
|
||||||
|
<h1>{% block h1 %}{% endblock %}</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% block quick_actions %}
|
||||||
|
{% if quick_actions %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 d-none d-md-block"> {# Visible only on large screens #}
|
||||||
|
{% for qa in quick_actions %}
|
||||||
|
<a href="{{ qa.url }}" class="btn btn-{{ qa.category }}">{{ qa.display }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<div class="col-12 d-md-none"> {# Visible only on small screens #}
|
||||||
|
{% for qa in quick_actions %}
|
||||||
|
<a href="{{ qa.url }}" class="btn btn-{{ qa.category }} btn-block">{{ qa.display }}</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
{% extends 'gym/base.html' %}
|
{% extends 'gym/base.html' %}
|
||||||
{% load humanize %}
|
{% load humanize %}
|
||||||
|
|
||||||
{% block content %}
|
{% block title %}{{ equipment.name }} ({{ equipment.room.name }}){% endblock %}
|
||||||
<div class="row">
|
{% block h1 %}{{ equipment.name }} <small class="text-muted">({{ equipment.room.name }})</small>{% endblock %}
|
||||||
<div class="col-12">
|
|
||||||
<h1>{% block title %}{{ equipment.name }} <small class="text-muted">({{ equipment.room.name }})</small>{% endblock %}</h1>
|
{% block quick_actions %}
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
{% if session %}
|
{% if session %}
|
||||||
|
@ -26,6 +24,9 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h2>Max théorique</h2>
|
<h2>Max théorique</h2>
|
||||||
|
|
|
@ -1,17 +1,10 @@
|
||||||
{% extends 'gym/base.html' %}
|
{% extends 'gym/base.html' %}
|
||||||
{% load bootstrap4 %}
|
{% load bootstrap4 %}
|
||||||
|
|
||||||
|
{% block title %}Ajouter une machine{% endblock %}
|
||||||
|
{% block h1 %}Ajouter une machine{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h1>{% block title %}Ajouter une machine{% endblock %}</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<a href="{% url 'room-detail' room.pk %}" class="btn btn-secondary">Retourner à la salle</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
|
|
|
@ -1,18 +1,9 @@
|
||||||
{% extends 'gym/base.html' %}
|
{% extends 'gym/base.html' %}
|
||||||
|
|
||||||
|
{% block title %}{{ room.name }}{% endblock %}
|
||||||
|
{% block h1 %}{{ room.name }}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h1>{% block title %}{{ room.name }}{% endblock %}</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<a href="{% url 'rooms-list' %}" class="btn btn-secondary">Liste des salles</a>
|
|
||||||
<a href="{% url 'equipment-create' %}?room={{ room.pk }}" class="btn btn-success">Ajouter une machine</a>
|
|
||||||
<a href="{% url 'session-start' %}?room={{ room.pk }}" class="btn btn-primary">Commencer une séance</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h2>Machines</h2>
|
<h2>Machines</h2>
|
||||||
|
|
|
@ -3,19 +3,10 @@
|
||||||
{% load static %}
|
{% load static %}
|
||||||
{% load l10n %}
|
{% load l10n %}
|
||||||
|
|
||||||
|
{% block title %}{{ title }} une série{% endblock %}
|
||||||
|
{% block h1 %}{{ title }} une série{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h1>{% block title %}{{ title }} une série{% endblock %}</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
{% if equipment %}
|
|
||||||
<a href="{% url 'equipment-detail' equipment.pk %}" class="btn btn-secondary">Retourner à la machine</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
|
|
|
@ -1,18 +1,10 @@
|
||||||
{% extends 'gym/base.html' %}
|
{% extends 'gym/base.html' %}
|
||||||
{% load bootstrap4 %}
|
{% load bootstrap4 %}
|
||||||
|
|
||||||
|
{% block title %}Séance en cours{% endblock %}
|
||||||
|
{% block h1 %}Séance en cours{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h1>{% block title %}Séance en cours{% endblock %}</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<a href="{% url 'room-detail' session.room.pk %}" class="btn btn-secondary">Retourner à la salle</a>
|
|
||||||
<a href="{% url 'equipment-create' %}?room={{ session.room.pk }}" class="btn btn-success">Ajouter une machine</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<h2>Infos</h2>
|
<h2>Infos</h2>
|
||||||
|
|
|
@ -1,19 +1,10 @@
|
||||||
{% extends 'gym/base.html' %}
|
{% extends 'gym/base.html' %}
|
||||||
{% load bootstrap4 %}
|
{% load bootstrap4 %}
|
||||||
|
|
||||||
|
{% block title %}{{ title }} une séance{% endblock %}
|
||||||
|
{% block h1 %}{{ title }} une séance{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h1>{% block title %}{{ title }} une séance{% endblock %}</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
{% if room %}
|
|
||||||
<a href="{% url 'room-detail' room.pk %}" class="btn btn-secondary">Retourner à la salle</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
{% extends 'gym/base.html' %}
|
{% extends 'gym/base.html' %}
|
||||||
{% load bootstrap4 %}
|
{% load bootstrap4 %}
|
||||||
|
|
||||||
|
{% block title %}Supprimer un réglage{% endblock %}
|
||||||
|
{% block h1 %}Supprimer un réglage{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h1>{% block title %}Supprimer un réglage{% endblock %}</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
|
|
|
@ -1,19 +1,10 @@
|
||||||
{% extends 'gym/base.html' %}
|
{% extends 'gym/base.html' %}
|
||||||
{% load bootstrap4 %}
|
{% load bootstrap4 %}
|
||||||
|
|
||||||
|
{% block title %}{{ title }} un réglage{% endblock %}
|
||||||
|
{% block h1 %}{{ title }} un réglage{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h1>{% block title %}{{ title }} un réglage{% endblock %}</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
{% if equipment %}
|
|
||||||
<a href="{% url 'equipment-detail' equipment.pk %}" class="btn btn-secondary">Retourner à la machine</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
|
|
|
@ -1,19 +1,10 @@
|
||||||
{% extends 'gym/base.html' %}
|
{% extends 'gym/base.html' %}
|
||||||
{% load bootstrap4 %}
|
{% load bootstrap4 %}
|
||||||
|
|
||||||
|
{% block title %}{{ title }} un max théorique{% endblock %}
|
||||||
|
{% block h1 %}{{ title }} un max théorique{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
<h1>{% block title %}{{ title }} un max théorique{% endblock %}</h1>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12">
|
|
||||||
{% if equipment %}
|
|
||||||
<a href="{% url 'equipment-detail' equipment.pk %}" class="btn btn-secondary">Retourner à la machine</a>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<form action="" method="post">
|
<form action="" method="post">
|
||||||
|
|
107
gym/views.py
107
gym/views.py
|
@ -5,7 +5,7 @@ from django.shortcuts import get_object_or_404
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.views import generic
|
from django.views import generic
|
||||||
|
|
||||||
from gym.mixins import SessionResetMixin
|
from gym.mixins import SessionResetMixin, QuickActionsMixin
|
||||||
from gym.models import Room, Equipment, Setting, Session, Round, TheoreticalMax
|
from gym.models import Room, Equipment, Setting, Session, Round, TheoreticalMax
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,11 +15,30 @@ class RoomListView(LoginRequiredMixin, SessionResetMixin, generic.ListView):
|
||||||
template_name = 'gym/rooms.html'
|
template_name = 'gym/rooms.html'
|
||||||
|
|
||||||
|
|
||||||
class RoomDetailView(LoginRequiredMixin, SessionResetMixin, generic.DetailView):
|
class RoomDetailView(LoginRequiredMixin, QuickActionsMixin, SessionResetMixin, generic.DetailView):
|
||||||
model = Room
|
model = Room
|
||||||
context_object_name = 'room'
|
context_object_name = 'room'
|
||||||
template_name = 'gym/room.html'
|
template_name = 'gym/room.html'
|
||||||
|
|
||||||
|
def get_quick_actions(self):
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'url': reverse('rooms-list'),
|
||||||
|
'category': 'secondary',
|
||||||
|
'display': 'Liste des salles'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url': "{}?room={}".format(reverse('equipment-create'), self.object.pk),
|
||||||
|
'category': 'success',
|
||||||
|
'display': 'Ajouter une machine'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url': "{}?room={}".format(reverse('session-start'), self.object.pk),
|
||||||
|
'category': 'primary',
|
||||||
|
'display': 'Commencer une séance'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['sessions'] = self.object.sessions.all().order_by('-start')
|
context['sessions'] = self.object.sessions.all().order_by('-start')
|
||||||
|
@ -46,12 +65,21 @@ class EquipmentDetailView(LoginRequiredMixin, generic.DetailView):
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
||||||
class EquipmentCreateView(LoginRequiredMixin, generic.CreateView):
|
class EquipmentCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||||
model = Equipment
|
model = Equipment
|
||||||
fields = ['room', 'name']
|
fields = ['room', 'name']
|
||||||
template_name = 'gym/equipment_edit.html'
|
template_name = 'gym/equipment_edit.html'
|
||||||
room = None
|
room = None
|
||||||
|
|
||||||
|
def get_quick_actions(self):
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'url': reverse('room-detail', args=(self.room.pk,)),
|
||||||
|
'category': 'secondary',
|
||||||
|
'display': 'Retourner à la salle'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['room'] = self.room
|
context['room'] = self.room
|
||||||
|
@ -74,12 +102,21 @@ class EquipmentCreateView(LoginRequiredMixin, generic.CreateView):
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
|
|
||||||
class SettingCreateView(LoginRequiredMixin, generic.CreateView):
|
class SettingCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||||
model = Setting
|
model = Setting
|
||||||
fields = ['equipment', 'name', 'value']
|
fields = ['equipment', 'name', 'value']
|
||||||
template_name = 'gym/setting_edit.html'
|
template_name = 'gym/setting_edit.html'
|
||||||
equipment = None
|
equipment = None
|
||||||
|
|
||||||
|
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):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['title'] = 'Ajouter'
|
context['title'] = 'Ajouter'
|
||||||
|
@ -103,11 +140,20 @@ class SettingCreateView(LoginRequiredMixin, generic.CreateView):
|
||||||
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
||||||
|
|
||||||
|
|
||||||
class SettingUpdateView(LoginRequiredMixin, generic.UpdateView):
|
class SettingUpdateView(LoginRequiredMixin, QuickActionsMixin, generic.UpdateView):
|
||||||
model = Setting
|
model = Setting
|
||||||
fields = ['equipment', 'name', 'value']
|
fields = ['equipment', 'name', 'value']
|
||||||
template_name = 'gym/setting_edit.html'
|
template_name = 'gym/setting_edit.html'
|
||||||
|
|
||||||
|
def get_quick_actions(self):
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'url': reverse('equipment-detail', args=(self.object.equipment.pk,)),
|
||||||
|
'category': 'secondary',
|
||||||
|
'display': 'Retourner à la machine'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['edit'] = True
|
context['edit'] = True
|
||||||
|
@ -128,12 +174,21 @@ class SettingDeleteView(LoginRequiredMixin, generic.DeleteView):
|
||||||
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
||||||
|
|
||||||
|
|
||||||
class TheoreticalMaxCreateView(LoginRequiredMixin, generic.CreateView):
|
class TheoreticalMaxCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||||
model = TheoreticalMax
|
model = TheoreticalMax
|
||||||
fields = ['equipment', 'date', 'value']
|
fields = ['equipment', 'date', 'value']
|
||||||
template_name = 'gym/theoretical_max_edit.html'
|
template_name = 'gym/theoretical_max_edit.html'
|
||||||
equipment = None
|
equipment = None
|
||||||
|
|
||||||
|
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):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['title'] = 'Ajouter'
|
context['title'] = 'Ajouter'
|
||||||
|
@ -158,12 +213,22 @@ class TheoreticalMaxCreateView(LoginRequiredMixin, generic.CreateView):
|
||||||
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
return reverse('equipment-detail', kwargs={'pk': self.object.equipment.pk})
|
||||||
|
|
||||||
|
|
||||||
class SessionCreateView(LoginRequiredMixin, generic.CreateView):
|
class SessionCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||||
model = Session
|
model = Session
|
||||||
fields = ['room', 'start']
|
fields = ['room', 'start']
|
||||||
template_name = 'gym/session_edit.html'
|
template_name = 'gym/session_edit.html'
|
||||||
room = None
|
room = None
|
||||||
|
|
||||||
|
def get_quick_actions(self):
|
||||||
|
room_pk = self.room.pk
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'url': reverse('room-detail', args=(room_pk,)),
|
||||||
|
'category': 'secondary',
|
||||||
|
'display': 'Retourner à la salle'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['title'] = 'Démarrer'
|
context['title'] = 'Démarrer'
|
||||||
|
@ -185,23 +250,47 @@ class SessionCreateView(LoginRequiredMixin, generic.CreateView):
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
|
|
||||||
class SessionDetailView(LoginRequiredMixin, generic.DetailView):
|
class SessionDetailView(LoginRequiredMixin, QuickActionsMixin, generic.DetailView):
|
||||||
model = Session
|
model = Session
|
||||||
context_object_name = 'session'
|
context_object_name = 'session'
|
||||||
template_name = 'gym/session_detail.html'
|
template_name = 'gym/session_detail.html'
|
||||||
|
|
||||||
|
def get_quick_actions(self):
|
||||||
|
room_pk = self.get_object().room.pk
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
'url': reverse('room-detail', args=(room_pk,)),
|
||||||
|
'category': 'secondary',
|
||||||
|
'display': 'Retourner à la salle'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url': "{}?room={}".format(reverse('equipment-create'), room_pk),
|
||||||
|
'category': 'success',
|
||||||
|
'display': 'Ajouter une machine'
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
request.session['session_pk'] = self.get_object().pk
|
request.session['session_pk'] = self.get_object().pk
|
||||||
return super().dispatch(request, *args, **kwargs)
|
return super().dispatch(request, *args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class RoundCreateView(LoginRequiredMixin, generic.CreateView):
|
class RoundCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView):
|
||||||
model = Round
|
model = Round
|
||||||
fields = ['equipment', 'session', 'theoretical_max_percentage', 'chosen_weight', 'repetition_number', 'notes']
|
fields = ['equipment', 'session', 'theoretical_max_percentage', 'chosen_weight', 'repetition_number', 'notes']
|
||||||
template_name = 'gym/round_edit.html'
|
template_name = 'gym/round_edit.html'
|
||||||
equipment = None
|
equipment = None
|
||||||
session_pk = None
|
session_pk = None
|
||||||
|
|
||||||
|
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):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['title'] = 'Commencer'
|
context['title'] = 'Commencer'
|
||||||
|
|
Loading…
Reference in a new issue