Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_vincentdjango
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
Almira Redoble
midterm_vincentdjango
Commits
1b927ea1
Commit
1b927ea1
authored
Mar 06, 2023
by
Andrew Justin C. Idquival
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed output views and added admin
parent
2bf6795a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
10 deletions
+34
-10
admin.py
widget_vincentdjango/calendar/admin.py
+16
-0
models.py
widget_vincentdjango/calendar/models.py
+8
-3
views.py
widget_vincentdjango/calendar/views.py
+10
-7
No files found.
widget_vincentdjango/calendar/admin.py
View file @
1b927ea1
...
@@ -2,4 +2,20 @@ from django.contrib import admin
...
@@ -2,4 +2,20 @@ from django.contrib import admin
from
.models
import
Event
,
Location
from
.models
import
Event
,
Location
class
EventInline
(
admin
.
TabularInline
):
model
=
Event
class
WidgetUserAdmin
(
admin
.
ModelAdmin
):
model
=
Event
list_display
=
(
'last_name'
,
'first_name'
,
'department'
)
search_fields
=
(
'last_name'
,
'first_name'
,
'department'
)
list_filter
=
(
'last_name'
,
'department'
)
fieldsets
=
[
(
'Name'
,
{
'fields'
:
((
'last_name'
,
'first_name'
),
'middle_name'
,
'department'
,),
}),
]
widget_vincentdjango/calendar/models.py
View file @
1b927ea1
from
django.db
import
models
from
django.db
import
models
from
datetime
import
datetime
class
Event
(
models
.
Model
):
class
Event
(
models
.
Model
):
target_datetime
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
target_datetime
=
models
.
DateTimeField
(
default
=
datetime
.
now
()
)
activity
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
activity
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
estimated_hours
=
models
.
FloatField
(
default
=
0
)
estimated_hours
=
models
.
FloatField
(
default
=
0
)
location
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
location
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
course
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
course
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
def
__str__
(
self
):
def
__str__
(
self
):
return
'{}, {}'
.
format
(
self
.
dept_name
,
self
.
home_unit
)
return
"Widget’s Calendar of Activities"
"Date and Time: {}"
'Activity: {}'
'Estimated Hours: {}'
'Course/Section: {}'
.
format
(
self
.
target_datetime
,
self
.
activity
,
self
.
estimated_hours
,
self
.
course
)
class
Location
(
models
.
Model
):
class
Location
(
models
.
Model
):
...
@@ -17,4 +22,4 @@ class Location(models.Model):
...
@@ -17,4 +22,4 @@ class Location(models.Model):
venue
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
venue
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
def
__str__
(
self
):
def
__str__
(
self
):
return
'{}, {}'
.
format
(
self
.
mode
,
self
.
venue
)
return
'{} {}'
.
format
(
self
.
mode
,
self
.
venue
)
\ No newline at end of file
widget_vincentdjango/calendar/views.py
View file @
1b927ea1
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
django.http
import
HttpResponse
from
.models
import
Event
,
Location
def
index
(
request
):
def
index
(
request
):
...
@@ -12,16 +14,17 @@ def index(request):
...
@@ -12,16 +14,17 @@ def index(request):
body
=
""
body
=
""
for
event
in
Event
.
objects
.
all
():
body
+=
"<p style='border: 2px solid gray;
\
border-radius:5px;
\
padding:20px 30px;'>
\
{}<br>
\
</p>"
.
format
(
event
)
return_string
=
"<html>
\
return_string
=
"<html>
\
<body style = 'font-family:helvetica;
\
<body style = 'font-family:helvetica;
\
padding:30px;'>
\
padding:30px;'>
\
{}{}
\
{}{}
\
</body></html>"
.
format
(
head
,
body
)
</body></html>"
.
format
(
head
,
body
)
return
HttpResponse
(
"Widget’s Calendar of Activities<br>"
return
HttpResponse
(
return_string
)
"Date and Time: <target date>, <target time><br>"
"Activity: <activity><br>"
"Estimated Hours: <estimated hours><br>"
"Course/Section: <course_code> <course_title>-<section><br>"
"Mode: <mode><br>"
"Venue: <venue><br>"
)
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