Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_Alipins
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
Angelico Ruiz T. Teaño
widget_Alipins
Commits
12c7835a
Commit
12c7835a
authored
May 21, 2022
by
Carlo Joseph Echon
🐟
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added new view called addAnnouncement, and setup new page called add.html
parent
2bcd33fa
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
46 additions
and
9 deletions
+46
-9
models.py
widget_alipins/announcements/models.py
+7
-1
add.html
...et_alipins/announcements/templates/announcements/add.html
+17
-0
detail.html
...alipins/announcements/templates/announcements/detail.html
+8
-6
index.html
..._alipins/announcements/templates/announcements/index.html
+4
-1
urls.py
widget_alipins/announcements/urls.py
+3
-1
views.py
widget_alipins/announcements/views.py
+7
-0
db.sqlite3
widget_alipins/db.sqlite3
+0
-0
No files found.
widget_alipins/announcements/models.py
View file @
12c7835a
from
pickle
import
TRUE
from
django.db
import
models
from
django.db
import
models
from
homepage.models
import
WidgetUser
from
homepage.models
import
WidgetUser
from
django.urls
import
reverse
# Create your models here.
# Create your models here.
class
Announcement
(
models
.
Model
):
class
Announcement
(
models
.
Model
):
announcement_title
=
models
.
CharField
(
max_length
=
50
)
announcement_title
=
models
.
CharField
(
max_length
=
50
)
announcement_body
=
models
.
TextField
(
max_length
=
1500
)
announcement_body
=
models
.
TextField
(
max_length
=
1500
)
pub_date
=
models
.
DateTimeField
(
"date published"
)
pub_date
=
models
.
DateTimeField
(
"date published"
,
auto_now_add
=
True
)
pub_date
.
editable
=
True
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
)
announcement_image
=
models
.
ImageField
(
null
=
True
,
blank
=
True
,
upload_to
=
"announcements/"
)
announcement_image
=
models
.
ImageField
(
null
=
True
,
blank
=
True
,
upload_to
=
"announcements/"
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
announcement_title
return
self
.
announcement_title
def
get_absolute_url
(
self
):
return
reverse
(
'announcements:indexAnnouncements'
)
class
Reaction
(
models
.
Model
):
class
Reaction
(
models
.
Model
):
LIKE
=
"Like"
LIKE
=
"Like"
LOVE
=
"Love"
LOVE
=
"Love"
...
...
widget_alipins/announcements/templates/announcements/add.html
0 → 100644
View file @
12c7835a
{% extends 'base.html' %}
{% load static %}
{% block styles %}
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'announcements/style.css' %}"
>
{% endblock %}
{% block title %}New Announcement{% endblock %}
{% block content %}
<h1>
New Announcement
</h1>
<div>
<form
method=
"POST"
,
enctype=
"multipart/form-data"
>
{% csrf_token %}
{{form.as_p}}
<button>
Save Announcement
</button>
</div>
{% endblock %}
\ No newline at end of file
widget_alipins/announcements/templates/announcements/detail.html
View file @
12c7835a
...
@@ -15,13 +15,15 @@
...
@@ -15,13 +15,15 @@
{% if announcement.announcement_image %}
{% if announcement.announcement_image %}
<img
src =
"{{ announcement.announcement_image.url }}"
><br>
<img
src =
"{{ announcement.announcement_image.url }}"
><br>
{% endif %}
{% endif %}
Reaction:
<br>
Reaction
s
:
<br>
{% for reaction in reaction_list %}
{% for reaction in reaction_list %}
{% if reaction.announcement.id == announcement.id %}
{% if reaction.announcement.id == announcement.id %}
{{reaction.reaction_name}}: {{reaction.tally}}
<br>
{{reaction.reaction_name}}: {{reaction.tally}}
<br>
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
</p>
</p>
</div>
</div>
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_alipins/announcements/templates/announcements/index.html
View file @
12c7835a
...
@@ -13,11 +13,14 @@
...
@@ -13,11 +13,14 @@
{% if announcement_list %}
{% if announcement_list %}
<ul>
<ul>
{% for announcement in announcement_list %}
{% for announcement in announcement_list %}
<li><a
href=
"{% url 'announcements:details' announcement.id %}"
>
{{announcement.announcement_title}}
</a>
by {{announcement.author.first_name}} {{announcement.author.last_name}} dated {{announcement.pub_date|date:"d/m/Y"}}
</li>
<li><a
href=
"{% url 'announcements:details
Announcements
' announcement.id %}"
>
{{announcement.announcement_title}}
</a>
by {{announcement.author.first_name}} {{announcement.author.last_name}} dated {{announcement.pub_date|date:"d/m/Y"}}
</li>
{% endfor %}
{% endfor %}
</ul>
</ul>
{% else %}
{% else %}
<p>
There are no announcements.
</p>
<p>
There are no announcements.
</p>
{% endif %}
{% endif %}
<a
href=
"{% url 'announcements:addAnnouncements' %}"
>
<button>
New Announcement
</button>
</a>
</div>
</div>
{% endblock %}
{% endblock %}
\ No newline at end of file
widget_alipins/announcements/urls.py
View file @
12c7835a
from
django.urls
import
path
from
django.urls
import
path
from
.
import
views
from
.
import
views
from
.views
import
addAnnouncement
app_name
=
"announcements"
app_name
=
"announcements"
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
views
.
index
,
name
=
"indexAnnouncements"
),
path
(
''
,
views
.
index
,
name
=
"indexAnnouncements"
),
path
(
'<int:announcement_id>/details'
,
views
.
details
,
name
=
"details"
)
path
(
'<int:announcement_id>/details'
,
views
.
details
,
name
=
"detailsAnnouncements"
),
path
(
'add/'
,
addAnnouncement
.
as_view
(),
name
=
"addAnnouncements"
),
]
]
\ No newline at end of file
widget_alipins/announcements/views.py
View file @
12c7835a
...
@@ -2,6 +2,7 @@ from multiprocessing import context
...
@@ -2,6 +2,7 @@ from multiprocessing import context
from
django.http
import
HttpResponse
,
Http404
from
django.http
import
HttpResponse
,
Http404
from
.models
import
Announcement
,
Reaction
from
.models
import
Announcement
,
Reaction
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views.generic
import
CreateView
# Create your views here.
# Create your views here.
def
index
(
request
):
def
index
(
request
):
...
@@ -23,3 +24,9 @@ def details(request, announcement_id):
...
@@ -23,3 +24,9 @@ def details(request, announcement_id):
"reaction_list"
:
reaction_list
,
"reaction_list"
:
reaction_list
,
}
}
return
render
(
request
,
"announcements/detail.html"
,
output
)
return
render
(
request
,
"announcements/detail.html"
,
output
)
class
addAnnouncement
(
CreateView
):
model
=
Announcement
template_name
=
"announcements/add.html"
fields
=
[
'announcement_title'
,
'announcement_body'
,
'author'
,
'announcement_image'
]
widget_alipins/db.sqlite3
View file @
12c7835a
No preview for this file type
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