Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
widget_father when can i be on my own i have the hello world to see
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
father when can i be on my own i have the hello world to see
widget_father when can i be on my own i have the hello world to see
Commits
d293ac1b
Commit
d293ac1b
authored
May 23, 2022
by
Emilio Gentolia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed image and urls for announcements
parent
11952712
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
9 deletions
+32
-9
models.py
announcement_board/models.py
+2
-2
announcement_index.css
...nt_board/static/announcement_board/announcement_index.css
+14
-0
announcement_detail.html
...ard/templates/announcement_board/announcement_detail.html
+5
-1
announcement_form.html
...board/templates/announcement_board/announcement_form.html
+1
-1
index.html
announcement_board/templates/announcement_board/index.html
+1
-1
views.py
announcement_board/views.py
+9
-4
No files found.
announcement_board/models.py
View file @
d293ac1b
...
@@ -4,10 +4,10 @@ from homepage.models import WidgetUser
...
@@ -4,10 +4,10 @@ from homepage.models import WidgetUser
class
Announcement
(
models
.
Model
):
class
Announcement
(
models
.
Model
):
announcement_title
=
models
.
CharField
(
max_length
=
120
)
announcement_title
=
models
.
CharField
(
max_length
=
120
)
announcement_body
=
models
.
TextField
(
blank
=
True
)
announcement_body
=
models
.
TextField
(
blank
=
True
)
pub_date
=
models
.
DateField
(
"date published"
)
pub_date
=
models
.
DateField
(
auto_now_add
=
True
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
author
=
models
.
ForeignKey
(
WidgetUser
,
on_delete
=
models
.
CASCADE
,
default
=
1
)
announcement_pic
=
models
.
FileField
(
announcement_pic
=
models
.
FileField
(
upload_to
=
"
uploads
"
,
null
=
True
,
blank
=
True
)
upload_to
=
"
media/announcement_board
"
,
null
=
True
,
blank
=
True
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
announcement_title
return
self
.
announcement_title
...
...
announcement_board/static/announcement_board/announcement_index.css
View file @
d293ac1b
...
@@ -17,4 +17,18 @@
...
@@ -17,4 +17,18 @@
font-family
:
Khula
;
font-family
:
Khula
;
font-size
:
30px
;
font-size
:
30px
;
margin
:
0
margin
:
0
}
.new-announcement-link
{
text-decoration
:
none
;
font-family
:
Khula
;
color
:
black
;
font-size
:
26px
;
padding
:
10px
;
width
:
fit-content
;
transition
:
0.2s
ease-in-out
;
}
.new-announcement-link
:hover
{
background-color
:
rgba
(
0
,
0
,
0
,
0.8
);
color
:
white
;
}
}
\ No newline at end of file
announcement_board/templates/announcement_board/announcement_detail.html
View file @
d293ac1b
...
@@ -13,7 +13,11 @@
...
@@ -13,7 +13,11 @@
{% endblock %}
{% endblock %}
{% block content %}
{% block content %}
<img
width=
1000
height=
200
src=
"{% static 'announcement_board/default_announcementpic.png' %}"
/>
{% if object.announcement_pic != None and object.announcement_pic != '' %}
<img
width=
1000
height=
200
src=
"{% get_media_prefix %}{{object.announcement_pic}}"
/>
{% else %}
<img
width=
1000
height=
200
src=
"{% static 'announcement_board/default_announcementpic.png' %}"
/>
{% endif %}
<p>
{{object.announcement_body}}
<p>
<p>
{{object.announcement_body}}
<p>
<p>
by {{object.author.first_name}} {{object.author.last_name}}, {{object.pub_date | date:"d/m/o"}}
</p>
<p>
by {{object.author.first_name}} {{object.author.last_name}}, {{object.pub_date | date:"d/m/o"}}
</p>
<p>
Likes: {{reaction_likes}}
</p>
<p>
Likes: {{reaction_likes}}
</p>
...
...
announcement_board/templates/announcement_board/announcement_form.html
View file @
d293ac1b
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
{% block title %}Announcements{% endblock %}
{% block title %}Announcements{% endblock %}
{% block styles %}
{% block styles %}
<link
rel=
"stylesheet"
href=
"{% static 'announcement
s
/announcement_form.css' %}"
>
<link
rel=
"stylesheet"
href=
"{% static 'announcement
_board
/announcement_form.css' %}"
>
{% endblock %}
{% endblock %}
{% block header %}
{% block header %}
...
...
announcement_board/templates/announcement_board/index.html
View file @
d293ac1b
...
@@ -26,5 +26,5 @@ Announcement Board
...
@@ -26,5 +26,5 @@ Announcement Board
</li>
</li>
{% endfor %}
{% endfor %}
</ul>
</ul>
<a
class=
"new-
user-link"
href=
"/announcements/
add"
>
New Announcement
</a>
<a
class=
"new-
announcement-link"
href=
"
add"
>
New Announcement
</a>
{% endblock %}
{% endblock %}
\ No newline at end of file
announcement_board/views.py
View file @
d293ac1b
from
types
import
NoneType
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views
import
View
from
django.views
import
View
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
...
@@ -17,10 +18,14 @@ class AnnouncementDetailView(DetailView):
...
@@ -17,10 +18,14 @@ class AnnouncementDetailView(DetailView):
model
=
Announcement
model
=
Announcement
def
get_context_data
(
self
,
**
kwargs
):
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
=
super
()
.
get_context_data
(
**
kwargs
)
context
[
'reaction_likes'
]
=
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Like"
)
.
first
()
.
tally
if
(
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Angry"
)
.
first
()
!=
None
):
context
[
'reaction_love'
]
=
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Love"
)
.
first
()
.
tally
context
[
'reaction_likes'
]
=
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Like"
)
.
first
()
.
tally
context
[
'reaction_angry'
]
=
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Angry"
)
.
first
()
.
tally
context
[
'reaction_love'
]
=
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Love"
)
.
first
()
.
tally
context
[
'reaction_angry'
]
=
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Angry"
)
.
first
()
.
tally
else
:
context
[
'reaction_likes'
]
=
0
context
[
'reaction_love'
]
=
0
context
[
'reaction_angry'
]
=
0
return
context
return
context
class
AnnouncementCreateView
(
CreateView
):
class
AnnouncementCreateView
(
CreateView
):
...
...
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