Coverage report: + 46% +
+ + ++ coverage.py v7.2.7, + created at 2023-08-14 15:32 +0300 +
+diff --git a/Practice/Stupina/coolapp/admin.py b/Practice/Stupina/coolapp/admin.py new file mode 100644 index 0000000..4c434ef --- /dev/null +++ b/Practice/Stupina/coolapp/admin.py @@ -0,0 +1,9 @@ +from django.contrib import admin + +# Register your models here. + +from django.contrib import admin +from .models import Film, Comments + +admin.site.register(Film) +admin.site.register(Comments) diff --git a/Practice/Stupina/coolapp/forms.py b/Practice/Stupina/coolapp/forms.py new file mode 100644 index 0000000..04b093c --- /dev/null +++ b/Practice/Stupina/coolapp/forms.py @@ -0,0 +1,15 @@ +from django import forms +from .models import Film, Comments + + +class FilmForm(forms.ModelForm): + class Meta: + model = Film + fields = ('name', 'state', 'date_exist', 'desc', 'rate') +# поля pub_date и id заполняются сами + + +class CommentsForm(forms.ModelForm): + class Meta: + model = Comments + fields = ('comment',) diff --git a/Practice/Stupina/coolapp/models.py b/Practice/Stupina/coolapp/models.py new file mode 100644 index 0000000..800cf9b --- /dev/null +++ b/Practice/Stupina/coolapp/models.py @@ -0,0 +1,24 @@ +from django.db import models +from django.core.validators import MaxValueValidator, MinValueValidator + +# Create your models here. +class Film(models.Model): + #атрибуты name, desc, pub_date, rate - столбцы + name = models.CharField(max_length=200) + # TextField() - тип поля + state = models.TextField(null=True) + date_exist = models.DateField(default='0') + desc = models.TextField() + # 'date published' - как поле будет выглядеть при выводе на экран в терминале + # auto_now_add=True - когда будет добавляться новая запись, + # это поле будет автоматически проставляться, исходя из текущего времени + pub_date = models.DateTimeField('date published', auto_now_add=True) + rate = models.IntegerField(validators=[MinValueValidator(1), MaxValueValidator(10)], default=1) + + +class Comments(models.Model): + films_id = models.ForeignKey(Film, on_delete=models.CASCADE, null=True) + comment = models.TextField() + + + diff --git a/Practice/Stupina/coolapp/static/favicon.png b/Practice/Stupina/coolapp/static/favicon.png new file mode 100644 index 0000000..a167f51 Binary files /dev/null and b/Practice/Stupina/coolapp/static/favicon.png differ diff --git a/Practice/Stupina/coolapp/templates/coolapp/base.html b/Practice/Stupina/coolapp/templates/coolapp/base.html new file mode 100644 index 0000000..13d5d8b --- /dev/null +++ b/Practice/Stupina/coolapp/templates/coolapp/base.html @@ -0,0 +1,22 @@ + +{% load static %} + + +
+ + + + + +Страна : - {{ film.state }}
+Описание: {{ film.desc }}
+Дата создания: {{ film.date_exist }}
+{% if film.pub_date %} +Дата публикации отзыва: - {{ film.pub_date }}
+{% else %} +Дата публикации отзыва: - Unknown
+{% endif %} +Оценка: {{ film.rate }}
+{% for com in comm %} +Комментарии: {{com.comment }}
+{% endfor %} + +Оставить комментарий:
+ +{% endblock content %} diff --git a/Practice/Stupina/coolapp/templates/coolapp/films.html b/Practice/Stupina/coolapp/templates/coolapp/films.html new file mode 100644 index 0000000..b7a9bd1 --- /dev/null +++ b/Practice/Stupina/coolapp/templates/coolapp/films.html @@ -0,0 +1,18 @@ +{% extends 'coolapp/base.html' %} +{% block content %} + + +{% for film in films %} + +Описание: {{ film.desc }}
+{% if film.pub_date %} +Дата публикации : - {{ film.pub_date }}
+{% else %} +Дата публикации: - Unknown
+{% endif %} +Оценка : {{ film.rate }}
+{% endfor %} + + +{% endblock content %} diff --git a/Practice/Stupina/coolapp/templates/coolapp/index.html b/Practice/Stupina/coolapp/templates/coolapp/index.html new file mode 100644 index 0000000..07bb8a8 --- /dev/null +++ b/Practice/Stupina/coolapp/templates/coolapp/index.html @@ -0,0 +1,12 @@ + + +{% extends 'coolapp/base.html' %} +{% block content %} +Здесь Вы можете найти информацию о фильмах, их краткое описание и рейтинг
+Ошибка: У Вас нет прав для данной операции!
+{% endif %} + +{% endblock content %} \ No newline at end of file diff --git a/Practice/Stupina/coolapp/templates/coolapp/no_exit.html b/Practice/Stupina/coolapp/templates/coolapp/no_exit.html new file mode 100644 index 0000000..0008d3b --- /dev/null +++ b/Practice/Stupina/coolapp/templates/coolapp/no_exit.html @@ -0,0 +1,7 @@ + +{% extends 'coolapp/base.html' %} +{% block content %} + ++ coverage.py v7.2.7, + created at 2023-08-14 15:32 +0300 +
+| Module | +statements | +missing | +excluded | +coverage | +
|---|---|---|---|---|
| task_2.py | +39 | +21 | +0 | +46% | +
| Total | +39 | +21 | +0 | +46% | +
+ No items found using the specified filter. +
++ « prev + ^ index + » next + + coverage.py v7.2.7, + created at 2023-08-14 15:26 +0300 +
+ +1class IncorrectDataInput(Exception):
+2 pass
+ + +5class Money:
+6 def __init__(self, x, y):
+7 if isinstance(x, int) and isinstance(y, int):
+8 if x >= 0 and 0 <= y < 100:
+9 self.__x = x
+10 self.__y = y
+11 self._money = float(f'{self.__x}.{self.__y}')
+12 else:
+13 raise IncorrectDataInput
+14 else:
+15 print('Некорректный тип атрибутов')
+16 @property
+17 def money(self):
+18 return self._money
+ +20 def __str__(self):
+21 return f'{self.__x},{self.__y}'
+ +23 def __add__(self, other):
+24 res = round(self._money + other._money, 2)
+25 res = str(res).split('.')
+26 return Money(int(res[0]), int(res[1]))
+ +28 def __sub__(self, other):
+ +30 res = round(self._money - other._money, 2)
+31 if res < 0:
+32 print('Денежная сумма не может быть отрицательной')
+33 return None
+34 else:
+35 res = str(res).split('.')
+36 return Money(int(res[0]), int(res[1]))
+ +38 def __lt__(self, other):
+39 return self._money < other._money
+ +41 def __eq__(self, other):
+42 return self._money == other._money
+ +44 def __le__(self, other):
+45 return self._money <= other._money
+ + +48if __name__ == '__main__':
+49 ob1 = Money(10, 20)
+50 ob2 = Money(10, 4)
+ +52 print(ob1, ob2)
+53 print(ob1 - ob2)
+54 print(ob1 >= ob2)
+