Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_mgabolanimav
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
Mavrick Jordan Lee
midterm_mgabolanimav
Commits
ad570874
Commit
ad570874
authored
May 06, 2023
by
Ross Batacan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Created announcements/add URL with created template announcements-add.html
parent
3b893033
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
14 deletions
+20
-14
models.py
widget_mgabolanimav/announcements/models.py
+7
-3
announcement-add.html
...nouncements/templates/announcements/announcement-add.html
+10
-10
announcements.html
.../announcements/templates/announcements/announcements.html
+1
-1
views.py
widget_mgabolanimav/announcements/views.py
+2
-0
No files found.
widget_mgabolanimav/announcements/models.py
View file @
ad570874
from
django.db
import
models
from
dashboard.models
import
WidgetUser
from
django.urls
import
reverse
# Create your models here.
# please insert foreign key from dashboard application on announcement_author
class
Announcement
(
models
.
Model
):
announcement_title
=
models
.
CharField
(
max_length
=
50
,
unique
=
True
,
null
=
True
,
)
announcement_body
=
models
.
CharField
(
max_length
=
250
,
unique
=
True
,
null
=
True
,
)
announcement_author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
announcement_title
=
models
.
CharField
(
max_length
=
50
,
unique
=
True
,
null
=
True
,
verbose_name
=
"Title"
)
announcement_body
=
models
.
TextField
(
max_length
=
250
,
unique
=
True
,
null
=
True
,
verbose_name
=
"Body"
)
announcement_author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
null
=
True
,
verbose_name
=
"Author"
)
announcement_pub_datetime
=
models
.
DateTimeField
(
null
=
True
,
)
def
__str__
(
self
):
return
self
.
announcement_title
def
get_absolute_url
(
self
):
return
reverse
(
'announcements:announcement-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
reaction_choices
=
(
(
'Like'
,
'Like'
),
...
...
widget_mgabolanimav/announcements/templates/announcements/announcement-add.html
View file @
ad570874
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Title
</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
{% extends 'base.html' %}
{% 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 %}
\ No newline at end of file
widget_mgabolanimav/announcements/templates/announcements/announcements.html
View file @
ad570874
...
...
@@ -4,7 +4,7 @@
<h1>
Welcome to Widget's Announcement Board!
</h1>
<h3>
Announcements:
</h3>
{% for announcement in announcements %}
<a
href=
"{
{ announcement.get_absolute_url }
}"
>
{{ announcement.announcement_title }}
<a
href=
"{
% url 'announcements:announcement-details' announcement.id %
}"
>
{{ announcement.announcement_title }}
by {{ announcement.announcement_author.first_name }} {{ announcement.announcement_author.last_name }}
</a>
<br>
{% endfor %}
<br>
...
...
widget_mgabolanimav/announcements/views.py
View file @
ad570874
...
...
@@ -22,6 +22,8 @@ class AnnouncementsDetailsView(DetailView):
class
AnnouncementsCreateView
(
CreateView
):
model
=
Announcement
fields
=
'announcement_title'
,
'announcement_body'
,
'announcement_author'
template_name
=
'announcements/announcement-add.html'
class
AnnouncementsEditView
(
UpdateView
):
...
...
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