Skip to content

Commit 35b965e

Browse files
committed
changed model to one value field
1 parent 02ee8f1 commit 35b965e

4 files changed

Lines changed: 15 additions & 81 deletions

File tree

rate_projects/constants.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
VERBOSE_TYPES = (
1+
VERBOSE_NAME_TYPES = (
22
("str", "Текст"),
33
("int", "Целочисленное число"),
44
("float", "Число с плавающей точкой"),
55
("bool", "Да или нет"),
66
)
7-
8-
GET_TYPE_FROM_STRING = {"str": str, "int": int, "float": float, "bool": bool}

rate_projects/migrations/0001_initial.py

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 4.2.3 on 2024-02-07 11:02
1+
# Generated by Django 4.2.3 on 2024-02-10 10:49
22

33
from django.conf import settings
44
from django.db import migrations, models
@@ -10,9 +10,9 @@ class Migration(migrations.Migration):
1010
initial = True
1111

1212
dependencies = [
13-
("projects", "0021_project_subscribers"),
14-
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
1513
("partner_programs", "0004_auto_20231230_0002"),
14+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
15+
("projects", "0021_project_subscribers"),
1616
]
1717

1818
operations = [
@@ -91,33 +91,15 @@ class Migration(migrations.Migration):
9191
),
9292
),
9393
(
94-
"value_int",
95-
models.IntegerField(
96-
blank=True, null=True, verbose_name="Целочисленное значение"
97-
),
98-
),
99-
(
100-
"value_float",
101-
models.FloatField(
102-
blank=True,
103-
max_length=50,
104-
null=True,
105-
verbose_name="Значение с плавающей запятой",
106-
),
107-
),
108-
(
109-
"value_bool",
110-
models.BooleanField(
111-
blank=True, null=True, verbose_name="'Да или нет' значение"
94+
"value",
95+
models.CharField(
96+
blank=True, max_length=50, null=True, verbose_name="Значение"
11297
),
11398
),
11499
(
115-
"value_str",
116-
models.FloatField(
117-
blank=True,
118-
max_length=50,
119-
null=True,
120-
verbose_name="Текстовое значение",
100+
"comment",
101+
models.CharField(
102+
blank=True, max_length=100, null=True, verbose_name="Комментарий"
121103
),
122104
),
123105
(

rate_projects/migrations/0002_projectscore_comment_alter_projectscore_value_float_and_more.py

Lines changed: 0 additions & 34 deletions
This file was deleted.

rate_projects/models.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from partner_programs.models import PartnerProgram
55
from projects.models import Project
6-
from .constants import VERBOSE_TYPES
6+
from rate_projects.constants import VERBOSE_NAME_TYPES
77

88
User = get_user_model()
99

@@ -24,7 +24,7 @@ class Criteria(models.Model):
2424

2525
name = models.CharField(verbose_name="Название", max_length=50)
2626
description = models.TextField(verbose_name="Описание", null=True, blank=True)
27-
type = models.CharField(verbose_name="Тип", max_length=8, choices=VERBOSE_TYPES)
27+
type = models.CharField(verbose_name="Тип", max_length=8, choices=VERBOSE_NAME_TYPES)
2828

2929
min_value = models.FloatField(
3030
verbose_name="Минимально допустимое числовое значение",
@@ -60,10 +60,7 @@ class ProjectScore(models.Model):
6060
criteria: A ForeignKey connection to Criteria model
6161
user: A ForeignKey connection to User model
6262
63-
value_int: IntegerField for value
64-
value_float: FloatField for value
65-
value_bool: BooleanField for value
66-
value_str: CharField for value
63+
value: CharField for value
6764
6865
commentary: CharField for optional commentary
6966
@@ -75,17 +72,8 @@ class ProjectScore(models.Model):
7572
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name="scores")
7673
project = models.ForeignKey(Project, on_delete=models.CASCADE, related_name="scores")
7774

78-
value_int = models.IntegerField(
79-
verbose_name="Целочисленное значение", null=True, blank=True
80-
)
81-
value_float = models.FloatField(
82-
verbose_name="Значение с плавающей запятой", null=True, blank=True
83-
)
84-
value_bool = models.BooleanField(
85-
verbose_name="'Да или нет' значение", null=True, blank=True
86-
)
87-
value_str = models.CharField(
88-
verbose_name="Текстовое значение", max_length=50, null=True, blank=True
75+
value = models.CharField(
76+
verbose_name="Значение", max_length=50, null=True, blank=True
8977
)
9078

9179
comment = models.CharField(

0 commit comments

Comments
 (0)