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
a124dc97
Commit
a124dc97
authored
May 11, 2023
by
Nics De Vega
Browse files
Options
Browse Files
Download
Plain Diff
fixed merge conflicts in announcement_boardv2
parents
163e8db8
2d64e7fb
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
126 additions
and
28 deletions
+126
-28
.gitignore
.gitignore
+2
-1
models.py
widget_nicsbabes/announcement_board/models.py
+15
-1
announcement-add.html
..._board/templates/announcement_board/announcement-add.html
+16
-0
announcement-details.html
...rd/templates/announcement_board/announcement-details.html
+22
-0
announcement-edit.html
...board/templates/announcement_board/announcement-edit.html
+16
-0
announcements.html
...ent_board/templates/announcement_board/announcements.html
+29
-0
urls.py
widget_nicsbabes/announcement_board/urls.py
+7
-2
views.py
widget_nicsbabes/announcement_board/views.py
+18
-23
settings.py
widget_nicsbabes/widget_nicsbabes/settings.py
+1
-1
No files found.
.gitignore
View file @
a124dc97
**/.env
db.sqlite3
.DS_Store
**/**/__pycache__
\ No newline at end of file
**/**/__pycache__/**
**/**/**/__pycache__/**
widget_nicsbabes/announcement_board/models.py
View file @
a124dc97
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
0 → 100644
View file @
a124dc97
{% extends 'base.html' %}
{% load static %}
{% block title %}Add Announcement{% endblock %}
{% block content %}
<h1>
Add a new Announcement
</h1>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Announcement"
>
</form>
{% endblock %}
widget_nicsbabes/announcement_board/templates/announcement_board/announcement-details.html
0 → 100644
View file @
a124dc97
{% extends 'base.html' %}
{% load static %}
{% block title %}{{object.title}}{% endblock %}
{% block content %}
<h1>
{{object.title}}
</h1>
<h3>
by {{object.author.first_name}} {{object.author.last_name}}
</h3>
<h3>
{{object.pub_datetime|date:'m/d/Y, h:i A'}}
</h3>
<h3>
{{object.body}}
</h3>
{%for key, value in object.get_reactions.items%}
<h3>
{{key}}: {{value}}
</h3>
{% endfor%}
<form
action=
"../edit"
>
<input
type=
"submit"
value=
"Edit Announcement"
>
</form>
{% endblock %}
widget_nicsbabes/announcement_board/templates/announcement_board/announcement-edit.html
0 → 100644
View file @
a124dc97
{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Announcement{% endblock %}
{% block content %}
<h1>
Edit Announcement
</h1>
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes to Announcement"
>
</form>
{% endblock %}
widget_nicsbabes/announcement_board/templates/announcement_board/announcements.html
0 → 100644
View file @
a124dc97
{% extends 'base.html' %}
{% load static %}
{% block title %}Widget's Announcement Board{% endblock %}
{% block content %}
<h1>
Welcome to Widget's Announcement Board!
</h1>
<h3>
{% for object in announcements %}
<a
href=
"{{ object.get_absolute_url }}"
>
{{object.title}} by {{object.author.first_name}} {{object.author.last_name}}
</a>
<br>
{% endfor %}
</h3>
<form
action=
"add"
>
<input
type=
"submit"
value=
"Add Announcement"
>
</form>
<h3>
<a
href=
"../dashboard/"
>
Dashboard
</a><br>
<a
href=
"../forum/"
>
Forum
</a><br>
<a
href=
"../assignments/"
>
Assignments
</a><br>
<a
href=
"../calendar/"
>
Calendar
</a><br>
</h3>
{% endblock %}
widget_nicsbabes/announcement_board/urls.py
View file @
a124dc97
from
django.urls
import
path
from
.views
import
index
from
.views
import
(
announcements
,
AnnouncementCreateView
,
AnnouncementDetailView
,
AnnouncementUpdateView
)
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
)
path
(
''
,
announcements
,
name
=
'announcements'
),
path
(
'<int:pk>/details/'
,
AnnouncementDetailView
.
as_view
(),
name
=
'announcement-details'
),
path
(
'add/'
,
AnnouncementCreateView
.
as_view
(),
name
=
'announcement-add'
),
path
(
'<int:pk>/edit/'
,
AnnouncementUpdateView
.
as_view
(),
name
=
'announcement-edit'
),
]
app_name
=
'announcement_board'
widget_nicsbabes/announcement_board/views.py
View file @
a124dc97
from
django.http
import
HttpResponse
from
.models
import
Announcement
,
Reaction
from
dashboard.models
import
WidgetUser
from
.models
import
Announcement
from
django.shortcuts
import
render
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
def
announcements
(
request
):
return
render
(
request
,
'announcement_board/announcements.html'
,
{
'announcements'
:
Announcement
.
objects
.
order_by
(
'-pub_datetime'
)})
def
index
(
request
):
class
AnnouncementDetailView
(
DetailView
):
model
=
Announcement
template_name
=
"announcement_board/announcement-details.html"
return_string
=
'<body>'
for
announcement
in
Announcement
.
objects
.
all
():
announcement_heading
=
'{} by {} {} published {}:<br>'
.
format
(
announcement
.
title
,
announcement
.
author
.
first_name
,
announcement
.
author
.
last_name
,
announcement
.
pub_datetime
.
strftime
(
"
%
m/
%
d/
%
Y,
%
I:
%
M
%
p"
)
)
announcement_body
=
'{}<br>'
.
format
(
announcement
.
body
)
announcement_reactions
=
''
class
AnnouncementCreateView
(
CreateView
):
model
=
Announcement
template_name
=
"announcement_board/announcement-add.html"
fields
=
[
'title'
,
'body'
,
'author'
]
announcement_reactions
+=
'Like: {}<br>'
.
format
(
Reaction
.
objects
.
get
(
announcement
=
announcement
,
name
=
'Like'
)
.
tally
)
announcement_reactions
+=
'Love: {}<br>'
.
format
(
Reaction
.
objects
.
get
(
announcement
=
announcement
,
name
=
'Love'
)
.
tally
)
announcement_reactions
+=
'Angry: {}<br>'
.
format
(
Reaction
.
objects
.
get
(
announcement
=
announcement
,
name
=
'Angry'
)
.
tally
)
return_string
+=
announcement_heading
+
announcement_body
+
announcement_reactions
+
'<br>'
html_string
=
'<html>{}</html>'
.
format
(
return_string
)
return
HttpResponse
(
'Widget’s Announcement Board<br><br>Announcements:<br>'
+
html_string
)
class
AnnouncementUpdateView
(
UpdateView
):
model
=
Announcement
template_name
=
"announcement_board/announcement-edit.html"
fields
=
[
'title'
,
'body'
,
'author'
]
\ No newline at end of file
widget_nicsbabes/widget_nicsbabes/settings.py
View file @
a124dc97
...
...
@@ -118,7 +118,7 @@ TIME_ZONE = 'UTC'
USE_I18N
=
True
USE_TZ
=
Tru
e
USE_TZ
=
Fals
e
# Static files (CSS, JavaScript, Images)
...
...
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