Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_k3git
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
Stefan Gomez
midterm_k3git
Commits
77dbe756
Commit
77dbe756
authored
May 15, 2023
by
MJoshBen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented Per Announcement Details and edited the Models, Views and URLs accordingly
parent
d064d28b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
31 additions
and
3 deletions
+31
-3
models.py
widget_k3git/announcement/models.py
+4
-0
announcement-details.html
...uncement/templates/announcement/announcement-details.html
+17
-0
urls.py
widget_k3git/announcement/urls.py
+2
-1
views.py
widget_k3git/announcement/views.py
+8
-2
No files found.
widget_k3git/announcement/models.py
View file @
77dbe756
from
django.db
import
models
from
django.urls
import
reverse
# Create your models here.
class
Announcement
(
models
.
Model
):
...
...
@@ -9,6 +10,9 @@ class Announcement(models.Model):
def
__str__
(
self
):
return
'{} by {} published {}: {}'
.
format
(
self
.
title
,
self
.
author
,
self
.
pub_datetime
,
self
.
body
)
def
get_absolute_url
(
self
):
return
reverse
(
'announcement:announcement-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Reaction
(
models
.
Model
):
reaction_list
=
[(
"Like"
,
"Like"
),
(
"Heart"
,
"Heart"
),
(
"Angry"
,
"Angry"
)]
...
...
widget_k3git/announcement/templates/announcement/announcement-details.html
0 → 100644
View file @
77dbe756
{% extends 'base.html' %}
{% block title %}{{ announcement.title }}{% endblock %}
{% block content %}
<h1>
{{ announcement.title }}
</h1>
<h3>
by {{ announcement.author }}
</h3>
<h3>
{{ announcement.pub_datetime }}
</h3>
<h3>
{{ announcement.body }}
<br>
{{ reaction.name }}: {{ reaction.tally }}
<br>
{{ reaction.name }}: {{ reaction.tally }}
<br>
{{ reaction.name }}: {{ reaction.tally }}
<br>
</h3>
{% endblock %}
{% block scripts %}
<a
href=
"/announcements/{{ reaction.announcement.pk }}/edit"
><input
type=
"submit"
value=
"Edit Announcement"
></a>
{% endblock %}
widget_k3git/announcement/urls.py
View file @
77dbe756
from
django.contrib
import
admin
from
django.urls
import
path
from
.views
import
index
from
.views
import
index
,
AnnouncementDetailView
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
'<int:pk>/details'
,
AnnouncementDetailView
.
as_view
(),
name
=
'announcement-details'
)
]
app_name
=
"announcement"
widget_k3git/announcement/views.py
View file @
77dbe756
from
django.shortcuts
import
render
from
django.
http
import
HttpResponse
from
django.
views.generic.detail
import
DetailView
from
.models
import
Announcement
,
Reaction
def
index
(
request
):
return
render
(
request
,
'announcement/announcement.html'
,
{
'assignments'
:
Announcement
.
objects
.
all
()})
return
render
(
request
,
'announcement/announcement.html'
,
{
'announcement'
:
Announcement
.
objects
.
all
()})
class
AnnouncementDetailView
(
DetailView
):
model
=
Announcement
def
get
(
self
,
request
,
pk
):
return
render
(
request
,
'announcement/announcement-details.html'
,
{
'announcement'
:
self
.
model
.
objects
.
get
(
pk
=
pk
)})
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