Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
library-app-django
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ilham Maulana
library-app-django
Commits
1459f12f
Commit
1459f12f
authored
Jul 10, 2024
by
impfundev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: allow blank on descriprion book and add uuid field on librarian and member master
parent
ff250a88
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
2 deletions
+13
-2
models.py
books/models.py
+9
-1
models.py
librarians/models.py
+2
-1
models.py
members/models.py
+2
-0
No files found.
books/models.py
View file @
1459f12f
from
datetime
import
datetime
from
django.db
import
models
from
django.db
import
models
from
categories.models
import
Category
from
categories.models
import
Category
from
django.core.validators
import
MinValueValidator
,
MaxValueValidator
class
Book
(
models
.
Model
):
class
Book
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
)
title
=
models
.
CharField
(
max_length
=
100
)
description
=
models
.
CharField
(
max_length
=
255
)
description
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
null
=
True
)
stock
=
models
.
BigIntegerField
(
blank
=
True
,
null
=
True
)
stock
=
models
.
BigIntegerField
(
blank
=
True
,
null
=
True
)
category
=
models
.
ForeignKey
(
category
=
models
.
ForeignKey
(
to
=
Category
,
on_delete
=
models
.
CASCADE
,
blank
=
True
,
null
=
True
to
=
Category
,
on_delete
=
models
.
CASCADE
,
blank
=
True
,
null
=
True
...
@@ -12,6 +14,12 @@ class Book(models.Model):
...
@@ -12,6 +14,12 @@ class Book(models.Model):
cover_image
=
models
.
ImageField
(
upload_to
=
"uploads"
,
blank
=
True
,
null
=
True
)
cover_image
=
models
.
ImageField
(
upload_to
=
"uploads"
,
blank
=
True
,
null
=
True
)
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
updated_at
=
models
.
DateTimeField
(
auto_now
=
True
)
updated_at
=
models
.
DateTimeField
(
auto_now
=
True
)
published_year
=
models
.
PositiveIntegerField
(
validators
=
[
MinValueValidator
(
1900
),
MaxValueValidator
(
datetime
.
now
()
.
year
)],
help_text
=
"E.g: 2024"
,
blank
=
True
,
null
=
True
,
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
title
return
self
.
title
...
...
librarians/models.py
View file @
1459f12f
import
uuid
from
django.db
import
models
from
django.db
import
models
from
django.contrib.auth.models
import
User
class
Librarians
(
models
.
Model
):
class
Librarians
(
models
.
Model
):
uuid
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
())
name
=
models
.
CharField
(
max_length
=
50
)
name
=
models
.
CharField
(
max_length
=
50
)
email
=
models
.
EmailField
()
email
=
models
.
EmailField
()
password
=
models
.
CharField
(
max_length
=
255
)
password
=
models
.
CharField
(
max_length
=
255
)
...
...
members/models.py
View file @
1459f12f
import
uuid
from
django.db
import
models
from
django.db
import
models
from
members.utils
import
generate_unique_number
from
members.utils
import
generate_unique_number
...
@@ -5,6 +6,7 @@ random_number = generate_unique_number(15)
...
@@ -5,6 +6,7 @@ random_number = generate_unique_number(15)
class
Members
(
models
.
Model
):
class
Members
(
models
.
Model
):
uuid
=
models
.
UUIDField
(
default
=
uuid
.
uuid4
())
account_number
=
models
.
CharField
(
account_number
=
models
.
CharField
(
default
=
random_number
,
editable
=
False
,
max_length
=
15
default
=
random_number
,
editable
=
False
,
max_length
=
15
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment