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
261cfc17
Commit
261cfc17
authored
Mar 05, 2023
by
RJC
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit untracked files
parent
9b6930eb
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
126 additions
and
0 deletions
+126
-0
db.sqlite3
...lf/Uncommitted_changes_before_rebase_[Changes]/db.sqlite3
+0
-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
settings.py
widget_robo_mommy/widget_robo_mommy/settings.py
+3
-0
urls.py
widget_robo_mommy/widget_robo_mommy/urls.py
+2
-0
No files found.
.idea/shelf/Uncommitted_changes_before_rebase_[Changes]/db.sqlite3
0 → 100644
View file @
261cfc17
File added
widget_robo_mommy/announcements/__init__.py
0 → 100644
View file @
261cfc17
widget_robo_mommy/announcements/admin.py
0 → 100644
View file @
261cfc17
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 @
261cfc17
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 @
261cfc17
# 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 @
261cfc17
widget_robo_mommy/announcements/models.py
0 → 100644
View file @
261cfc17
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 @
261cfc17
from
django.test
import
TestCase
# Create your tests here.
widget_robo_mommy/announcements/urls.py
0 → 100644
View file @
261cfc17
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 @
261cfc17
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/widget_robo_mommy/settings.py
View file @
261cfc17
...
@@ -13,9 +13,11 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
...
@@ -13,9 +13,11 @@ https://docs.djangoproject.com/en/3.2/ref/settings/
from
pathlib
import
Path
from
pathlib
import
Path
from
dotenv
import
load_dotenv
from
dotenv
import
load_dotenv
import
os
import
os
DIRNAME
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
DIRNAME
=
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
))
load_dotenv
()
load_dotenv
()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR
=
Path
(
__file__
)
.
resolve
()
.
parent
.
parent
BASE_DIR
=
Path
(
__file__
)
.
resolve
()
.
parent
.
parent
...
@@ -35,6 +37,7 @@ ALLOWED_HOSTS = []
...
@@ -35,6 +37,7 @@ ALLOWED_HOSTS = []
# Application definition
# Application definition
INSTALLED_APPS
=
[
INSTALLED_APPS
=
[
'announcements'
,
'Assignments'
,
'Assignments'
,
'forum.apps.ForumConfig'
,
'forum.apps.ForumConfig'
,
'Dashboard.apps.DashboardConfig'
,
'Dashboard.apps.DashboardConfig'
,
...
...
widget_robo_mommy/widget_robo_mommy/urls.py
View file @
261cfc17
...
@@ -14,9 +14,11 @@ Including another URLconf
...
@@ -14,9 +14,11 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
"""
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django.urls
import
include
,
path
from
django.urls
import
path
,
include
from
django.urls
import
path
,
include
urlpatterns
=
[
urlpatterns
=
[
path
(
'announcements/'
,
include
(
'announcements.urls'
,
namespace
=
"announcements"
)),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'Assignments/'
,
include
(
'Assignments.urls'
,
namespace
=
"Assignments"
)),
path
(
'Assignments/'
,
include
(
'Assignments.urls'
,
namespace
=
"Assignments"
)),
path
(
''
,
include
((
'forum.urls'
,
'forum'
),
namespace
=
'forum'
)),
path
(
''
,
include
((
'forum.urls'
,
'forum'
),
namespace
=
'forum'
)),
...
...
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