diff --git a/bloggy/forms/edit_profile_form.py b/bloggy/forms/edit_profile_form.py index 045a199..0ab1c8b 100644 --- a/bloggy/forms/edit_profile_form.py +++ b/bloggy/forms/edit_profile_form.py @@ -1,6 +1,5 @@ from django import forms -from django.forms import ClearableFileInput - +from django.forms import ClearableFileInput, ModelForm, inlineformset_factory from bloggy.models import User @@ -11,18 +10,20 @@ class NonClearableFileInput(ClearableFileInput): class EditProfileForm(forms.ModelForm): class Meta: model = User - help_texts={ - "bio": "This will be displayed publicly on your profile. Keep it short and crisp." + help_texts = { + "bio": "This will be displayed publicly on your profile. Keep it short and crisp.", + 'receive_news_updates': "News about product and feature updates", + 'receive_new_content': "Get notified when new content is added" + } + + labels = { + 'receive_news_updates': "News and updates", + 'receive_new_content': "New tutorials & courses" } + fields = [ - 'profile_photo', - 'name', - 'website', - 'twitter', - 'linkedin', - 'youtube', - 'github', - 'bio' + 'profile_photo', 'name', 'website', 'twitter', 'linkedin', 'youtube', 'github', 'bio', + 'receive_news_updates', 'receive_new_content' ] widgets = { @@ -64,4 +65,13 @@ class Meta: 'rows': 5, 'placeholder': 'Your github' }), + + 'receive_news_updates': forms.CheckboxInput(attrs={ + 'class': 'form-check-input', + }), + + 'receive_new_content': forms.CheckboxInput(attrs={ + 'class': 'form-check-input', + }), + } diff --git a/bloggy/migrations/0008_user_receive_new_content_user_receive_news_updates.py b/bloggy/migrations/0008_user_receive_new_content_user_receive_news_updates.py new file mode 100644 index 0000000..60ce011 --- /dev/null +++ b/bloggy/migrations/0008_user_receive_new_content_user_receive_news_updates.py @@ -0,0 +1,23 @@ +# Generated by Django 4.2.7 on 2024-01-10 14:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bloggy', '0007_alter_post_difficulty_alter_post_post_type_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='receive_new_content', + field=models.BooleanField(default=True), + ), + migrations.AddField( + model_name='user', + name='receive_news_updates', + field=models.BooleanField(default=True), + ), + ] diff --git a/bloggy/models/user.py b/bloggy/models/user.py index c225e1e..2d3357d 100644 --- a/bloggy/models/user.py +++ b/bloggy/models/user.py @@ -66,6 +66,8 @@ class User(AbstractBaseUser, ResizeImageMixin, PermissionsMixin): youtube = models.CharField(max_length=100, null=True, blank=True) github = models.CharField(max_length=100, null=True, blank=True) bio = models.TextField(max_length=250, null=True, blank=True) + receive_news_updates = models.BooleanField(default=True) + receive_new_content = models.BooleanField(default=True) class Meta: db_table = "bloggy_user" diff --git a/bloggy/templates/.DS_Store b/bloggy/templates/.DS_Store index 3ce9dd1..5c08fbd 100644 Binary files a/bloggy/templates/.DS_Store and b/bloggy/templates/.DS_Store differ diff --git a/bloggy/templates/pages/user_profile.html b/bloggy/templates/pages/user_profile.html index 721cdfc..7921d05 100644 --- a/bloggy/templates/pages/user_profile.html +++ b/bloggy/templates/pages/user_profile.html @@ -39,9 +39,13 @@

{{ userProfile.username }}

My articles(so far)

- {% for post in posts %} -
{% include "partials/post_list_item.html" with post=post cssClass="" %}
- {% endfor %} + {% if posts|length <= 0 %} +

Currently, there are no published posts.

+ {% else %} + {% for post in posts %} +
{% include "partials/post_list_item.html" with post=post cssClass="" %}
+ {% endfor %} + {% endif %}
{% include 'partials/paging.html' with posts=posts %} diff --git a/bloggy/templates/partials/article_row_list.html b/bloggy/templates/partials/article_row_list.html index afcb2be..604a71f 100644 --- a/bloggy/templates/partials/article_row_list.html +++ b/bloggy/templates/partials/article_row_list.html @@ -7,41 +7,39 @@
-

- {{ article.title }} +

+ {{ post.title }}

- {% if article.author.username == user.username %} + {% if post.author.username == user.username %}   - {% get_hit_count for article %} views + {% get_hit_count for post %} views - - {{ article.get_comments_count }} comments + {{ post.get_comments_count }} comments - Edit + Edit {% endif %}
- {% if article.thumbnail %} + {% if post.thumbnail %}
- {{ article.title }} + {{ post.title }}
{% endif %}
diff --git a/bloggy/templates/partials/dashboard_menu.html b/bloggy/templates/partials/dashboard_menu.html index 17f551c..4db528d 100644 --- a/bloggy/templates/partials/dashboard_menu.html +++ b/bloggy/templates/partials/dashboard_menu.html @@ -1,18 +1,25 @@ {% load static %} {% load custom_widgets %} -
+
Home
Account
- Your profile + + Dashboard
+ {% if user.is_staff %} + Your profile +
+ {% endif %} + {% if user.is_superuser %} - Dashboard + Admin panel
{% endif %} diff --git a/bloggy/templates/partials/header.html b/bloggy/templates/partials/header.html index 7f29add..9e3a351 100644 --- a/bloggy/templates/partials/header.html +++ b/bloggy/templates/partials/header.html @@ -52,25 +52,35 @@