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
5a223fde
Commit
5a223fde
authored
Jul 09, 2024
by
impfundev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: shifting librarian create,update, delete form to reusable template
parent
ba7e9563
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
27 deletions
+8
-27
create_form.html
dashboards/templates/form/create_form.html
+2
-6
delete_form.html
dashboards/templates/form/delete_form.html
+1
-4
update_form.html
dashboards/templates/form/update_form.html
+1
-5
librarians_table_data.html
librarians/templates/librarians_table_data.html
+1
-1
views.py
librarians/views.py
+3
-11
No files found.
librarians/templates/librarians_
create_form.html
→
dashboards/templates/form/
create_form.html
View file @
5a223fde
{% extends "layout.html" %} {% block dashboard %}
<div
style=
"max-width: 80vw"
class=
"w-100 p-4"
>
<div
class=
"d-flex flex-column gap-2 mb-4"
>
<h1
class=
"h3"
>
Create Librarian Account
</h1>
<form
id=
"librarian_update_modal_{{ librarian_id }}"
action=
"/dashboard/librarians/add/"
method=
"POST"
>
<h1
class=
"h3"
>
Add Data
</h1>
<form
action=
""
method=
"POST"
>
{% csrf_token %}
<div
class=
"d-flex flex-column gap-1"
>
{{ form }}
</div>
<div
class=
"d-flex gap-2 my-3"
>
...
...
librarians/templates/librarians_
delete_form.html
→
dashboards/templates/form/
delete_form.html
View file @
5a223fde
...
...
@@ -2,10 +2,7 @@
<div
style=
"max-width: 80vw"
class=
"w-100 p-4"
>
<div
class=
"d-flex flex-column gap-2 mb-4"
>
<h1
class=
"h3"
>
Are you sure want to delete this data
<form
action=
""
method=
"POST"
>
<form
action=
""
method=
"POST"
>
{% csrf_token %}
<div
class=
"d-flex flex-column gap-1"
>
Once data is deleted, it cannot be restored.
</div>
<div
class=
"d-flex gap-2 my-3"
>
...
...
librarians/templates/librarians_
update_form.html
→
dashboards/templates/form/
update_form.html
View file @
5a223fde
...
...
@@ -2,11 +2,7 @@
<div
style=
"max-width: 80vw"
class=
"w-100 p-4"
>
<div
class=
"d-flex flex-column gap-2 mb-4"
>
<h1
class=
"h3"
>
Update Data
</h1>
<form
id=
"librarian_update_modal_{{ librarian_id }}"
action=
""
method=
"POST"
>
<form
action=
""
method=
"POST"
>
{% csrf_token %}
<div
class=
"d-flex flex-column gap-1"
>
{{ form }}
</div>
<div
class=
"d-flex gap-2 my-3"
>
...
...
librarians/templates/librarians_table_data.html
View file @
5a223fde
...
...
@@ -9,7 +9,7 @@
</tr>
</thead>
<tbody>
{% if
librarians %} {% for librarian in librarians
%}
{% if
object_list %} {% for librarian in object_list
%}
<tr>
<td>
{{ librarian.name }}
</td>
<td>
{{ librarian.email }}
</td>
...
...
librarians/views.py
View file @
5a223fde
from
django.db.models
import
Q
from
django.views
import
generic
from
django.http
import
HttpResponseRedirect
from
django.shortcuts
import
render
,
redirect
,
get_object_or_404
from
datetime
import
datetime
from
authentications.utils
import
Hasher
from
librarians.models
import
Librarians
from
librarians.forms
import
LibrarianForm
...
...
@@ -15,7 +8,6 @@ class LibrarianListView(generic.ListView):
model
=
Librarians
template_name
=
"librarians.html"
paginate_by
=
5
context_object_name
=
"librarians"
def
get_queryset
(
self
):
queryset
=
super
()
.
get_queryset
()
...
...
@@ -40,7 +32,7 @@ class LibrarianCreateView(generic.edit.CreateView):
model
=
Librarians
form_class
=
LibrarianForm
success_url
=
"/dashboard/librarians/"
template_name
=
"
librarians_
create_form.html"
template_name
=
"
form/
create_form.html"
success_message
=
"Librarian created successfully!"
...
...
@@ -48,12 +40,12 @@ class LibrarianUpdateView(generic.edit.UpdateView):
model
=
Librarians
form_class
=
LibrarianForm
success_url
=
"/dashboard/librarians"
template_name
=
"
librarians_
update_form.html"
template_name
=
"
form/
update_form.html"
success_message
=
"Librarian updated successfully!"
class
LibrarianDeleteView
(
generic
.
edit
.
DeleteView
):
model
=
Librarians
success_url
=
"/dashboard/librarians"
template_name
=
"
librarians_
delete_form.html"
template_name
=
"
form/
delete_form.html"
success_message
=
"Librarian deleted successfully!"
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