Skip to content

Commit 803306d

Browse files
author
Арсентьев Антон
committed
commit
0 parents  commit 803306d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+17897
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*/__pycache__/*
2+
*pyc
3+
helpy.txt

Dockerfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
FROM python:3.8-buster
2+
3+
WORKDIR /usr/src/mytruegym
4+
5+
ENV PYTHONDONTWRITEBYTECODE 1
6+
ENV PYTHONUNBUFFERED 1
7+
8+
RUN pip install --upgrade pip
9+
COPY requirements.txt .
10+
RUN pip install -r requirements.txt
11+
12+
COPY . .

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 AntonArsentiev
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# MyTrueGym

calories/__init__.py

Whitespace-only changes.

calories/admin.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from .models import Calorie
2+
from django.contrib import admin
3+
4+
5+
admin.site.register(Calorie)

calories/apps.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from django.apps import AppConfig
2+
3+
4+
class CaloriesConfig(AppConfig):
5+
name = "calories"

calories/forms.py

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
from django import forms
2+
from django.utils.translation import ugettext_lazy
3+
from django.core.validators import MinValueValidator
4+
5+
6+
class CalorieForm(forms.Form):
7+
title = forms.CharField(
8+
label=ugettext_lazy("Название"),
9+
widget=forms.TextInput(
10+
attrs={
11+
"placeholder": ugettext_lazy("Название")
12+
}
13+
),
14+
required=False
15+
)
16+
kcal_from = forms.DecimalField(
17+
label=ugettext_lazy("Ккал от"),
18+
widget=forms.TextInput(
19+
attrs={
20+
"placeholder": ugettext_lazy("Ккал от"),
21+
"type": "number",
22+
"style": "width: 90px;"
23+
}
24+
),
25+
required=False,
26+
validators=[
27+
MinValueValidator(0.0)
28+
]
29+
)
30+
kcal_to = forms.DecimalField(
31+
label=ugettext_lazy("Ккал до"),
32+
widget=forms.TextInput(
33+
attrs={
34+
"placeholder": ugettext_lazy("Ккал до"),
35+
"type": "number",
36+
"style": "width: 90px;"
37+
}
38+
),
39+
required=False,
40+
validators=[
41+
MinValueValidator(0.0)
42+
]
43+
)
44+
protein_from = forms.DecimalField(
45+
label=ugettext_lazy("Белки от"),
46+
widget=forms.TextInput(
47+
attrs={
48+
"placeholder": ugettext_lazy("Белки от"),
49+
"type": "number",
50+
"style": "width: 110px;"
51+
}
52+
),
53+
required=False,
54+
validators=[
55+
MinValueValidator(0.0)
56+
]
57+
)
58+
protein_to = forms.DecimalField(
59+
label=ugettext_lazy("Белки до"),
60+
widget=forms.TextInput(
61+
attrs={
62+
"placeholder": ugettext_lazy("Белки до"),
63+
"type": "number",
64+
"style": "width: 110px;"
65+
}
66+
),
67+
required=False,
68+
validators=[
69+
MinValueValidator(0.0)
70+
]
71+
)
72+
oil_from = forms.DecimalField(
73+
label=ugettext_lazy("Жиры от"),
74+
widget=forms.TextInput(
75+
attrs={
76+
"placeholder": ugettext_lazy("Жиры от"),
77+
"type": "number",
78+
"style": "width: 90px;"
79+
}
80+
),
81+
required=False,
82+
validators=[
83+
MinValueValidator(0.0)
84+
]
85+
)
86+
oil_to = forms.DecimalField(
87+
label=ugettext_lazy("Жиры до"),
88+
widget=forms.TextInput(
89+
attrs={
90+
"placeholder": ugettext_lazy("Жиры до"),
91+
"type": "number",
92+
"style": "width: 90px;"
93+
}
94+
),
95+
required=False,
96+
validators=[
97+
MinValueValidator(0.0)
98+
]
99+
)
100+
carb_from = forms.DecimalField(
101+
label=ugettext_lazy("Углеводы от"),
102+
widget=forms.TextInput(
103+
attrs={
104+
"placeholder": ugettext_lazy("Углеводы от"),
105+
"type": "number",
106+
"style": "width: 120px;"
107+
}
108+
),
109+
required=False,
110+
validators=[
111+
MinValueValidator(0.0)
112+
]
113+
)
114+
carb_to = forms.DecimalField(
115+
label=ugettext_lazy("Углеводы до"),
116+
widget=forms.TextInput(
117+
attrs={
118+
"placeholder": ugettext_lazy("Углеводы до"),
119+
"type": "number",
120+
"style": "width: 120px;"
121+
}
122+
),
123+
required=False,
124+
validators=[
125+
MinValueValidator(0.0)
126+
]
127+
)

calories/migrations/0001_initial.py

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Generated by Django 3.1.1 on 2020-09-21 19:06
2+
3+
import django.core.validators
4+
from django.db import migrations, models
5+
import django.db.models.manager
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
initial = True
11+
12+
dependencies = [
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='Calorie',
18+
fields=[
19+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20+
('title', models.CharField(default='', max_length=20, verbose_name='Название')),
21+
('title_en', models.CharField(default='', max_length=20, verbose_name='Title')),
22+
('avatar', models.ImageField(upload_to='', verbose_name='Фотография')),
23+
('kcal', models.PositiveIntegerField(default=0, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(1000000)], verbose_name='Ккал')),
24+
('protein', models.DecimalField(decimal_places=2, default=0.0, max_digits=5, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(1000000)], verbose_name='Белки')),
25+
('oil', models.DecimalField(decimal_places=2, default=0.0, max_digits=5, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(1000000)], verbose_name='Жиры')),
26+
('carb', models.DecimalField(decimal_places=2, default=0.0, max_digits=5, validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(1000000)], verbose_name='Углеводы')),
27+
],
28+
options={
29+
'verbose_name': 'Калория',
30+
'verbose_name_plural': 'Калории',
31+
'ordering': ['kcal'],
32+
},
33+
managers=[
34+
('manager', django.db.models.manager.Manager()),
35+
],
36+
),
37+
migrations.AddIndex(
38+
model_name='calorie',
39+
index=models.Index(fields=['title_en', 'kcal', 'protein', 'oil', 'carb'], name='calories_ca_title_e_42012e_idx'),
40+
),
41+
migrations.AddIndex(
42+
model_name='calorie',
43+
index=models.Index(fields=['title', 'kcal', 'protein', 'oil', 'carb'], name='calories_ca_title_2bda5f_idx'),
44+
),
45+
]

calories/migrations/__init__.py

Whitespace-only changes.

calories/models.py

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
from constants import *
2+
from django.db import models
3+
from django.core.validators import MinValueValidator, MaxValueValidator
4+
5+
6+
class Calorie(models.Model):
7+
title = models.CharField(
8+
default="",
9+
max_length=20,
10+
verbose_name="Название",
11+
db_index=False
12+
)
13+
title_en = models.CharField(
14+
default="",
15+
max_length=20,
16+
verbose_name="Title",
17+
db_index=False
18+
)
19+
avatar = models.ImageField(
20+
verbose_name="Фотография"
21+
)
22+
kcal = models.PositiveIntegerField(
23+
default=0,
24+
verbose_name="Ккал",
25+
db_index=False,
26+
validators=[
27+
MinValueValidator(MIN_CALORIES_VALUE),
28+
MaxValueValidator(MAX_CALORIES_VALUE)
29+
]
30+
)
31+
protein = models.DecimalField(
32+
default=0.0,
33+
max_digits=5,
34+
decimal_places=2,
35+
verbose_name="Белки",
36+
db_index=False,
37+
validators=[
38+
MinValueValidator(MIN_CALORIES_VALUE),
39+
MaxValueValidator(MAX_CALORIES_VALUE)
40+
]
41+
)
42+
oil = models.DecimalField(
43+
default=0.0,
44+
max_digits=5,
45+
decimal_places=2,
46+
verbose_name="Жиры",
47+
db_index=False,
48+
validators=[
49+
MinValueValidator(MIN_CALORIES_VALUE),
50+
MaxValueValidator(MAX_CALORIES_VALUE)
51+
]
52+
)
53+
carb = models.DecimalField(
54+
default=0.0,
55+
max_digits=5,
56+
decimal_places=2,
57+
verbose_name="Углеводы",
58+
db_index=False,
59+
validators=[
60+
MinValueValidator(MIN_CALORIES_VALUE),
61+
MaxValueValidator(MAX_CALORIES_VALUE)
62+
]
63+
)
64+
65+
manager = models.Manager()
66+
67+
def __str__(self):
68+
return self.title
69+
70+
class Meta:
71+
verbose_name = "Калория"
72+
verbose_name_plural = "Калории"
73+
ordering = [KCAL]
74+
indexes = [
75+
models.Index(fields=[TITLE_EN, KCAL, PROTEIN, OIL, CARB]),
76+
models.Index(fields=[TITLE, KCAL, PROTEIN, OIL, CARB]),
77+
]

calories/static/css/calories.css

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
.calories_notice_p {
2+
text-align: center;
3+
font-size: 2rem;
4+
}
5+
6+
.calories_error_p {
7+
color: red;
8+
text-align: center;
9+
}
10+
11+
.form_calories_find {
12+
display:inline-block;
13+
}
14+
15+
.calories_find_form_input {
16+
display: inline-block;
17+
float: right;
18+
}
19+
20+
.find_submit {
21+
width: 60px;
22+
}
23+
24+
.clear_submit {
25+
width: 85px;
26+
}
27+
28+
.media {
29+
margin-bottom: 50px;
30+
}
31+
32+
.media-body {
33+
margin-top: 30px;
34+
}
35+
36+
.calories_find_empty_result_p {
37+
color: red;
38+
text-align: center;
39+
margin: 160px auto;
40+
font-size: 2.5rem;
41+
}
42+
43+
#id_title {
44+
width: 100px;
45+
}
46+
47+
#id_kcal_from {
48+
width: 100px;
49+
}
50+
51+
#id_kcal_to {
52+
width: 100px;
53+
}
54+
55+
#id_protein_from {
56+
width: 100px;
57+
}
58+
59+
#id_protein_to {
60+
width: 100px;
61+
}
62+
63+
#id_oil_from {
64+
width: 100px;
65+
}
66+
67+
#id_oil_to {
68+
width: 100px;
69+
}
70+
71+
#id_carb_from {
72+
width: 100px;
73+
}
74+
75+
#id_carb_to {
76+
width: 100px;
77+
}

0 commit comments

Comments
 (0)