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
54904acd
Commit
54904acd
authored
Mar 05, 2023
by
RJC
Browse files
Options
Browse Files
Download
Plain Diff
pulled changes from dev branch
parents
e49dd566
285a1f83
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
290 additions
and
5 deletions
+290
-5
__init__.py
widget_robo_mommy/Dashboard/__init__.py
+0
-0
admin.py
widget_robo_mommy/Dashboard/admin.py
+14
-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
+31
-0
__init__.py
widget_robo_mommy/Dashboard/migrations/__init__.py
+0
-0
models.py
widget_robo_mommy/Dashboard/models.py
+10
-0
Dashboard.html
...t_robo_mommy/Dashboard/templates/Dashboard/Dashboard.html
+19
-0
tests.py
widget_robo_mommy/Dashboard/tests.py
+3
-0
urls.py
widget_robo_mommy/Dashboard/urls.py
+9
-0
views.py
widget_robo_mommy/Dashboard/views.py
+7
-0
__init__.py
widget_robo_mommy/forum/__init__.py
+0
-0
admin.py
widget_robo_mommy/forum/admin.py
+7
-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
+6
-3
urls.py
widget_robo_mommy/widget_robo_mommy/urls.py
+3
-2
No files found.
widget_robo_mommy/Dashboard/__init__.py
0 → 100644
View file @
54904acd
widget_robo_mommy/Dashboard/admin.py
0 → 100644
View file @
54904acd
from
django.contrib
import
admin
from
.models
import
Department
class
DepartmentAdmin
(
admin
.
ModelAdmin
):
model
=
Department
list_display
=
(
'dept_name'
,
'home_unit'
)
search_fields
=
(
'dept_name'
,
'home_unit'
)
admin
.
site
.
register
(
Department
,
DepartmentAdmin
)
widget_robo_mommy/Dashboard/apps.py
0 → 100644
View file @
54904acd
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 @
54904acd
# 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 @
54904acd
# Generated by Django 3.2 on 2023-03-04 15:37
import
django.contrib.auth.models
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'auth'
,
'0012_alter_user_first_name_max_length'
),
(
'Dashboard'
,
'0001_initial'
),
]
operations
=
[
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
()),
],
),
]
widget_robo_mommy/Dashboard/migrations/__init__.py
0 → 100644
View file @
54904acd
widget_robo_mommy/Dashboard/models.py
0 → 100644
View file @
54904acd
from
django.db
import
models
from
django.contrib.auth.models
import
User
class
Department
(
models
.
Model
):
dept_name
=
models
.
CharField
(
max_length
=
50
)
home_unit
=
models
.
CharField
(
max_length
=
100
)
class
WidgetUser
(
User
):
pass
widget_robo_mommy/Dashboard/templates/Dashboard/Dashboard.html
0 → 100644
View file @
54904acd
<!DOCTYPE HTML>
<HTML>
<Head>
<h1>
Welcome to Widget!
</h1>
</Head>
<h2>
WIDGET USERS
</h2>
<ul>
{% for Department in object_list %}
<li>
{{Department.dept_name}}, {{Department.home_unit}}
</li>
{% endfor %}
</ul>
</HTML>
widget_robo_mommy/Dashboard/tests.py
0 → 100644
View file @
54904acd
from
django.test
import
TestCase
# Create your tests here.
widget_robo_mommy/Dashboard/urls.py
0 → 100644
View file @
54904acd
from
django.urls
import
path
from
.views
import
DashboardView
urlpatterns
=
[
path
(
''
,
DashboardView
.
as_view
()),
]
app_name
=
"Dashboard"
\ No newline at end of file
widget_robo_mommy/Dashboard/views.py
0 → 100644
View file @
54904acd
from
.models
import
Department
from
django.views
import
generic
class
DashboardView
(
generic
.
ListView
):
model
=
Department
template_name
=
'Dashboard/Dashboard.html'
widget_robo_mommy/forum/__init__.py
0 → 100644
View file @
54904acd
widget_robo_mommy/forum/admin.py
0 → 100644
View file @
54904acd
from
django.contrib
import
admin
from
.models
import
ForumPost
,
Reply
,
WidgetUser
# Register your models here.
admin
.
site
.
register
(
ForumPost
)
admin
.
site
.
register
(
Reply
)
admin
.
site
.
register
(
WidgetUser
)
widget_robo_mommy/forum/apps.py
0 → 100644
View file @
54904acd
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 @
54904acd
# 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 @
54904acd
# 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 @
54904acd
widget_robo_mommy/forum/models.py
0 → 100644
View file @
54904acd
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 @
54904acd
from
django.test
import
TestCase
# Create your tests here.
widget_robo_mommy/forum/urls.py
0 → 100644
View file @
54904acd
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 @
54904acd
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 @
54904acd
...
...
@@ -13,7 +13,7 @@ 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'.
...
...
@@ -24,7 +24,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY
=
os
.
getenv
(
'SECRET_KEY'
)
SECRET_KEY
=
'django-insecure-t*s#_++5=ze
%3
#*ns6vcmt8a5bw6249en-!ek7*#3=p-dkhl_f'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG
=
True
...
...
@@ -36,12 +36,15 @@ ALLOWED_HOSTS = []
INSTALLED_APPS
=
[
'Assignments'
,
'forum.apps.ForumConfig'
,
'Dashboard.apps.DashboardConfig'
,
'django.contrib.admin'
,
'django.contrib.auth'
,
'django.contrib.contenttypes'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'tz_detect'
,
]
MIDDLEWARE
=
[
...
...
@@ -110,7 +113,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 @
54904acd
...
...
@@ -14,10 +14,11 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from
django.contrib
import
admin
from
django.urls
import
path
from
django.conf.urls
import
include
from
django.urls
import
path
,
include
urlpatterns
=
[
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