Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_bigdjangoenergy
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
Alec Dayupay
midterm_bigdjangoenergy
Commits
de9e295a
Commit
de9e295a
authored
Mar 02, 2023
by
Anthony Bicomong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added announcements app
parent
824b9b44
Changes
13
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
100 additions
and
3 deletions
+100
-3
__init__.cpython-311.pyc
...energy/announcements/__pycache__/__init__.cpython-311.pyc
+0
-0
admin.cpython-311.pyc
...ngoenergy/announcements/__pycache__/admin.cpython-311.pyc
+0
-0
apps.cpython-311.pyc
...angoenergy/announcements/__pycache__/apps.cpython-311.pyc
+0
-0
models.cpython-311.pyc
...goenergy/announcements/__pycache__/models.cpython-311.pyc
+0
-0
urls.cpython-311.pyc
...angoenergy/announcements/__pycache__/urls.cpython-311.pyc
+0
-0
views.cpython-311.pyc
...ngoenergy/announcements/__pycache__/views.cpython-311.pyc
+0
-0
admin.py
widget_bigdjangoenergy/announcements/admin.py
+22
-1
0001_initial.py
..._bigdjangoenergy/announcements/migrations/0001_initial.py
+34
-0
0001_initial.cpython-311.pyc
...ments/migrations/__pycache__/0001_initial.cpython-311.pyc
+0
-0
__init__.cpython-311.pyc
...uncements/migrations/__pycache__/__init__.cpython-311.pyc
+0
-0
models.py
widget_bigdjangoenergy/announcements/models.py
+18
-1
urls.py
widget_bigdjangoenergy/announcements/urls.py
+8
-0
views.py
widget_bigdjangoenergy/announcements/views.py
+18
-1
No files found.
widget_bigdjangoenergy/announcements/__pycache__/__init__.cpython-311.pyc
0 → 100644
View file @
de9e295a
File added
widget_bigdjangoenergy/announcements/__pycache__/admin.cpython-311.pyc
0 → 100644
View file @
de9e295a
File added
widget_bigdjangoenergy/announcements/__pycache__/apps.cpython-311.pyc
0 → 100644
View file @
de9e295a
File added
widget_bigdjangoenergy/announcements/__pycache__/models.cpython-311.pyc
0 → 100644
View file @
de9e295a
File added
widget_bigdjangoenergy/announcements/__pycache__/urls.cpython-311.pyc
0 → 100644
View file @
de9e295a
File added
widget_bigdjangoenergy/announcements/__pycache__/views.cpython-311.pyc
0 → 100644
View file @
de9e295a
File added
widget_bigdjangoenergy/announcements/admin.py
View file @
de9e295a
from
django.contrib
import
admin
# Register your models here.
from
.models
import
Announcement
,
Reaction
class
AnnouncementAdmin
(
admin
.
ModelAdmin
):
model
=
Announcement
list_display
=
(
'title'
,
'body'
,
'author'
,
'pub_datetime'
)
search_fields
=
(
'title'
,
'body'
,
'author'
,
'pub_datetime'
)
list_filter
=
(
'title'
,
'body'
,
'author'
,
'pub_datetime'
)
class
AnnonuncementInline
(
admin
.
TabularInline
):
model
=
Announcement
class
ReactionAdmin
(
admin
.
ModelAdmin
):
model
=
Reaction
list_display
=
(
'name'
,
'tally'
,
'announcement'
)
search_fields
=
(
'name'
,
'tally'
,
'announcement'
)
list_filter
=
(
'name'
,
'tally'
,
'announcement'
)
class
ReactionInline
(
admin
.
TabularInline
):
model
=
Reaction
admin
.
site
.
register
(
Announcement
,
AnnouncementAdmin
)
admin
.
site
.
register
(
Reaction
,
ReactionAdmin
)
\ No newline at end of file
widget_bigdjangoenergy/announcements/migrations/0001_initial.py
0 → 100644
View file @
de9e295a
# Generated by Django 3.2 on 2023-03-02 06:17
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
initial
=
True
dependencies
=
[
]
operations
=
[
migrations
.
CreateModel
(
name
=
'Announcement'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'title'
,
models
.
CharField
(
max_length
=
50
)),
(
'body'
,
models
.
CharField
(
max_length
=
700
)),
(
'author'
,
models
.
CharField
(
max_length
=
200
)),
(
'pub_datetime'
,
models
.
DateTimeField
()),
],
),
migrations
.
CreateModel
(
name
=
'Reaction'
,
fields
=
[
(
'id'
,
models
.
BigAutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'name'
,
models
.
CharField
(
max_length
=
50
)),
(
'tally'
,
models
.
IntegerField
()),
(
'announcement'
,
models
.
ForeignKey
(
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
to
=
'announcements.announcement'
)),
],
),
]
widget_bigdjangoenergy/announcements/migrations/__pycache__/0001_initial.cpython-311.pyc
0 → 100644
View file @
de9e295a
File added
widget_bigdjangoenergy/announcements/migrations/__pycache__/__init__.cpython-311.pyc
0 → 100644
View file @
de9e295a
File added
widget_bigdjangoenergy/announcements/models.py
View file @
de9e295a
from
django.db
import
models
from
django.urls
import
reverse
# Create your models here.
class
Announcement
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
50
)
body
=
models
.
CharField
(
max_length
=
700
)
#author = models.ForeignKey("dashboard.WidgetUser", on_delete=models.CASCADE)
author
=
models
.
CharField
(
max_length
=
200
)
pub_datetime
=
models
.
DateTimeField
()
def
__str__
(
self
):
return
self
.
title
class
Reaction
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
50
)
tally
=
models
.
IntegerField
()
announcement
=
models
.
ForeignKey
(
Announcement
,
on_delete
=
models
.
CASCADE
)
def
__str__
(
self
):
return
self
.
name
\ No newline at end of file
widget_bigdjangoenergy/announcements/urls.py
0 → 100644
View file @
de9e295a
from
django.urls
import
path
from
.views
import
index
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
]
app_name
=
"announcements"
widget_bigdjangoenergy/announcements/views.py
View file @
de9e295a
from
django.shortcuts
import
render
from
django.http
import
HttpResponse
from
.models
import
Announcement
,
Reaction
def
index
(
request
):
all_announcements
=
Announcement
.
objects
.
all
()
all_reactions
=
Reaction
.
objects
.
all
()
response
=
"Big Django Energy - Announcement Board<br><br>Announcements:<br>"
for
announcement
in
all_announcements
:
announcementpubdate
=
announcement
.
pub_datetime
.
strftime
(
"
%
m/
%
d/
%
Y,
%
H:
%
M:
%
S"
)
+
", "
#TO_DO: fix timezone
response
=
response
+
announcement
.
title
+
" by "
+
announcement
.
author
.
first_name
+
" "
+
announcement
.
author
.
last_name
#TO_DO: widgetUser functionality (parsing author info)
response
=
response
+
" published "
+
announcementpubdate
+
"<br>"
response
=
response
+
announcement
.
body
+
"<br>"
for
reaction
in
all_reactions
:
if
reaction
.
announcement
==
announcement
:
response
=
response
+
reaction
.
name
+
": "
+
str
(
reaction
.
tally
)
+
"<br>"
response
=
response
+
"<br>"
return
HttpResponse
(
response
)
# Create your views here.
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