Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_nicsbabes
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
Nics De Vega
midterm_nicsbabes
Commits
586a30f2
Commit
586a30f2
authored
May 10, 2023
by
Nics De Vega
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified app models and templates
parent
da2041a0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
67 additions
and
5 deletions
+67
-5
models.py
widget_nicsbabes/announcement_board/models.py
+15
-1
announcement-add.html
..._board/templates/announcement_board/announcement-add.html
+9
-1
announcement-details.html
...rd/templates/announcement_board/announcement-details.html
+13
-1
announcement-edit.html
...board/templates/announcement_board/announcement-edit.html
+10
-1
announcements.html
...ent_board/templates/announcement_board/announcements.html
+20
-1
No files found.
widget_nicsbabes/announcement_board/models.py
View file @
586a30f2
from
django.db
import
models
from
dashboard.models
import
WidgetUser
from
django.urls
import
reverse
from
django.utils
import
timezone
class
Announcement
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
,
default
=
""
)
body
=
models
.
TextField
(
default
=
""
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
pub_datetime
=
models
.
DateTimeField
()
pub_datetime
=
models
.
DateTimeField
(
default
=
timezone
.
now
)
def
__str__
(
self
):
return
'{} by {}'
.
format
(
self
.
title
,
self
.
author
)
def
get_absolute_url
(
self
):
return
reverse
(
"announcement_board:announcement-details"
,
kwargs
=
{
'pk'
:
self
.
pk
})
def
get_reactions
(
self
):
reacts
=
{
'Like'
:
0
,
'Love'
:
0
,
'Angry'
:
0
}
for
key
in
reacts
.
keys
():
try
:
reacts
[
key
]
=
Reaction
.
objects
.
get
(
announcement
=
self
,
name
=
key
)
.
tally
except
:
reacts
[
key
]
=
0
return
reacts
class
Reaction
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
20
,
default
=
""
)
...
...
widget_nicsbabes/announcement_board/templates/announcement_board/announcement-add.html
View file @
586a30f2
{% extends 'base.html' %}
{% load static %}
{% block title %}{% endblock %}
{% block title %}
Add Announcement
{% endblock %}
{% block content %}
<h2>
Add a new Announcement
</h2>
<form
method=
"post"
>
{% csrf_token %}
{% for field in form %}
<h3>
{{field.label}}: {{field}}
<br><br></h3>
{% endfor %}
<input
type=
"submit"
value=
"Add Announcement"
>
</form>
{% endblock %}
widget_nicsbabes/announcement_board/templates/announcement_board/announcement-details.html
View file @
586a30f2
{% extends 'base.html' %}
{% load static %}
{% block title %}{% endblock %}
{% block title %}{
{object.title}}{
% endblock %}
{% block content %}
<h2>
{{object.title}}
</h2>
<ul>
<li><h3>
by {{object.author.first_name}} {{object.author.last_name}}
</h3></li>
<li><h3>
{{object.pub_datetime|date:'m/d/Y h:i A'}}
</h3></li>
<li><h3>
{{object.body}}
</h4></li>
{%for key, value in object.get_reactions.items%}
<li><h3>
{{key}}: {{value}}
</h3></li>
{% endfor%}
<h3><a
href=
"../edit/"
>
Edit Announcement
</a></h3>
</ul>
{% endblock %}
widget_nicsbabes/announcement_board/templates/announcement_board/announcement-edit.html
View file @
586a30f2
{% extends 'base.html' %}
{% load static %}
{% block title %}{% endblock %}
{% block title %}
Edit Announcement
{% endblock %}
{% block content %}
<h2>
Edit Announcement
</h2>
<form
method=
"post"
>
{% csrf_token %}
{% for field in form %}
<h3>
{{field.label}}: {{field}}
<br><br></h3>
{% endfor %}
<input
type=
"submit"
value=
"Save Changes to Announcement"
>
</form>
{% endblock %}
widget_nicsbabes/announcement_board/templates/announcement_board/announcements.html
View file @
586a30f2
{% extends 'base.html' %}
{% load static %}
{% block title %}{% endblock %}
{% block title %}
Widget's Announcement Board
{% endblock %}
{% block content %}
<h2>
Welcome to Widget's Announcement Board!
</h2>
<br>
{% for object in announcements %}
<h3><a
href=
"{{ object.get_absolute_url }}"
>
{{object.title}} by {{object.author.first_name}} {{object.author.last_name}}
</a></h3>
{% endfor %}
<br>
<h3><a
href=
"add/"
>
Add Announcement
</a></h3>
<br>
<h2>
<small>
<a
href=
"../dashboard/"
>
Dashboard
</a><br>
<a
href=
"../forum/"
>
Forum
</a><br>
<a
href=
"../assignments/"
>
Assignments
</a><br>
<a
href=
"../calendar/"
>
Calendar
</a><br>
</small>
</h2>
{% endblock %}
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