Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_robo_mommy
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Raul Jarod Conanan
midterm_robo_mommy
Commits
8b8c9045
Commit
8b8c9045
authored
Mar 06, 2023
by
RJC
Browse files
Options
Browse Files
Download
Plain Diff
pull changes from dev
parents
3fbd0a3a
70e63ef9
Changes
42
Show whitespace changes
Inline
Side-by-side
Showing
42 changed files
with
529 additions
and
1 deletion
+529
-1
db.sqlite3
...lf/Uncommitted_changes_before_rebase_[Changes]/db.sqlite3
+0
-0
__init__.py
widget_robo_mommy/Assignments/__init__.py
+0
-0
admin.py
widget_robo_mommy/Assignments/admin.py
+11
-0
apps.py
widget_robo_mommy/Assignments/apps.py
+6
-0
0001_initial.py
widget_robo_mommy/Assignments/migrations/0001_initial.py
+34
-0
0002_alter_assignment_course.py
...my/Assignments/migrations/0002_alter_assignment_course.py
+19
-0
__init__.py
widget_robo_mommy/Assignments/migrations/__init__.py
+0
-0
models.py
widget_robo_mommy/Assignments/models.py
+17
-0
tests.py
widget_robo_mommy/Assignments/tests.py
+3
-0
urls.py
widget_robo_mommy/Assignments/urls.py
+8
-0
views.py
widget_robo_mommy/Assignments/views.py
+20
-0
__init__.py
widget_robo_mommy/Dashboard/__init__.py
+0
-0
admin.py
widget_robo_mommy/Dashboard/admin.py
+19
-0
apps.py
widget_robo_mommy/Dashboard/apps.py
+6
-0
0001_initial.py
widget_robo_mommy/Dashboard/migrations/0001_initial.py
+22
-0
0002_widgetuser.py
widget_robo_mommy/Dashboard/migrations/0002_widgetuser.py
+24
-0
__init__.py
widget_robo_mommy/Dashboard/migrations/__init__.py
+0
-0
models.py
widget_robo_mommy/Dashboard/models.py
+13
-0
tests.py
widget_robo_mommy/Dashboard/tests.py
+3
-0
urls.py
widget_robo_mommy/Dashboard/urls.py
+8
-0
views.py
widget_robo_mommy/Dashboard/views.py
+20
-0
__init__.py
widget_robo_mommy/announcements/__init__.py
+0
-0
admin.py
widget_robo_mommy/announcements/admin.py
+12
-0
apps.py
widget_robo_mommy/announcements/apps.py
+6
-0
0001_initial.py
widget_robo_mommy/announcements/migrations/0001_initial.py
+35
-0
__init__.py
widget_robo_mommy/announcements/migrations/__init__.py
+0
-0
models.py
widget_robo_mommy/announcements/models.py
+24
-0
tests.py
widget_robo_mommy/announcements/tests.py
+3
-0
urls.py
widget_robo_mommy/announcements/urls.py
+8
-0
views.py
widget_robo_mommy/announcements/views.py
+33
-0
__init__.py
widget_robo_mommy/forum/__init__.py
+0
-0
admin.py
widget_robo_mommy/forum/admin.py
+6
-0
apps.py
widget_robo_mommy/forum/apps.py
+6
-0
0001_initial.py
widget_robo_mommy/forum/migrations/0001_initial.py
+56
-0
0002_auto_20230304_2337.py
...et_robo_mommy/forum/migrations/0002_auto_20230304_2337.py
+29
-0
__init__.py
widget_robo_mommy/forum/migrations/__init__.py
+0
-0
models.py
widget_robo_mommy/forum/models.py
+17
-0
tests.py
widget_robo_mommy/forum/tests.py
+3
-0
urls.py
widget_robo_mommy/forum/urls.py
+6
-0
views.py
widget_robo_mommy/forum/views.py
+36
-0
settings.py
widget_robo_mommy/widget_robo_mommy/settings.py
+12
-1
urls.py
widget_robo_mommy/widget_robo_mommy/urls.py
+4
-0
No files found.
widget_robo_mommy
/db.sqlite3
→
.idea/shelf/Uncommitted_changes_before_rebase_[Changes]
/db.sqlite3
View file @
8b8c9045
No preview for this file type
widget_robo_mommy/Assignments/__init__.py
0 → 100644
View file @
8b8c9045
widget_robo_mommy/Assignments/admin.py
0 → 100644
View file @
8b8c9045
from
django.contrib
import
admin
from
.models
import
Assignment
,
Course
class
AssignmentAdmin
(
admin
.
ModelAdmin
):
model
=
Assignment
class
CourseAdmin
(
admin
.
ModelAdmin
):
model
=
Course
admin
.
site
.
register
(
Assignment
,
AssignmentAdmin
)
admin
.
site
.
register
(
Course
,
CourseAdmin
)
\ No newline at end of file
widget_robo_mommy/Assignments/apps.py
0 → 100644
View file @
8b8c9045
from
django.apps
import
AppConfig
class
AssignmentsConfig
(
AppConfig
):
default_auto_field
=
'django.db.models.BigAutoField'
name
=
'Assignments'
widget_robo_mommy/Assignments/migrations/0001_initial.py
0 → 100644
View file @
8b8c9045
# Generated by Django 4.1.7 on 2023-03-04 17:11
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Assignment'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name'
,
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
null
=
True
)),
(
'description'
,
models
.
TextField
(
blank
=
True
,
null
=
True
)),
(
'course'
,
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
null
=
True
)),
(
'perfect_score'
,
models
.
IntegerField
(
blank
=
True
,
null
=
True
)),
(
'passing_score'
,
models
.
IntegerField
(
blank
=
True
,
null
=
True
)),
],
),
migrations
.
CreateModel
(
name
=
'Course'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'code'
,
models
.
CharField
(
blank
=
True
,
max_length
=
10
,
null
=
True
)),
(
'title'
,
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
null
=
True
)),
(
'section'
,
models
.
CharField
(
blank
=
True
,
max_length
=
3
,
null
=
True
)),
],
),
]
widget_robo_mommy/Assignments/migrations/0002_alter_assignment_course.py
0 → 100644
View file @
8b8c9045
# Generated by Django 4.1.7 on 2023-03-04 17:27
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'Assignments'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'assignment'
,
name
=
'course'
,
field
=
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'Assignments.course'
),
),
]
widget_robo_mommy/Assignments/migrations/__init__.py
0 → 100644
View file @
8b8c9045
widget_robo_mommy/Assignments/models.py
0 → 100644
View file @
8b8c9045
from
django.db
import
models
class
Course
(
models
.
Model
):
code
=
models
.
CharField
(
max_length
=
10
,
blank
=
True
,
null
=
True
)
title
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
null
=
True
)
section
=
models
.
CharField
(
max_length
=
3
,
blank
=
True
,
null
=
True
)
class
Assignment
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
null
=
True
)
description
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
course
=
models
.
ForeignKey
(
Course
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
perfect_score
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
passing_score
=
models
.
IntegerField
(
blank
=
True
,
null
=
True
)
def
save
(
self
,
*
args
,
**
kwargs
):
self
.
passing_score
=
int
(
self
.
perfect_score
*
0.60
)
super
(
Assignment
,
self
)
.
save
(
*
args
,
**
kwargs
)
widget_robo_mommy/Assignments/tests.py
0 → 100644
View file @
8b8c9045
from
django.test
import
TestCase
# Create your tests here.
widget_robo_mommy/Assignments/urls.py
0 → 100644
View file @
8b8c9045
from
django.urls
import
path
from
.views
import
index
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
]
app_name
=
"Assignments"
widget_robo_mommy/Assignments/views.py
0 → 100644
View file @
8b8c9045
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
Assignment
,
Course
import
os
def
index
(
request
):
output
=
f
"Widget's Assignments Page<br><br>"
count
=
Assignment
.
objects
.
all
()
.
count
()
for
i
in
range
(
1
,
count
+
1
):
assignments
=
Assignment
.
objects
.
get
(
id
=
i
)
output
+=
f
"""Assignment Name: {assignments.name}<br>
Description: {assignments.description}<br>
Perfect Score: {assignments.perfect_score}<br>
Passing Score: {assignments.passing_score}<br>
Course/Section: {assignments.course.code} {assignments.course.title}-{assignments.course.section}<br>
<br>"""
return
HttpResponse
(
output
)
widget_robo_mommy/Dashboard/__init__.py
0 → 100644
View file @
8b8c9045
widget_robo_mommy/Dashboard/admin.py
0 → 100644
View file @
8b8c9045
from
django.contrib
import
admin
from
.models
import
Department
,
WidgetUser
class
DepartmentAdmin
(
admin
.
ModelAdmin
):
model
=
Department
list_display
=
(
'dept_name'
,
'home_unit'
)
search_fields
=
(
'dept_name'
,
'home_unit'
)
class
WidgetUserAdmin
(
admin
.
ModelAdmin
):
model
=
WidgetUser
admin
.
site
.
register
(
Department
,
DepartmentAdmin
)
admin
.
site
.
register
(
WidgetUser
,
WidgetUserAdmin
)
widget_robo_mommy/Dashboard/apps.py
0 → 100644
View file @
8b8c9045
from
django.apps
import
AppConfig
class
DashboardConfig
(
AppConfig
):
default_auto_field
=
'django.db.models.BigAutoField'
name
=
'Dashboard'
widget_robo_mommy/Dashboard/migrations/0001_initial.py
0 → 100644
View file @
8b8c9045
# Generated by Django 4.1.6 on 2023-03-03 15:37
from
django.db
import
migrations
,
models
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Department'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'dept_name'
,
models
.
CharField
(
max_length
=
50
)),
(
'home_unit'
,
models
.
CharField
(
max_length
=
100
)),
],
),
]
widget_robo_mommy/Dashboard/migrations/0002_widgetuser.py
0 → 100644
View file @
8b8c9045
# Generated by Django 4.1.6 on 2023-03-04 16:34
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'Dashboard'
,
'0001_initial'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'WidgetUser'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'first_name'
,
models
.
CharField
(
max_length
=
50
)),
(
'middle_name'
,
models
.
CharField
(
max_length
=
50
)),
(
'last_name'
,
models
.
CharField
(
max_length
=
50
)),
(
'department'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'Dashboard.department'
)),
],
),
]
widget_robo_mommy/Dashboard/migrations/__init__.py
0 → 100644
View file @
8b8c9045
widget_robo_mommy/Dashboard/models.py
0 → 100644
View file @
8b8c9045
from
django.db
import
models
class
Department
(
models
.
Model
):
dept_name
=
models
.
CharField
(
max_length
=
50
)
home_unit
=
models
.
CharField
(
max_length
=
100
)
class
WidgetUser
(
models
.
Model
):
first_name
=
models
.
CharField
(
max_length
=
50
)
middle_name
=
models
.
CharField
(
max_length
=
50
)
last_name
=
models
.
CharField
(
max_length
=
50
)
department
=
models
.
ForeignKey
(
Department
,
on_delete
=
models
.
CASCADE
)
\ No newline at end of file
widget_robo_mommy/Dashboard/tests.py
0 → 100644
View file @
8b8c9045
from
django.test
import
TestCase
# Create your tests here.
widget_robo_mommy/Dashboard/urls.py
0 → 100644
View file @
8b8c9045
from
django.urls
import
path
from
.views
import
Dashboard_list_view
urlpatterns
=
[
path
(
''
,
Dashboard_list_view
,
name
=
'Dashboard_list_view'
),
]
app_name
=
"Dashboard"
\ No newline at end of file
widget_robo_mommy/Dashboard/views.py
0 → 100644
View file @
8b8c9045
from
.models
import
WidgetUser
,
Department
from
django.http
import
HttpResponse
from
django.shortcuts
import
render
def
Dashboard_list_view
(
request
):
html_string_1
=
'<html lang="en"><head><meta charset="UTF-8">'
\
'<h1>Welcome to Widget</h1>'
\
'<h2>WIDGET USERS</h2></head><ul>'
html_string_2
=
''
for
wu
in
WidgetUser
.
objects
.
all
():
html_string_2
+=
'<li>{}, {} {}: {}, {}'
.
format
(
wu
.
last_name
,
wu
.
first_name
,
wu
.
middle_name
,
wu
.
department
.
dept_name
,
wu
.
department
.
home_unit
)
html_string_2
+=
'</ul></li>'
html_string_final
=
html_string_1
+
html_string_2
+
'</html>'
return
HttpResponse
(
html_string_final
)
widget_robo_mommy/announcements/__init__.py
0 → 100644
View file @
8b8c9045
widget_robo_mommy/announcements/admin.py
0 → 100644
View file @
8b8c9045
from
django.contrib
import
admin
from
.models
import
Announcement
,
Reaction
class
AnnouncementAdmin
(
admin
.
ModelAdmin
):
model
=
Announcement
class
ReactionAdmin
(
admin
.
ModelAdmin
):
model
=
Reaction
# Register your models here.
admin
.
site
.
register
(
Announcement
,
AnnouncementAdmin
)
admin
.
site
.
register
(
Reaction
,
ReactionAdmin
)
\ No newline at end of file
widget_robo_mommy/announcements/apps.py
0 → 100644
View file @
8b8c9045
from
django.apps
import
AppConfig
class
AnnouncementsConfig
(
AppConfig
):
default_auto_field
=
'django.db.models.BigAutoField'
name
=
'announcements'
widget_robo_mommy/announcements/migrations/0001_initial.py
0 → 100644
View file @
8b8c9045
# Generated by Django 4.1.7 on 2023-03-05 14:21
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
(
'Dashboard'
,
'0002_widgetuser'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Announcement'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'title'
,
models
.
TextField
(
blank
=
True
,
null
=
True
)),
(
'body'
,
models
.
TextField
(
blank
=
True
,
null
=
True
)),
(
'pub_datetime'
,
models
.
DateTimeField
(
null
=
True
)),
(
'author'
,
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'Dashboard.widgetuser'
)),
],
),
migrations
.
CreateModel
(
name
=
'Reaction'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name'
,
models
.
CharField
(
blank
=
True
,
default
=
'Like'
,
max_length
=
5
,
null
=
True
)),
(
'tally'
,
models
.
IntegerField
(
blank
=
True
,
default
=
0
,
null
=
True
)),
(
'announcement'
,
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'announcements.announcement'
)),
],
),
]
widget_robo_mommy/announcements/migrations/__init__.py
0 → 100644
View file @
8b8c9045
widget_robo_mommy/announcements/models.py
0 → 100644
View file @
8b8c9045
from
django.db
import
models
from
Dashboard.models
import
WidgetUser
class
Announcement
(
models
.
Model
):
title
=
models
.
TextField
(
null
=
True
,
blank
=
True
)
body
=
models
.
TextField
(
null
=
True
,
blank
=
True
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
pub_datetime
=
models
.
DateTimeField
(
null
=
True
)
class
Reaction
(
models
.
Model
):
LIKE
=
'Like'
LOVE
=
'Love'
ANGRY
=
'Angry'
REACTION_CHOICES
=
[
(
LIKE
,
'Like'
),
(
LOVE
,
'Love'
),
(
ANGRY
,
'Angry'
),
]
name
=
models
.
CharField
(
max_length
=
5
,
default
=
LIKE
,
null
=
True
,
blank
=
True
)
tally
=
models
.
IntegerField
(
default
=
0
,
null
=
True
,
blank
=
True
)
announcement
=
models
.
ForeignKey
(
Announcement
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
# Create your models here.
widget_robo_mommy/announcements/tests.py
0 → 100644
View file @
8b8c9045
from
django.test
import
TestCase
# Create your tests here.
widget_robo_mommy/announcements/urls.py
0 → 100644
View file @
8b8c9045
from
django.urls
import
path
from
.views
import
index
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
]
app_name
=
"announcements"
\ No newline at end of file
widget_robo_mommy/announcements/views.py
0 → 100644
View file @
8b8c9045
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
Announcement
,
Reaction
import
pytz
from
django.utils
import
timezone
def
convert_to_localtime
(
utctime
):
format
=
'
%
d/
%
m/
%
Y
%
H:
%
M'
utc
=
utctime
.
replace
(
tzinfo
=
pytz
.
UTC
)
localtz
=
utc
.
astimezone
(
timezone
.
get_current_timezone
())
return
localtz
.
strftime
(
format
)
def
index
(
request
):
html_string_1
=
'<html lang="en"><head><meta charset="UTF-8"></head>
\
<b><h1>Widget
\'
s Announcement Board</h1></b>
\
<h2>Announcements:</h2><br/>'
html_string_2
=
""
for
announced
in
Announcement
.
objects
.
all
():
html_string_2
+=
"{} by {} {} published {}<br />:
\
{}"
.
format
(
announced
.
title
,
announced
.
author
.
first_name
,
announced
.
author
.
last_name
,
convert_to_localtime
(
announced
.
pub_datetime
),
announced
.
body
)
for
reacts
in
announced
.
reaction
.
all
():
html_string_2
+=
"{}: {}"
.
format
(
reacts
.
name
,
reacts
.
tally
)
html_string_final
=
html_string_1
+
html_string_2
+
"</html>"
return
HttpResponse
(
html_string_final
)
# Create your views here.
widget_robo_mommy/forum/__init__.py
0 → 100644
View file @
8b8c9045
widget_robo_mommy/forum/admin.py
0 → 100644
View file @
8b8c9045
from
django.contrib
import
admin
from
.models
import
ForumPost
,
Reply
# Register your models here.
admin
.
site
.
register
(
ForumPost
)
admin
.
site
.
register
(
Reply
)
widget_robo_mommy/forum/apps.py
0 → 100644
View file @
8b8c9045
from
django.apps
import
AppConfig
class
ForumConfig
(
AppConfig
):
default_auto_field
=
'django.db.models.BigAutoField'
name
=
'forum'
widget_robo_mommy/forum/migrations/0001_initial.py
0 → 100644
View file @
8b8c9045
# Generated by Django 3.2 on 2023-03-04 13:35
import
django.contrib.auth.models
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
(
'auth'
,
'0012_alter_user_first_name_max_length'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'ForumPost'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'title'
,
models
.
CharField
(
blank
=
True
,
max_length
=
255
,
null
=
True
)),
(
'body'
,
models
.
TextField
(
blank
=
True
,
null
=
True
)),
(
'pub_datetime'
,
models
.
DateTimeField
(
auto_now_add
=
True
)),
],
),
migrations
.
CreateModel
(
name
=
'WidgetUser'
,
fields
=
[
(
'user_ptr'
,
models
.
OneToOneField
(
auto_created
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
parent_link
=
True
,
primary_key
=
True
,
serialize
=
False
,
to
=
'auth.user'
)),
],
options
=
{
'verbose_name'
:
'user'
,
'verbose_name_plural'
:
'users'
,
'abstract'
:
False
,
},
bases
=
(
'auth.user'
,),
managers
=
[
(
'objects'
,
django
.
contrib
.
auth
.
models
.
UserManager
()),
],
),
migrations
.
CreateModel
(
name
=
'Reply'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'body'
,
models
.
TextField
(
blank
=
True
,
null
=
True
)),
(
'pub_datetime'
,
models
.
DateTimeField
(
auto_now_add
=
True
)),
(
'author'
,
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'forum.widgetuser'
)),
(
'forumpost'
,
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'reply'
,
to
=
'forum.forumpost'
)),
],
),
migrations
.
AddField
(
model_name
=
'forumpost'
,
name
=
'author'
,
field
=
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'forumpost'
,
to
=
'forum.widgetuser'
),
),
]
widget_robo_mommy/forum/migrations/0002_auto_20230304_2337.py
0 → 100644
View file @
8b8c9045
# Generated by Django 3.2 on 2023-03-04 15:37
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'Dashboard'
,
'0002_widgetuser'
),
(
'admin'
,
'0003_logentry_add_action_flag_choices'
),
(
'forum'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'forumpost'
,
name
=
'author'
,
field
=
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'forumpost'
,
to
=
'Dashboard.widgetuser'
),
),
migrations
.
AlterField
(
model_name
=
'reply'
,
name
=
'author'
,
field
=
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'Dashboard.widgetuser'
),
),
migrations
.
DeleteModel
(
name
=
'WidgetUser'
,
),
]
widget_robo_mommy/forum/migrations/__init__.py
0 → 100644
View file @
8b8c9045
widget_robo_mommy/forum/models.py
0 → 100644
View file @
8b8c9045
from
django.db
import
models
from
Dashboard.models
import
WidgetUser
# Create your models here.
class
ForumPost
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
255
,
blank
=
True
,
null
=
True
)
body
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
author
=
models
.
ForeignKey
(
WidgetUser
,
related_name
=
'forumpost'
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
pub_datetime
=
models
.
DateTimeField
(
auto_now_add
=
True
)
class
Reply
(
models
.
Model
):
forumpost
=
models
.
ForeignKey
(
ForumPost
,
related_name
=
'reply'
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
body
=
models
.
TextField
(
blank
=
True
,
null
=
True
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
pub_datetime
=
models
.
DateTimeField
(
auto_now_add
=
True
)
widget_robo_mommy/forum/tests.py
0 → 100644
View file @
8b8c9045
from
django.test
import
TestCase
# Create your tests here.
widget_robo_mommy/forum/urls.py
0 → 100644
View file @
8b8c9045
from
django.urls
import
path
from
.views
import
*
urlpatterns
=
[
path
(
'forum/'
,
forum_post_list_view
,
name
=
'forum_post_list_view'
)
]
widget_robo_mommy/forum/views.py
0 → 100644
View file @
8b8c9045
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
ForumPost
import
pytz
from
django.utils
import
timezone
# helper function to convert utc datetime object to local time
def
convert_utc_to_local
(
utctime
):
datetime_format
=
'
%
d/
%
m/
%
Y
%
H:
%
M'
utc
=
utctime
.
replace
(
tzinfo
=
pytz
.
UTC
)
localtz
=
utc
.
astimezone
(
timezone
.
get_current_timezone
())
return
localtz
.
strftime
(
datetime_format
)
def
forum_post_list_view
(
request
):
html_string_1
=
'<html lang="en"><head><meta charset="UTF-8"><title>Forum Post List</title>'
\
'<h1>Forum Post List</h1></head><ul>'
html_string_2
=
''
for
fp
in
ForumPost
.
objects
.
all
():
html_string_2
+=
'<li><b style="font-size: 30px">{}</b>'
\
' by <b style="font-size: large">{} {}</b>'
\
' posted <b>{}</b><p>{}</p><ul>'
.
format
(
fp
.
title
,
fp
.
author
.
first_name
,
fp
.
author
.
last_name
,
convert_utc_to_local
(
fp
.
pub_datetime
),
fp
.
body
)
for
replies
in
fp
.
reply
.
all
():
html_string_2
+=
'<li> Reply by <b>{} {}</b> '
\
'posted <b>{}</b><p>{}</p></li>'
.
format
(
replies
.
author
.
first_name
,
replies
.
author
.
last_name
,
convert_utc_to_local
(
replies
.
pub_datetime
),
replies
.
body
)
html_string_2
+=
'</ul></li>'
html_string_final
=
html_string_1
+
html_string_2
+
'</ul></html>'
return
HttpResponse
(
html_string_final
)
widget_robo_mommy/widget_robo_mommy/settings.py
View file @
8b8c9045
...
...
@@ -11,6 +11,12 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
"""
from
pathlib
import
Path
from
dotenv
import
load_dotenv
import
os
DIRNAME
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
load_dotenv
()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR
=
Path
(
__file__
)
.
resolve
()
.
parent
.
parent
...
...
@@ -31,6 +37,10 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS
=
[
'announcements'
,
'Assignments'
,
'forum.apps.ForumConfig'
,
'Dashboard.apps.DashboardConfig'
,
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
...
...
@@ -38,6 +48,7 @@ INSTALLED_APPS = [
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'widget_Calendar'
,
'tz_detect'
,
]
MIDDLEWARE
=
[
...
...
@@ -106,7 +117,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE
=
'en-us'
TIME_ZONE
=
'
UTC
'
TIME_ZONE
=
'
Asia/Hong_Kong
'
USE_I18N
=
True
...
...
widget_robo_mommy/widget_robo_mommy/urls.py
View file @
8b8c9045
...
...
@@ -18,6 +18,10 @@ from django.urls import include, path
urlpatterns
=
[
path
(
'announcements/'
,
include
(
'announcements.urls'
,
namespace
=
"announcements"
)),
path
(
'widget_Calendar/'
,
include
(
'widget_Calendar.urls'
,
namespace
=
"widget_Calendar"
)),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'Assignments/'
,
include
(
'Assignments.urls'
,
namespace
=
"Assignments"
)),
path
(
''
,
include
((
'forum.urls'
,
'forum'
),
namespace
=
'forum'
)),
path
(
'Dashboard/'
,
include
(
'Dashboard.urls'
,
namespace
=
"Dashboard"
)),
]
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