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
18a248ce
Commit
18a248ce
authored
May 23, 2022
by
Emilio Gentolia
Browse files
Options
Browse Files
Download
Plain Diff
merged branches with forum
parents
69139449
d293ac1b
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
78 additions
and
9 deletions
+78
-9
models.py
announcement_board/models.py
+2
-2
announcement_form.css
...ent_board/static/announcement_board/announcement_form.css
+14
-0
announcement_index.css
...nt_board/static/announcement_board/announcement_index.css
+14
-0
announcement_detail.html
...ard/templates/announcement_board/announcement_detail.html
+6
-2
announcement_form.html
...board/templates/announcement_board/announcement_form.html
+21
-0
index.html
announcement_board/templates/announcement_board/index.html
+1
-0
views.py
announcement_board/views.py
+17
-4
urls.py
..._can_i_be_on_my_own_i_have_the_hello_world_to_see/urls.py
+3
-1
No files found.
announcement_board/models.py
View file @
18a248ce
...
@@ -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_form.css
0 → 100644
View file @
18a248ce
label
{
font-family
:
Khula
;
font-weight
:
600
;
}
input
{
font-family
:
Khula
;
}
p
{
margin
:
30px
0px
;
}
form
{
padding-bottom
:
20px
;
}
\ No newline at end of file
announcement_board/static/announcement_board/announcement_index.css
View file @
18a248ce
...
@@ -18,3 +18,17 @@
...
@@ -18,3 +18,17 @@
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 @
18a248ce
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
{% extends 'base.html' %}
{% extends 'base.html' %}
{% load static %}
{% load static %}
{% block title %}
Homepage
{% endblock %}
{% block title %}
Announcements
{% endblock %}
{% block styles %}
{% block styles %}
<link
rel=
"stylesheet"
href=
"{% static 'announcement_board/announcement_detail.css' %}"
>
<link
rel=
"stylesheet"
href=
"{% static 'announcement_board/announcement_detail.css' %}"
>
...
@@ -13,7 +13,11 @@
...
@@ -13,7 +13,11 @@
{% endblock %}
{% endblock %}
{% block content %}
{% block content %}
{% 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' %}"
/>
<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
0 → 100644
View file @
18a248ce
<!-- announcements/announcement_form.html -->
{% extends 'base.html' %}
{% load static %}
{% block title %}Announcements{% endblock %}
{% block styles %}
<link
rel=
"stylesheet"
href=
"{% static 'announcement_board/announcement_form.css' %}"
>
{% endblock %}
{% block header %}
New Announcement
{% endblock %}
{% block content %}
<form
enctype=
"multipart/form-data"
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Announcement"
>
</form>
{% endblock %}
\ No newline at end of file
announcement_board/templates/announcement_board/index.html
View file @
18a248ce
...
@@ -26,4 +26,5 @@ Announcement Board
...
@@ -26,4 +26,5 @@ Announcement Board
</li>
</li>
{% endfor %}
{% endfor %}
</ul>
</ul>
<a
class=
"new-announcement-link"
href=
"add"
>
New Announcement
</a>
{% endblock %}
{% endblock %}
\ No newline at end of file
announcement_board/views.py
View file @
18a248ce
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
from
django.views.generic.edit
import
CreateView
from
.models
import
Announcement
,
Reaction
from
.models
import
Announcement
,
Reaction
...
@@ -16,9 +18,20 @@ class AnnouncementDetailView(DetailView):
...
@@ -16,9 +18,20 @@ 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
)
if
(
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Angry"
)
.
first
()
!=
None
):
context
[
'reaction_likes'
]
=
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Like"
)
.
first
()
.
tally
context
[
'reaction_likes'
]
=
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Like"
)
.
first
()
.
tally
context
[
'reaction_love'
]
=
Reaction
.
objects
.
filter
(
announcement_id
=
self
.
kwargs
[
'pk'
])
.
filter
(
reaction_name
=
"Love"
)
.
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
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
):
model
=
Announcement
fields
=
[
"announcement_title"
,
"announcement_body"
,
"author"
,
"announcement_pic"
]
def
get_success_url
(
self
):
return
"/announcements/"
widget_father_when_can_i_be_on_my_own_i_have_the_hello_world_to_see/urls.py
View file @
18a248ce
...
@@ -19,7 +19,7 @@ from django.conf.urls.static import static
...
@@ -19,7 +19,7 @@ from django.conf.urls.static import static
from
django.conf
import
settings
from
django.conf
import
settings
from
homepage.views
import
WidgetUserCreateView
from
homepage.views
import
WidgetUserCreateView
from
forum.views
import
PostCreateView
from
forum.views
import
PostCreateView
from
announcement_board.views
import
AnnouncementCreateView
urlpatterns
=
[
urlpatterns
=
[
path
(
'homepage/'
,
include
(
"homepage.urls"
,
namespace
=
'homepage'
)),
path
(
'homepage/'
,
include
(
"homepage.urls"
,
namespace
=
'homepage'
)),
...
@@ -31,6 +31,8 @@ urlpatterns = [
...
@@ -31,6 +31,8 @@ urlpatterns = [
path
(
'forum/'
,
include
(
"forum.urls"
,
namespace
=
'forum'
)),
path
(
'forum/'
,
include
(
"forum.urls"
,
namespace
=
'forum'
)),
path
(
'announcements/'
,
include
(
"announcement_board.urls"
,
path
(
'announcements/'
,
include
(
"announcement_board.urls"
,
namespace
=
'announcement_board'
)),
namespace
=
'announcement_board'
)),
path
(
'announcements/add'
,
AnnouncementCreateView
.
as_view
(),
name
=
'announcement_form'
),
path
(
'assignments/'
,
include
(
"assignments.urls"
,
namespace
=
'assignments'
)),
path
(
'assignments/'
,
include
(
"assignments.urls"
,
namespace
=
'assignments'
)),
]
]
...
...
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