14 changed files with 112 additions and 3 deletions
			
			
		@ -0,0 +1,3 @@
					 | 
				
			||||
from django.contrib import admin | 
				
			||||
 | 
				
			||||
# Register your models here. | 
				
			||||
@ -0,0 +1,6 @@
					 | 
				
			||||
from django.apps import AppConfig | 
				
			||||
 | 
				
			||||
 | 
				
			||||
class CommentsConfig(AppConfig): | 
				
			||||
    default_auto_field = 'django.db.models.BigAutoField' | 
				
			||||
    name = 'comments' | 
				
			||||
									
										
											File diff suppressed because one or more lines are too long
										
									
								
							
						@ -0,0 +1,36 @@
					 | 
				
			||||
# Generated by Django 4.0.3 on 2022-04-09 12:38 | 
				
			||||
 | 
				
			||||
from django.db import migrations, models | 
				
			||||
import django.db.models.deletion | 
				
			||||
 | 
				
			||||
 | 
				
			||||
class Migration(migrations.Migration): | 
				
			||||
 | 
				
			||||
    initial = True | 
				
			||||
 | 
				
			||||
    dependencies = [ | 
				
			||||
        ('posts', '0003_alter_post_options'), | 
				
			||||
    ] | 
				
			||||
 | 
				
			||||
    operations = [ | 
				
			||||
        migrations.CreateModel( | 
				
			||||
            name='CommentAuthor', | 
				
			||||
            fields=[ | 
				
			||||
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | 
				
			||||
                ('author_name', models.CharField(max_length=60, verbose_name='Имя автора')), | 
				
			||||
                ('author_secret_hash', models.CharField(max_length=256, verbose_name='Хеш секрета')), | 
				
			||||
            ], | 
				
			||||
        ), | 
				
			||||
        migrations.CreateModel( | 
				
			||||
            name='Comment', | 
				
			||||
            fields=[ | 
				
			||||
                ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | 
				
			||||
                ('author_name', models.CharField(max_length=60, verbose_name='имя автора')), | 
				
			||||
                ('author_secret', models.CharField(blank=True, max_length=128, verbose_name='секретная строка')), | 
				
			||||
                ('reply', models.IntegerField(blank=True)), | 
				
			||||
                ('comment_text', models.TextField()), | 
				
			||||
                ('date', models.DateTimeField()), | 
				
			||||
                ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='posts.post')), | 
				
			||||
            ], | 
				
			||||
        ), | 
				
			||||
    ] | 
				
			||||
@ -0,0 +1,18 @@
					 | 
				
			||||
# Generated by Django 4.0.3 on 2022-04-09 13:01 | 
				
			||||
 | 
				
			||||
from django.db import migrations, models | 
				
			||||
 | 
				
			||||
 | 
				
			||||
class Migration(migrations.Migration): | 
				
			||||
 | 
				
			||||
    dependencies = [ | 
				
			||||
        ('comments', '0001_initial'), | 
				
			||||
    ] | 
				
			||||
 | 
				
			||||
    operations = [ | 
				
			||||
        migrations.AlterField( | 
				
			||||
            model_name='comment', | 
				
			||||
            name='reply', | 
				
			||||
            field=models.IntegerField(null=True), | 
				
			||||
        ), | 
				
			||||
    ] | 
				
			||||
@ -0,0 +1,26 @@
					 | 
				
			||||
from django.db import models | 
				
			||||
from posts.models import Post | 
				
			||||
 | 
				
			||||
 | 
				
			||||
class Comment(models.Model): | 
				
			||||
    """Класс для комента.""" | 
				
			||||
 | 
				
			||||
    post = models.ForeignKey(Post, on_delete=models.CASCADE) | 
				
			||||
    author_name = models.CharField("имя автора", max_length=60) | 
				
			||||
    author_secret = models.CharField("секретная строка", max_length=128, blank=True) | 
				
			||||
    reply = models.IntegerField(null=True) | 
				
			||||
    comment_text = models.TextField() | 
				
			||||
    date = models.DateTimeField() | 
				
			||||
 | 
				
			||||
 | 
				
			||||
class CommentAuthor(models.Model): | 
				
			||||
    """Валидация автора коммента. | 
				
			||||
 | 
				
			||||
    Если коментатор оставил секретную фразу, то от нее вычисляется | 
				
			||||
    хеш, который сравнивается с тем, который есть в базе для этого | 
				
			||||
    сочетания author_name:hash. | 
				
			||||
 | 
				
			||||
    """ | 
				
			||||
 | 
				
			||||
    author_name = models.CharField("Имя автора", max_length=60) | 
				
			||||
    author_secret_hash = models.CharField("Хеш секрета", max_length=256) | 
				
			||||
@ -0,0 +1,3 @@
					 | 
				
			||||
from django.test import TestCase | 
				
			||||
 | 
				
			||||
# Create your tests here. | 
				
			||||
@ -0,0 +1,3 @@
					 | 
				
			||||
from django.shortcuts import render | 
				
			||||
 | 
				
			||||
# Create your views here. | 
				
			||||
					Loading…
					
					
				
		Reference in new issue