-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from rkshaon/rkshaon
backend
- Loading branch information
Showing
42 changed files
with
675 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/env | ||
__pycache__ | ||
__pycache__ | ||
/media |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from django.contrib import admin | ||
|
||
from author_api.models import Author | ||
|
||
|
||
@admin.register(Author) | ||
class AuthorAdmin(admin.ModelAdmin): | ||
list_display = [ | ||
'id', 'full_name', 'birth_date', | ||
'died_date', 'is_alive', | ||
] | ||
list_display_links = ('id', 'full_name',) | ||
list_filter = [] | ||
search_fields = ('first_name', 'last_name', 'birth_date') | ||
readonly_fields = ('id',) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AuthorApiConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'author_api' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 5.1.1 on 2024-09-06 19:40 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Author', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('first_name', models.CharField(max_length=100)), | ||
('last_name', models.CharField(max_length=100)), | ||
('biography', models.TextField(blank=True, null=True)), | ||
('birth_date', models.DateField(blank=True, null=True)), | ||
], | ||
), | ||
] |
38 changes: 38 additions & 0 deletions
38
backend/author_api/migrations/0002_author_added_by_author_added_date_time_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generated by Django 5.1.1 on 2024-09-06 19:46 | ||
|
||
import django.db.models.deletion | ||
import django.utils.timezone | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('author_api', '0001_initial'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='author', | ||
name='added_by', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='author', | ||
name='added_date_time', | ||
field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), | ||
preserve_default=False, | ||
), | ||
migrations.AddField( | ||
model_name='author', | ||
name='is_deleted', | ||
field=models.BooleanField(default=False), | ||
), | ||
migrations.AddField( | ||
model_name='author', | ||
name='updated_date_time', | ||
field=models.DateTimeField(auto_now=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.1.1 on 2024-09-06 19:52 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('author_api', '0002_author_added_by_author_added_date_time_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='author', | ||
name='died_date', | ||
field=models.DateField(blank=True, null=True), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from django.db import models | ||
|
||
|
||
class Author(models.Model): | ||
first_name = models.CharField(max_length=100) | ||
last_name = models.CharField(max_length=100) | ||
biography = models.TextField(blank=True, null=True) # Optional bio field | ||
birth_date = models.DateField(null=True, blank=True) | ||
died_date = models.DateField(null=True, blank=True) | ||
added_by = models.ForeignKey( | ||
'user_api.User', | ||
blank=True, | ||
null=True, | ||
on_delete=models.CASCADE | ||
) | ||
is_deleted = models.BooleanField(default=False) | ||
added_date_time = models.DateTimeField(auto_now_add=True) | ||
updated_date_time = models.DateTimeField(auto_now=True) | ||
|
||
@property | ||
def full_name(self): | ||
return f"{self.first_name} {self.last_name}" | ||
|
||
@property | ||
def is_alive(self): | ||
return True if not self.died_date else False | ||
|
||
def __str__(self): | ||
return f'{self.first_name} {self.last_name}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
File renamed without changes.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.contrib import admin | ||
|
||
from book_api.models import Book | ||
|
||
|
||
@admin.register(Book) | ||
class BookAdmin(admin.ModelAdmin): | ||
list_display = [ | ||
'id', 'title', 'edition', 'isbn', | ||
'published_date', 'language', | ||
'is_deleted', | ||
] | ||
list_display_links = [ | ||
'title', | ||
] | ||
list_filter = [ | ||
'authors', 'publisher', | ||
] | ||
search_fields = [ | ||
'title', 'edition', 'isbn', | ||
'published_date', 'language', | ||
'description', | ||
] | ||
readonly_fields = ['id',] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BookApiConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'book_api' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Generated by Django 5.1.1 on 2024-09-06 20:28 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('author_api', '0003_author_died_date'), | ||
('publisher_api', '0002_publisher_added_by_publisher_added_date_time_and_more'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Book', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('title', models.CharField(max_length=255)), | ||
('description', models.TextField(blank=True, null=True)), | ||
('edition', models.CharField(blank=True, max_length=50, null=True)), | ||
('isbn', models.CharField(blank=True, max_length=13, null=True, unique=True)), | ||
('pages', models.PositiveIntegerField(blank=True, null=True)), | ||
('published_date', models.DateField(blank=True, null=True)), | ||
('pdf_file', models.FileField(blank=True, null=True, upload_to='books')), | ||
('cover_image', models.ImageField(blank=True, null=True, upload_to='book_covers')), | ||
('is_deleted', models.BooleanField(default=False)), | ||
('added_date_time', models.DateTimeField(auto_now_add=True)), | ||
('updated_date_time', models.DateTimeField(auto_now=True)), | ||
('added_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
('authors', models.ManyToManyField(related_name='books', to='author_api.author')), | ||
('publisher', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='books', to='publisher_api.publisher')), | ||
], | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
backend/book_api/migrations/0002_rename_pdf_file_book_book.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.1.1 on 2024-09-06 20:32 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('book_api', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='book', | ||
old_name='pdf_file', | ||
new_name='book', | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.1.1 on 2024-09-06 20:33 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('book_api', '0002_rename_pdf_file_book_book'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='book', | ||
name='language', | ||
field=models.CharField(blank=True, max_length=200, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 5.1.1 on 2024-09-06 20:43 | ||
|
||
import book_api.models | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('book_api', '0003_book_language'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='book', | ||
name='book', | ||
field=models.FileField(blank=True, null=True, upload_to=book_api.models.book_upload_path), | ||
), | ||
] |
Empty file.
Oops, something went wrong.