Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_group 6
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
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
Patricia Isabella Nava
widget_group 6
Commits
94be781c
Commit
94be781c
authored
May 26, 2022
by
Pierre Ashley Salcedo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: added form for creating new entry in WidgetUser
parent
98c380aa
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
85 additions
and
15 deletions
+85
-15
db.sqlite3
widget_group_6/db.sqlite3
+0
-0
forms.py
widget_group_6/homepage/forms.py
+8
-0
0003_widgetuser_profile_image.py
...up_6/homepage/migrations/0003_widgetuser_profile_image.py
+18
-0
models.py
widget_group_6/homepage/models.py
+5
-0
no_image.png
widget_group_6/homepage/static/homepage/images/no_image.png
+0
-0
style.css
widget_group_6/homepage/static/homepage/style.css
+16
-3
add.html
widget_group_6/homepage/templates/homepage/add.html
+14
-0
detail.html
widget_group_6/homepage/templates/homepage/detail.html
+4
-8
index.html
widget_group_6/homepage/templates/homepage/index.html
+5
-1
urls.py
widget_group_6/homepage/urls.py
+2
-1
views.py
widget_group_6/homepage/views.py
+13
-2
No files found.
widget_group_6/db.sqlite3
View file @
94be781c
No preview for this file type
widget_group_6/homepage/forms.py
0 → 100644
View file @
94be781c
from
django.forms
import
ModelForm
from
.models
import
WidgetUser
class
UserForm
(
ModelForm
):
class
Meta
:
model
=
WidgetUser
fields
=
[
"last_name"
,
"first_name"
,
"middle_name"
,
"id_num"
,
"email"
,
"department"
,
"profile_image"
]
\ No newline at end of file
widget_group_6/homepage/migrations/0003_widgetuser_profile_image.py
0 → 100644
View file @
94be781c
# Generated by Django 4.0.3 on 2022-05-26 21:45
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'homepage'
,
'0002_auto_20220407_0505'
),
]
operations
=
[
migrations
.
AddField
(
model_name
=
'widgetuser'
,
name
=
'profile_image'
,
field
=
models
.
ImageField
(
blank
=
True
,
null
=
True
,
upload_to
=
'images/'
),
),
]
widget_group_6/homepage/models.py
View file @
94be781c
...
@@ -26,6 +26,11 @@ class WidgetUser(models.Model):
...
@@ -26,6 +26,11 @@ class WidgetUser(models.Model):
default
=
None
,
default
=
None
,
null
=
True
null
=
True
)
)
profile_image
=
models
.
ImageField
(
upload_to
=
"images/"
,
blank
=
True
,
null
=
True
)
department
=
models
.
ForeignKey
(
department
=
models
.
ForeignKey
(
Department
,
Department
,
on_delete
=
models
.
CASCADE
,
on_delete
=
models
.
CASCADE
,
...
...
widget_group_6/homepage/static/homepage/images/no_image.png
0 → 100644
View file @
94be781c
24.4 KB
widget_group_6/homepage/static/homepage/style.css
View file @
94be781c
...
@@ -31,16 +31,29 @@ ul { list-style-type: none; }
...
@@ -31,16 +31,29 @@ ul { list-style-type: none; }
li
{
margin
:
10px
0
;
}
li
{
margin
:
10px
0
;
}
table
{
width
:
100%
;
}
th
{
text-align
:
right
;}
a
{
color
:
rgb
(
255
,
255
,
255
);
}
a
{
color
:
rgb
(
255
,
255
,
255
);
}
img
{
width
:
400px
;
}
img
{
width
:
400px
;
}
button
{
width
:
10em
;
margin
:
1em
3em
;
}
input
,
select
{
width
:
100%
;
box-sizing
:
border-box
;
}
#userInfo
{
#userInfo
{
display
:
flex
;
display
:
flex
;
flex-flow
:
row
wrap-reverse
;
flex-flow
:
row
wrap-reverse
;
justify-content
:
space-evenly
;
justify-content
:
space-evenly
;
}
}
#userInfo
>
div
{
#userInfo
>
div
{
flex
:
0
1
auto
;
}
flex
:
0
1
auto
;
}
\ No newline at end of file
widget_group_6/homepage/templates/homepage/add.html
0 → 100644
View file @
94be781c
{% extends "homepage/base.html" %}
{% block content %}
<header><h1>
ADD WIDGET USER
</h1></header>
<form
action=
"{% url 'homepage:add' %}"
method=
"POST"
enctype=
"multipart/form-data"
>
{% csrf_token %}
<table>
{{ user_form.as_table }}
</table>
<br>
<button
class=
"button"
type=
"submit"
>
Save New User
</button>
</form>
{% endblock %}
\ No newline at end of file
widget_group_6/homepage/templates/homepage/detail.html
View file @
94be781c
...
@@ -14,14 +14,10 @@
...
@@ -14,14 +14,10 @@
</ul>
</ul>
</div>
</div>
<div>
<div>
{% if user.id_num == 201234 %}
{% if user.profile_image %}
<img
src =
"{% static 'homepage/images/201234.png' %}"
alt =
"profile image"
>
<img
src =
"{{user.profile_image.url}}"
alt =
"profile image"
>
{% elif user.id_num == 201524 %}
<img
src =
"{% static 'homepage/images/201524.png' %}"
alt =
"profile image"
>
{% elif user.id_num == 204483 %}
<img
src =
"{% static 'homepage/images/204483.png' %}"
alt =
"profile image"
>
{% else %}
{% else %}
<img
src =
"{% static 'homepage/images/
205678.png' %}"
alt =
"profile image
"
>
<img
src =
"{% static 'homepage/images/
no_image.png' %}
"
>
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
...
...
widget_group_6/homepage/templates/homepage/index.html
View file @
94be781c
...
@@ -7,12 +7,16 @@
...
@@ -7,12 +7,16 @@
{% if user_list %}
{% if user_list %}
<ol>
<ol>
{% for user in user_list %}
{% for user in user_list %}
<li>
<a
href =
"{% url 'homepage:detail' user.id_num %}"
>
<li><a
href =
"{% url 'homepage:detail' user.id_num %}"
>
{{user.last_name}}, {{user.first_name}} {{user.middle_name}}
{{user.last_name}}, {{user.first_name}} {{user.middle_name}}
</a></li>
</a></li>
{% endfor %}
{% endfor %}
</ol>
</ol>
<ul><a
href =
"{% url 'homepage:add' %}"
class =
"addToListLink"
>
Add Widget User
</a></ul>
{% else %}
{% else %}
<p>
No users available.
</p>
<p>
No users available.
</p>
{% endif %}
{% endif %}
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_group_6/homepage/urls.py
View file @
94be781c
...
@@ -4,5 +4,6 @@ from . import views
...
@@ -4,5 +4,6 @@ from . import views
app_name
=
"homepage"
app_name
=
"homepage"
urlpatterns
=
[
urlpatterns
=
[
path
(
""
,
views
.
index
,
name
=
"homepage"
),
path
(
""
,
views
.
index
,
name
=
"homepage"
),
path
(
"<int:user_id>/details"
,
views
.
detail
,
name
=
"detail"
)
path
(
"users/add/"
,
views
.
add
,
name
=
"add"
),
path
(
"users/<int:user_id>/details/"
,
views
.
detail
,
name
=
"detail"
)
]
]
\ No newline at end of file
widget_group_6/homepage/views.py
View file @
94be781c
from
django.shortcuts
import
render
from
django.shortcuts
import
re
direct
,
re
nder
from
django.http
import
Http404
,
HttpResponse
from
django.http
import
Http404
,
HttpResponse
from
.models
import
WidgetUser
from
.models
import
WidgetUser
from
.forms
import
UserForm
# Create your views here.
# Create your views here.
def
index
(
request
):
def
index
(
request
):
...
@@ -19,3 +20,13 @@ def detail(request, user_id):
...
@@ -19,3 +20,13 @@ def detail(request, user_id):
"user"
:
user
"user"
:
user
}
}
return
render
(
request
,
"homepage/detail.html"
,
context
)
return
render
(
request
,
"homepage/detail.html"
,
context
)
def
add
(
request
):
if
request
.
method
==
"POST"
:
user_form
=
UserForm
(
request
.
POST
,
request
.
FILES
)
if
user_form
.
is_valid
():
new_user
=
user_form
.
save
()
return
redirect
(
"homepage:homepage"
)
else
:
user_form
=
UserForm
()
return
render
(
request
,
"homepage/add.html"
,
{
"user_form"
:
user_form
})
\ No newline at end of file
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