Skip to content
Extraits de code Groupes Projets
Valider 9f3756f1 rédigé par Charles Anteunis's avatar Charles Anteunis
Parcourir les fichiers

questionnaire quotidien, menus et modification de compte

parent 3f5e9989
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de avec 245 ajouts et 14 suppressions
from django.contrib import admin
from .models import Menu, QuestionQuotid
# Register your models here.
admin.site.register(Menu)
admin.site.register(QuestionQuotid)
\ No newline at end of file
......@@ -5,6 +5,8 @@ from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.core.exceptions import ValidationError
import os
from .models import QuestionQuotid
class UserForm(UserCreationForm):
class Meta:
......@@ -17,4 +19,18 @@ class questionnaireForm(forms.Form):
type_sport = forms.CharField(max_length=50)
eau = forms.IntegerField()
maladie = forms.CharField(max_length=50)
poisd = forms.IntegerField()
\ No newline at end of file
poisd = forms.IntegerField()
class UserModifForm(forms.ModelForm):
class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email')
class QuestionQuotidForm(forms.ModelForm):
nbh_activite = forms.IntegerField(min_value=0, label="nombre d'heures d'activité")
volume_eau = forms.IntegerField(min_value=0, label="volume d'eau bu ce jour")
class Meta:
model = QuestionQuotid
fields = '__all__'
\ No newline at end of file
# Generated by Django 2.2.6 on 2019-10-16 17:07
# Generated by Django 2.2.6 on 2019-11-06 23:42
from django.db import migrations, models
......@@ -15,8 +15,30 @@ class Migration(migrations.Migration):
name='Menu',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('nb_plat', models.IntegerField()),
('entree', models.CharField(max_length=150)),
('type_menu', models.CharField(choices=[('sante', 'santé'), ('perte', 'perte de poids'), ('prise', 'prise de masse'), ('cheat', 'cheat day')], max_length=5)),
('nb_cal', models.PositiveIntegerField()),
('entree', models.CharField(choices=[('SAL', 'salade'), ('SOP', 'soupe')], max_length=3)),
('plat', models.CharField(choices=[('PV', 'pâtes viande'), ('LP', 'légumes pommes de terre')], max_length=3)),
('dessert', models.CharField(choices=[('GAT', 'gâteau'), ('YAO', 'yaourt')], default='GAT', max_length=3)),
],
),
migrations.CreateModel(
name='QuestionQuotid',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('typeRepas', models.CharField(max_length=3)),
('nbh_activite', models.PositiveIntegerField()),
('volume_eau', models.PositiveIntegerField()),
('maladies', models.CharField(max_length=3)),
],
),
migrations.CreateModel(
name='Sport',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('type_sport', models.CharField(max_length=150)),
('nb_seances', models.IntegerField()),
('intensite', models.IntegerField()),
],
),
]
# Generated by Django 2.2.6 on 2019-11-07 00:40
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('nutriform', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='questionquotid',
name='poids',
field=models.PositiveIntegerField(null=True),
),
migrations.AlterField(
model_name='questionquotid',
name='maladies',
field=models.CharField(choices=[('RH', 'Rhume'), ('GR', 'Grippe'), ('AN', 'Angine')], max_length=3),
),
migrations.AlterField(
model_name='questionquotid',
name='typeRepas',
field=models.CharField(choices=[('sante', 'santé'), ('perte', 'perte de poids'), ('prise', 'prise de masse'), ('cheat', 'cheat day')], max_length=5),
),
]
......@@ -4,11 +4,52 @@ from django.contrib.auth.models import User
# Create your models here.
User._meta.get_field('email')._unique = True
TYPEMENU_CHOICES = [
('sante','santé'),
('perte','perte de poids'),
('prise','prise de masse'),
('cheat','cheat day')
]
ENTREE_CHOICES = [
('SAL','salade'),
('SOP','soupe')
]
PLAT_CHOICES = [
('PV','pâtes viande'),
('LP','légumes pommes de terre')
]
DESSERT_CHOICES =[
('GAT','gâteau'),
('YAO','yaourt')
]
class Menu(models.Model):
type_plat = models.CharField(max_length=150)
nb_plat = models.IntegerField()
type_menu = models.CharField(max_length=5, choices=TYPEMENU_CHOICES)
nb_cal = models.PositiveIntegerField()
entree = models.CharField(max_length=3, choices=ENTREE_CHOICES)
plat = models.CharField(max_length=3, choices=PLAT_CHOICES)
dessert = models.CharField(max_length=3, choices=DESSERT_CHOICES, default='GAT')
def __str__(self):
return self.type_menu
class Sport(models.Model):
type_sport = models.CharField(max_length=150)
nb_seances = models.IntegerField()
intensite = models.IntegerField()
\ No newline at end of file
intensite = models.IntegerField()
MALADIES_CHOICES = [
('RH', 'Rhume'),
('GR', 'Grippe'),
('AN', 'Angine')
]
class QuestionQuotid(models.Model):
typeRepas = models.CharField(max_length=5, choices=TYPEMENU_CHOICES)
nbh_activite = models.PositiveIntegerField()
volume_eau = models.PositiveIntegerField()
maladies = models.CharField(max_length=3, choices=MALADIES_CHOICES)
poids = models.PositiveIntegerField(null=True)
\ No newline at end of file
......@@ -8,7 +8,11 @@
<h3>Mes informations diverses</h3>
<p>Informations blabla</p>
<a href="{%url 'password_change'%}" class="button">Modifier mon mot de passe</a>
<a href="{% url 'password_change' %}" class="button">Modifier mon mot de passe</a>
<a href="{% url 'modif_compte' %}" class="button">Modifier mon compte</a>
<a href="{% url 'questionnaire' %}" class="button">Questionnaire quotidien</a>
</div class="container">
{% endblock %}
\ No newline at end of file
......@@ -92,8 +92,7 @@
</div>
</div>
<ul class="actions">
<li><a href="#" class="button special big">Perte de poids</a></li>
<li><a href="#" class="button big">Entretien</a></li>
<li><a href="{% url 'menus' %}" class="button special big">Découvrez nos menus</a></li>
</ul>
</div>
</section>
......
{% extends "../nutriform/base.html" %}
{% block content %}
<div class="container">
<header class="major">
<h2>Liste des menus disponibles</h2>
<p>Cete liste est vouée à évoluer perpétuellement</p>
</header>
<div class="table-wrapper">
<table class="alt">
<thead>
<tr>
<th>Type de menu</th>
<th>Nombre de caolories</th>
<th>Entrée</th>
<th>Plat</th>
<th>Dessert</th>
</tr>
</thead>
<tbody>
{% for menu in listmenus %}
<tr>
<td>{{ menu.get_type_menu_display}}</td>
<td>{{ menu.nb_cal }}</td>
<td>{{ menu.get_entree_display }}</td>
<td>{{ menu.get_plat_display }}</td>
<td>{{ menu.get_dessert_display }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div class="container">
{% endblock %}
\ No newline at end of file
{% extends "../nutriform/base.html" %}
{% block content %}
<div class="container">
<h3>Modification du compte {{ user.username }}</h3>
<form action="" method="POST">
{% csrf_token %}
{{form}}
<input type="submit" value="Modifier">
</form>
</div class="container">
{% endblock %}
\ No newline at end of file
{% extends "../nutriform/base.html" %}
{% block content %}
<div class="container">
<h3>Questionnaire quotidien</h3>
<p>Ce questinonaire permet de vous proposer des services plus personnalisés et adaptés à vos besoins</p>
<form action="" method="POST">
{% csrf_token %}
{{ form }}
<input type="submit" value="Enregistrer">
</form>
</div class="container">
{% endblock %}
\ No newline at end of file
......@@ -8,5 +8,8 @@ urlpatterns = [
path('register/', views.register, name='register'),
path('accounts/profile/', views.compte, name='compte'),
path('aboutus', views.aboutus, name="aboutus"),
path('accounts/', include('django.contrib.auth.urls'))
path('accounts/', include('django.contrib.auth.urls')),
path('menus/', views.menus, name='menus'),
path('accounts/profile/modification/', views.modif_compte, name='modif_compte'),
path('accounts/questionnaire/', views.question_quotid, name='questionnaire')
]
......@@ -2,8 +2,10 @@ from django.shortcuts import render, get_object_or_404, redirect
from django.http import HttpResponse
from django.core.mail import send_mail
from django.contrib.auth.decorators import login_required
from django.contrib.auth.forms import UserChangeForm
from .forms import UserForm
from .forms import UserForm, UserModifForm, QuestionQuotidForm
from .models import Menu, QuestionQuotid
def index(request):
if request.method == 'POST' :
......@@ -38,4 +40,46 @@ def compte(request):
return render(request, 'nutriform/compte.html')
def aboutus(request):
return render(request, 'nutriform/aboutus.html')
\ No newline at end of file
return render(request, 'nutriform/aboutus.html')
def menus(request):
listmenus = list(Menu.objects.all())
context = {
'listmenus':listmenus
}
return render(request, 'nutriform/menus.html', context)
@login_required
def modif_compte(request):
user = request.user
if request.method == 'POST':
form = UserModifForm(request.POST, instance=user)
if form.is_valid():
user = form.save()
return redirect('compte')
else :
form = UserModifForm(instance=user)
context = {
'form': form,
}
return render(request, 'nutriform/modif_compte.html', context)
@login_required
def question_quotid(request):
if request.method == 'POST':
form = QuestionQuotidForm(request.POST)
if form.is_valid():
form.save()
return redirect('compte')
else :
form = QuestionQuotidForm()
context = {
'form':form,
}
return render(request, 'nutriform/questionnaire.html', context)
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter