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 @@
Currently, there are no published posts.
+ {% else %} + {% for post in posts %} +