Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_django unchained
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
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
Jose Emmanuel B. Laurel
widget_django unchained
Commits
81e2ed6a
Commit
81e2ed6a
authored
May 26, 2022
by
Jose Emmanuel B. Laurel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New Feature: edited homepage/forms.py for use if ever
parent
dcfbdfaa
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
11 deletions
+45
-11
db.sqlite3
widget_django_unchained/db.sqlite3
+0
-0
forms.cpython-39.pyc
...jango_unchained/homepage/__pycache__/forms.cpython-39.pyc
+0
-0
views.cpython-39.pyc
...jango_unchained/homepage/__pycache__/views.cpython-39.pyc
+0
-0
forms.py
widget_django_unchained/homepage/forms.py
+14
-5
createUser_form.html
...nchained/homepage/templates/homepage/createUser_form.html
+11
-1
views.py
widget_django_unchained/homepage/views.py
+16
-5
style.css
widget_django_unchained/static/style.css
+4
-0
No files found.
widget_django_unchained/db.sqlite3
View file @
81e2ed6a
No preview for this file type
widget_django_unchained/homepage/__pycache__/forms.cpython-39.pyc
View file @
81e2ed6a
No preview for this file type
widget_django_unchained/homepage/__pycache__/views.cpython-39.pyc
View file @
81e2ed6a
No preview for this file type
widget_django_unchained/homepage/forms.py
View file @
81e2ed6a
from
multiprocessing.sharedctypes
import
Value
from
unicodedata
import
name
from
django
import
forms
from
django
import
forms
from
django.forms
import
ModelForm
from
homepage.models
import
WidgetUser
from
homepage.models
import
WidgetUser
,
Department
class
IndexCardForm
(
forms
.
Form
):
class
CreateUserForm
(
ModelForm
,
forms
.
Form
):
name
=
forms
.
CharField
(
label
=
'Full Name'
,
max_length
=
100
)
class
Meta
:
section
=
forms
.
CharField
(
label
=
'CSCI40 Section'
,
max_length
=
5
)
model
=
WidgetUser
age
=
forms
.
IntegerField
(
label
=
'Current Age'
)
fields
=
[
"last_name"
,
"first_name"
,
"middle_name"
,
"id_num"
,
"email"
]
\ No newline at end of file
departments
=
forms
.
ModelChoiceField
(
label
=
'Department'
,
queryset
=
Department
.
objects
.
all
(),
initial
=
Department
.
objects
.
first
()
)
\ No newline at end of file
widget_django_unchained/homepage/templates/homepage/createUser_form.html
View file @
81e2ed6a
{% extends "homepage/base.html" %}
{% extends "homepage/base.html" %}
{% block content %}
{% block content %}
<form
action=
"newUser/"
method=
"POST"
>
<h1>
Create User:
</h1>
<form
method=
"POST"
action=
"{% url 'homepage:newUser' %}"
>
{% csrf_token %}
{% csrf_token %}
<!-- {{ createUserForm.as_p }} -->
<h3>
Enter Last Name:
</h3>
<input
type=
"text"
name=
"Last name"
>
<h3>
Enter Last Name:
</h3>
<input
type=
"text"
name=
"Last name"
>
<h3>
Enter First Name:
</h3>
<input
type=
"text"
name=
"First name"
>
<h3>
Enter First Name:
</h3>
<input
type=
"text"
name=
"First name"
>
<h3>
Enter Middle Name:
</h3>
<input
type=
"text"
name=
"Middle name"
>
<h3>
Enter Middle Name:
</h3>
<input
type=
"text"
name=
"Middle name"
>
...
@@ -23,5 +27,11 @@
...
@@ -23,5 +27,11 @@
<br>
<br>
<button
class=
"button"
type=
"submit"
>
Save New User
</button>
<button
class=
"button"
type=
"submit"
>
Save New User
</button>
<br>
<br>
<a
href=
"{% url 'homepage:index' %}"
>
Return to Homepage
</a>
</form>
</form>
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_django_unchained/homepage/views.py
View file @
81e2ed6a
from
.models
import
Department
from
homepage.forms
import
CreateUserForm
from
.models
import
WidgetUser
from
.models
import
WidgetUser
,
Department
from
django.http
import
HttpResponse
,
Http404
from
django.http
import
HttpResponse
,
Http404
from
django.shortcuts
import
render
from
django.shortcuts
import
re
direct
,
re
nder
def
index
(
request
):
def
index
(
request
):
widgetUser
=
WidgetUser
.
objects
.
order_by
(
"last_name"
)
widgetUser
=
WidgetUser
.
objects
.
order_by
(
"last_name"
)
...
@@ -11,9 +11,20 @@ def index(request):
...
@@ -11,9 +11,20 @@ def index(request):
return
render
(
request
,
"homepage/widgetusers_orderedlist.html"
,
context
)
return
render
(
request
,
"homepage/widgetusers_orderedlist.html"
,
context
)
def
createUser
(
request
):
def
createUser
(
request
):
# if request.method == "POST":
# createUserForm = CreateUserForm(request.POST)
# if createUserForm.is_valid():
# newWidgetUser = createUserForm.save()
# newWidgetUser.department_id = Department.objects.get(request.POST['Department'].pk)
# newWidgetUser.save()
# return redirect("homepage:createUser")
# else:
# createUserForm = CreateUserForm()
department
=
Department
.
objects
.
all
()
department
=
Department
.
objects
.
all
()
context
=
{
context
=
{
"Department"
:
department
"Department"
:
department
,
# "createUserForm" : createUserForm
}
}
return
render
(
request
,
"homepage/createUser_form.html"
,
context
)
return
render
(
request
,
"homepage/createUser_form.html"
,
context
)
...
@@ -26,7 +37,7 @@ def newUser(request):
...
@@ -26,7 +37,7 @@ def newUser(request):
email
=
request
.
POST
.
get
(
"Email address"
)
email
=
request
.
POST
.
get
(
"Email address"
)
dept_Value
=
request
.
POST
.
get
(
"newDepartment"
)
dept_Value
=
request
.
POST
.
get
(
"newDepartment"
)
widgetUser
=
WidgetUser
.
objects
.
create
(
first_name
=
first_name
,
middle_name
=
middle_name
,
last_name
=
last_name
,
id_num
=
id_num
,
email
=
email
,
department_id
=
dept_Value
)
widgetUser
=
WidgetUser
.
objects
.
create
(
first_name
=
first_name
,
middle_name
=
middle_name
,
last_name
=
last_name
,
id_num
=
id_num
,
email
=
email
,
department_id
=
dept_Value
)
return
HttpResponse
(
"User Added
"
)
return
redirect
(
"homepage:createUser
"
)
def
detail
(
request
,
widgetuser_id
):
def
detail
(
request
,
widgetuser_id
):
try
:
try
:
...
...
widget_django_unchained/static/style.css
View file @
81e2ed6a
...
@@ -10,6 +10,10 @@ h3 {
...
@@ -10,6 +10,10 @@ h3 {
color
:
palevioletred
;
color
:
palevioletred
;
font-weight
:
bold
;
font-weight
:
bold
;
}
}
p
{
color
:
palevioletred
;
font-weight
:
bold
;
}
ol
{
ol
{
color
:
wheat
;
color
:
wheat
;
font-weight
:
bold
;
font-weight
:
bold
;
...
...
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