From 5a8b1ceb1eadb4bb5e1978245f35e00a2594d014 Mon Sep 17 00:00:00 2001 From: Nilanchala Date: Wed, 10 Jan 2024 17:53:23 +0000 Subject: [PATCH] Added dashbaord --- bloggy/forms/edit_profile_form.py | 34 +++++---- ...e_new_content_user_receive_news_updates.py | 23 ++++++ bloggy/models/user.py | 2 + bloggy/templates/.DS_Store | Bin 6148 -> 8196 bytes bloggy/templates/pages/user_profile.html | 10 ++- .../templates/partials/article_row_list.html | 32 ++++----- bloggy/templates/partials/dashboard_menu.html | 15 ++-- bloggy/templates/partials/header.html | 68 ++++++++++++------ bloggy/templates/profile/account_view.html | 31 +++++--- bloggy/templates/profile/change_password.html | 8 +-- bloggy/templates/profile/edit_profile.html | 43 +++++++---- .../templates/profile/my_dashboard_view.html | 34 +++++++++ bloggy/templates/profile/update_username.html | 8 +-- bloggy/templates/profile/user_bookmarks.html | 6 +- bloggy/urls.py | 4 +- bloggy/views/edit_profile_view.py | 53 +++++++------- bloggy/views/login.py | 6 ++ bloggy/views/my_dashboard_view.py | 43 +++++++++++ bloggy/views/user.py | 2 +- 19 files changed, 299 insertions(+), 123 deletions(-) create mode 100644 bloggy/migrations/0008_user_receive_new_content_user_receive_news_updates.py create mode 100644 bloggy/templates/profile/my_dashboard_view.html create mode 100644 bloggy/views/my_dashboard_view.py 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 3ce9dd10aa59164d02db1068318f7fba98b7bd17..5c08fbd6f3964200ebd2c4954108d769073076b4 100644 GIT binary patch literal 8196 zcmeHMU2GIp6u#f|hgmzc(+YNgg|1Wy7E5cHF(wsq>GlWk@SfM~Xo$L}~ zIzv)o)JGABB5-vCcJ=$ zI&J4XcgQ|z9oOspNpI!=iHGx6(Y9tra-LI|a{c3aeJ>T`&07BNq9xi&igrBv%dmX@k?;jeo?-`-IKO zcDcsbx!T6~?RU1c-FyF@?tKRzny=IA8*bIsYGbx(xq&@yTlvw9pR-)kb|;2sY%`b~ zDcZiBb*z+|nX+Q_xH~rApx4(K#`+DasyC+#S^J5C9Xu&~Z8Vy+Vz;JtHS>(^|FE3EMSex-T{DT8A<0WU`hM(@kl1 zpSIH&DazHw^nR(_rL8s6Id5u;mg2{x?m;7IJjx$?DB}l%)0WF$>7pF#p|LT4GLyFk zXIv{EzEK}(#m`52ZnW351CI~NRW}W&>L_>EWtx^L)-Y&1OcuKB7VUt331R?2!B_R~ zRkgW9uI6Nmyp?fWQ__dXclwQN3+tqvJ;lbE$4;>q*%|gByTCqS->@IpFYGe=oh`Dz z**{QF0S&8B3mxmQ8Et4s2X1G{6Cd3t3iZc38Kgb)Z1B6NTPikQVo zJcDQP9G=H%LF!iosb9w%IEy!N4)5YUypNCYF)rX!d`2|?8uPe>g=OSDR8C%8E+=ns zDDOI+J3-nK-OCLk>4u2_Kl`Z}y#C+2^7nr+De9sKL=m_#BY?`@q26v<+e$k=ueB3& zJw_LAeBPWyVM3iK#|cF_PI%=HL%L7URBn?DaZVy>sQvFB0;2O@#69ey^M7eHZle2t E0adHlUjP6A delta 131 zcmZp1XfcprU|?W$DortDU=RQ@Ie-{MGqg=C6q~50D9i|C12IsnxGcCRFDE}QePW>| zBjaXXv0scE8yZ;`vvY6=GJ~`LRdE9eS0HZNSoocJGQW&2CrJMRAZD0s!z0bZ1hD~R LDZ}P?o*B#l_`w#8 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 @@