From 81576e0f8f15d1e54831dd1b00afbf720b00e0b4 Mon Sep 17 00:00:00 2001 From: Rezaul Karim Shaon Date: Fri, 13 Sep 2024 00:12:22 +0600 Subject: [PATCH 1/3] updt: backend - user, book model user model updated for full name with admin book model updated for uploader with admin --- backend/book_api/admin.py | 2 +- backend/book_api/models.py | 4 +++ backend/user_api/admin.py | 8 ++++-- ...dle_name_alter_user_first_name_and_more.py | 28 +++++++++++++++++++ backend/user_api/models.py | 28 +++++++++++++++++++ 5 files changed, 66 insertions(+), 4 deletions(-) create mode 100644 backend/user_api/migrations/0003_user_middle_name_alter_user_first_name_and_more.py diff --git a/backend/book_api/admin.py b/backend/book_api/admin.py index 81560dd..506069e 100644 --- a/backend/book_api/admin.py +++ b/backend/book_api/admin.py @@ -30,7 +30,7 @@ class BookAdmin(admin.ModelAdmin): list_display = [ 'id', 'book_code', 'title', 'cover', 'edition', 'isbn', 'published_date', 'language', - 'is_deleted', + 'is_deleted', 'uploader', ] @admin.display(boolean=True) diff --git a/backend/book_api/models.py b/backend/book_api/models.py index 9cb1c4f..8ecf3b1 100644 --- a/backend/book_api/models.py +++ b/backend/book_api/models.py @@ -117,6 +117,10 @@ class Book(models.Model): def cover(self) -> bool: return bool(self.cover_image) + @property + def uploader(self): + return self.added_by + def __str__(self): authors = ", ".join([ author.full_name for author in self.authors.all() diff --git a/backend/user_api/admin.py b/backend/user_api/admin.py index e44c6d4..f6b8c5a 100644 --- a/backend/user_api/admin.py +++ b/backend/user_api/admin.py @@ -6,10 +6,12 @@ @admin.register(User) class UserAdmin(admin.ModelAdmin): list_display = ( - 'id', 'username', 'email', 'role', 'is_active', + 'id', 'full_name', 'username', 'email', 'role', 'is_active', 'is_staff', 'is_superuser', ) - list_display_links = ('id', 'username', 'email') + list_display_links = ['id', 'full_name', 'username', 'email'] list_filter = ('role', 'is_active', 'is_staff') - search_fields = ('username', 'email') + search_fields = [ + 'username', 'email', 'full_name' + ] readonly_fields = ('id',) diff --git a/backend/user_api/migrations/0003_user_middle_name_alter_user_first_name_and_more.py b/backend/user_api/migrations/0003_user_middle_name_alter_user_first_name_and_more.py new file mode 100644 index 0000000..cd91274 --- /dev/null +++ b/backend/user_api/migrations/0003_user_middle_name_alter_user_first_name_and_more.py @@ -0,0 +1,28 @@ +# Generated by Django 5.1.1 on 2024-09-12 18:06 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('user_api', '0002_remove_user_is_private'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='middle_name', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AlterField( + model_name='user', + name='first_name', + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AlterField( + model_name='user', + name='last_name', + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/backend/user_api/models.py b/backend/user_api/models.py index 1f8d113..83b192e 100644 --- a/backend/user_api/models.py +++ b/backend/user_api/models.py @@ -32,6 +32,15 @@ class User(AbstractUser): (3, 'Reader'), ) + first_name = models.CharField( + max_length=255, blank=True, null=True + ) + middle_name = models.CharField( + max_length=255, blank=True, null=True + ) + last_name = models.CharField( + max_length=255, blank=True, null=True + ) email = models.EmailField(unique=True) username = models.CharField( max_length=50, @@ -47,5 +56,24 @@ class User(AbstractUser): USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['username', 'role'] + @property + def full_name(self) -> str: + name = "" + + if self.first_name: + name += f"{self.first_name}" + + if self.middle_name: + if name: + name += f" {self.middle_name}" + else: + name += f"{self.middle_name}" + + if self.last_name: + if name: + name += f" {self.last_name}" + else: + name += f"{self.last_name}" + def __str__(self): return self.email From e257a4fed482ca4de5d24651b0bb6f161de96d62 Mon Sep 17 00:00:00 2001 From: Rezaul Karim Shaon Date: Fri, 13 Sep 2024 00:13:25 +0600 Subject: [PATCH 2/3] updt: deploy gunicorn status added --- deploy.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/deploy.sh b/deploy.sh index 667827d..ad0d1f1 100755 --- a/deploy.sh +++ b/deploy.sh @@ -47,5 +47,6 @@ python manage.py migrate echo -e "${BLUE}Restart Backend Gunicorn Service${RESET}" echo -e "${YELLOW}=======================================${RESET}" systemctl restart gunicorn-bookshelf.service +systemctl status gunicorn-bookshelf.service echo -e "${RED}Finish${RESET}..." From 0c4bd8fe20035b3ee4484f99f598473f45dd5449 Mon Sep 17 00:00:00 2001 From: Rezaul Karim Shaon Date: Fri, 13 Sep 2024 00:25:45 +0600 Subject: [PATCH 3/3] updt: frontend - home pagination button position fixed --- frontend/src/pages/HomePage.vue | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/frontend/src/pages/HomePage.vue b/frontend/src/pages/HomePage.vue index cb1ff52..d0a80ee 100644 --- a/frontend/src/pages/HomePage.vue +++ b/frontend/src/pages/HomePage.vue @@ -6,18 +6,34 @@ Explore a vast collection of books, share your reviews, and connect with other book lovers.

+
+
+ +
+
+
+ +
+
- - +
+ +
+
+
+ +