diff --git a/PlanktonDetector/Community/migrations/0004_alter_post_content.py b/PlanktonDetector/Community/migrations/0004_alter_post_content.py new file mode 100644 index 0000000..0233ee2 --- /dev/null +++ b/PlanktonDetector/Community/migrations/0004_alter_post_content.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-01-06 23:25 + +import ckeditor.fields +from django.db import migrations + + +class Migration(migrations.Migration): + dependencies = [ + ("Community", "0003_comment_date_added"), + ] + + operations = [ + migrations.AlterField( + model_name="post", + name="content", + field=ckeditor.fields.RichTextField(blank=True, null=True), + ), + ] diff --git a/PlanktonDetector/Community/migrations/0005_alter_comment_date_added_alter_post_date_pub.py b/PlanktonDetector/Community/migrations/0005_alter_comment_date_added_alter_post_date_pub.py new file mode 100644 index 0000000..e7460ee --- /dev/null +++ b/PlanktonDetector/Community/migrations/0005_alter_comment_date_added_alter_post_date_pub.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.7 on 2024-01-07 00:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("Community", "0004_alter_post_content"), + ] + + operations = [ + migrations.AlterField( + model_name="comment", + name="date_added", + field=models.DateTimeField(auto_now_add=True), + ), + migrations.AlterField( + model_name="post", + name="date_pub", + field=models.DateTimeField(auto_now_add=True), + ), + ] diff --git a/PlanktonDetector/Community/models.py b/PlanktonDetector/Community/models.py index fa94610..8d8b78c 100644 --- a/PlanktonDetector/Community/models.py +++ b/PlanktonDetector/Community/models.py @@ -1,14 +1,15 @@ from django.db import models from django.contrib.auth.models import User +from ckeditor.fields import RichTextField # Create your models here. class Post(models.Model): title = models.CharField(max_length=500) - content = models.TextField() + content = RichTextField(null=True, blank=True) author = models.ForeignKey(User, on_delete=models.CASCADE, null=False) - date_pub = models.DateField(auto_now_add=True) + date_pub = models.DateTimeField(auto_now_add=True) @property def sorted_comments(self): @@ -19,4 +20,4 @@ class Comment(models.Model): author = models.ForeignKey(User, on_delete=models.CASCADE, null=False) content = models.TextField() post = models.ForeignKey(Post, on_delete=models.CASCADE) - date_added = models.DateField(auto_now_add=True) + date_added = models.DateTimeField(auto_now_add=True) diff --git a/PlanktonDetector/Community/views.py b/PlanktonDetector/Community/views.py index d3f1bf4..341c051 100644 --- a/PlanktonDetector/Community/views.py +++ b/PlanktonDetector/Community/views.py @@ -11,7 +11,7 @@ from .froms import PostForm, CommentForm class ListPosts(ListView): model = Post template_name = "list_posts.html" - paginate_by = 3 + paginate_by = 4 def get_queryset(self) -> QuerySet[Any]: queryset = Post.objects.all().order_by("-date_pub") diff --git a/PlanktonDetector/db.sqlite3 b/PlanktonDetector/db.sqlite3 index d4ec1d5..a7d5506 100644 Binary files a/PlanktonDetector/db.sqlite3 and b/PlanktonDetector/db.sqlite3 differ diff --git a/PlanktonDetector/static/Community/css/add_post.css b/PlanktonDetector/static/Community/css/add_post.css index ce7c4bb..99203e1 100644 --- a/PlanktonDetector/static/Community/css/add_post.css +++ b/PlanktonDetector/static/Community/css/add_post.css @@ -5,13 +5,15 @@ align-items: center; } -#add_post p{ - display: flex; - flex-direction: row; - justify-content: space-between; - align-items: center; +#add_post input{ + margin-bottom: 10px; } +#add_post label{ + margin-bottom: 10px; + font-size: 20px; + font-weight: bold; +} #submit{ background-color: chartreuse; @@ -22,4 +24,5 @@ color:black; font-family: Arial; text-align: center; + margin-top: 10px; } \ No newline at end of file diff --git a/PlanktonDetector/static/Community/css/list_posts.css b/PlanktonDetector/static/Community/css/list_posts.css index 2b5e61b..51e1018 100644 --- a/PlanktonDetector/static/Community/css/list_posts.css +++ b/PlanktonDetector/static/Community/css/list_posts.css @@ -47,4 +47,5 @@ ul{ box-shadow: 0 0 0 2px black; font-size: 20px; font-family: Arial; + margin-bottom:10px; } \ No newline at end of file diff --git a/PlanktonDetector/static/Community/css/post_details.css b/PlanktonDetector/static/Community/css/post_details.css index b0a8d19..a237703 100644 --- a/PlanktonDetector/static/Community/css/post_details.css +++ b/PlanktonDetector/static/Community/css/post_details.css @@ -12,7 +12,7 @@ margin-top:10px; flex-direction: column; justify-content:center; - align-items: flex-start; + align-items: stretch; border: 3px solid lightgray; width: 80%; padding: 15px; @@ -30,6 +30,7 @@ font-size: 40px; color: black; font-weight: bold; + align-self: flex-start; } #content{ diff --git a/PlanktonDetector/templates/add_post.html b/PlanktonDetector/templates/add_post.html index 7b8f77a..c341af1 100644 --- a/PlanktonDetector/templates/add_post.html +++ b/PlanktonDetector/templates/add_post.html @@ -6,7 +6,8 @@ {%block content%}
{% csrf_token %} - {{ form.as_p }} + {{form}} + {{form.media}}
{%endblock content%} \ No newline at end of file diff --git a/PlanktonDetector/templates/history.html b/PlanktonDetector/templates/history.html index 5f610ae..9263579 100644 --- a/PlanktonDetector/templates/history.html +++ b/PlanktonDetector/templates/history.html @@ -12,7 +12,7 @@
upload_image
-

{{detection.date_predicted.date}}

+

{{detection.date_predicted}}

{{detection.owner}}

Images uploaded: {{detection.images.all.count}}

diff --git a/PlanktonDetector/templates/post_details.html b/PlanktonDetector/templates/post_details.html index b085729..a505834 100644 --- a/PlanktonDetector/templates/post_details.html +++ b/PlanktonDetector/templates/post_details.html @@ -8,20 +8,22 @@

{{object.title}}

-

{{object.content}}

+

{{object.content|safe}}

{{object.author}}

Comments:

-
+ {%if user.is_authenticated%} +
{%csrf_token%} {{form}}
+ {%endif%}
{%for comment in object.sorted_comments%}