Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_gitgud
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
Neal Luigi D. Rodriguez
midterm_gitgud
Commits
910c0e41
Commit
910c0e41
authored
May 15, 2023
by
Neal Luigi D. Rodriguez
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'announcementv2'
parents
9f35145c
0aa3ee67
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
119 additions
and
8 deletions
+119
-8
forms.py
widget_gitgud/Announcement_Board/forms.py
+12
-0
models.py
widget_gitgud/Announcement_Board/models.py
+10
-4
announcements-add.html
...ment_Board/templates/announcements/announcements-add.html
+12
-0
announcements-details.html
..._Board/templates/announcements/announcements-details.html
+18
-0
announcements-edit.html
...ent_Board/templates/announcements/announcements-edit.html
+12
-0
announcements.html
...uncement_Board/templates/announcements/announcements.html
+24
-0
urls.py
widget_gitgud/Announcement_Board/urls.py
+9
-3
views.py
widget_gitgud/Announcement_Board/views.py
+22
-1
No files found.
widget_gitgud/Announcement_Board/forms.py
0 → 100644
View file @
910c0e41
from
django
import
forms
from
.models
import
Announcement
,
Reaction
class
AnnouncementForm
(
forms
.
ModelForm
):
class
meta
:
model
=
Announcement
fields
=
[
'title'
,
'body'
,
'author'
,
'pub_datetime'
]
class
ReactionForm
(
forms
.
ModelForm
):
class
meta
:
model
=
Reaction
fields
=
[
'name'
,
'tally'
,
'announcement'
]
widget_gitgud/Announcement_Board/models.py
View file @
910c0e41
from
django.db
import
models
from
django.db
import
models
from
Dashboard.models
import
WidgetUser
from
Dashboard.models
import
WidgetUser
from
django.urls
import
reverse
class
Announcement
(
models
.
Model
):
class
Announcement
(
models
.
Model
):
title
=
models
.
CharField
(
max_length
=
100
)
title
=
models
.
CharField
(
max_length
=
100
)
...
@@ -9,7 +10,10 @@ class Announcement(models.Model):
...
@@ -9,7 +10,10 @@ class Announcement(models.Model):
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
title
return
self
.
title
def
get_absolute_url
(
self
):
return
reverse
(
'Announcement_Board:announcements-details'
,
kwargs
=
{
'pk'
:
self
.
pk
})
class
Reaction
(
models
.
Model
):
class
Reaction
(
models
.
Model
):
name_choices
=
(
name_choices
=
(
(
'like'
,
'like'
),
(
'like'
,
'like'
),
...
@@ -18,9 +22,11 @@ class Reaction(models.Model):
...
@@ -18,9 +22,11 @@ class Reaction(models.Model):
)
)
name
=
models
.
CharField
(
max_length
=
100
,
choices
=
name_choices
)
name
=
models
.
CharField
(
max_length
=
100
,
choices
=
name_choices
)
tally
=
models
.
IntegerField
()
tally
=
models
.
IntegerField
()
announcement
=
models
.
ForeignKey
(
Announcement
,
on_delete
=
models
.
PROTECT
)
announcement
=
models
.
ForeignKey
(
Announcement
,
on_delete
=
models
.
PROTECT
,
related_name
=
'reactions'
)
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
widget_gitgud/Announcement_Board/templates/announcements/announcements-add.html
0 → 100644
View file @
910c0e41
{% extends 'base.html' %}
{% load static %}
{% block title %} Add Announcement {% endblock %}
{% block content %}
<h1>
Add a new announcement
</h1>
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Add Announcement"
>
</form>
{% endblock %}
widget_gitgud/Announcement_Board/templates/announcements/announcements-details.html
0 → 100644
View file @
910c0e41
{% extends 'base.html' %}
{% load static %}
{% block title %}{{ object.title }}{% endblock %}
{% block content %}
<h1>
{{ object.title }}
</h1>
<h2>
by {{ object.author }}
</h2>
<h3>
{{ object.pub_datetime }}
</h3>
<h4>
{{ object.body }}
</h4>
<ul>
{% for reaction in object.reactions.all %}
{{reaction.name}}: {{reaction.tally}}
<br>
{% endfor %}
</ul>
<button
onclick=
"window.location.href='../../../announcements/{{object.id}}/edit/';"
>
Edit Announcement
</button>
{% endblock %}
widget_gitgud/Announcement_Board/templates/announcements/announcements-edit.html
0 → 100644
View file @
910c0e41
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Announcement {% endblock %}
{% block content %}
<h1>
Edit announcement
</h1>
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes to Announcement"
>
</form>
{% endblock %}
widget_gitgud/Announcement_Board/templates/announcements/announcements.html
0 → 100644
View file @
910c0e41
{% extends 'base.html' %}
{% load static %}
{% block title %} Widget's Announcement Board {% endblock %}
{% block content %}
<h1>
Welcome to Widget's Announcement Board!
</h1>
<h2>
Announcements:
</h2>
<ul>
{% for object in announcements %}
<li>
<a
href=
"{{ object.get_absolute_url }}"
>
{{ object.title }} by {{ object.author }}
</a>
</li>
{% endfor %}
</ul>
<button
onclick=
"window.location.href='../announcements/add/';"
>
New Announcement
</button>
<p>
<a
href=
"http://127.0.0.1:8000/Dashboard/"
>
Dashboard
</a><br>
<a
href=
"http://127.0.0.1:8000/Forum/"
>
Forum
</a><br>
<a
href=
"http://127.0.0.1:8000/Assignments/"
>
Assignments
</a><br>
<a
href=
"http://127.0.0.1:8000/Calendar/"
>
Calendar
</a>
</p>
{% endblock %}
\ No newline at end of file
widget_gitgud/Announcement_Board/urls.py
View file @
910c0e41
from
django.urls
import
path
from
django.urls
import
path
from
.views
import
index
from
.views
import
(
index
,
AnnouncementView
,
AnnouncementsDetailView
,
AnnouncementsCreateView
,
AnnouncementsUpdateView
)
urlpatterns
=
[
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
''
,
index
,
name
=
'index'
),
path
(
'announcements/'
,
AnnouncementView
,
name
=
"Announcements"
),
path
(
'announcements/<pk>/details/'
,
AnnouncementsDetailView
.
as_view
(),
name
=
'announcements-details'
),
path
(
'announcements/add/'
,
AnnouncementsCreateView
.
as_view
(),
name
=
'announcements-add'
),
path
(
'announcements/<pk>/edit/'
,
AnnouncementsUpdateView
.
as_view
(),
name
=
'announcements-edit'
)
]
]
app_name
=
"AnnouncementBoard"
app_name
=
"Announcement_Board"
\ No newline at end of file
widget_gitgud/Announcement_Board/views.py
View file @
910c0e41
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.shortcuts
import
HttpResponse
from
django.shortcuts
import
HttpResponse
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
.models
import
Announcement
,
Reaction
from
.models
import
Announcement
,
Reaction
...
@@ -25,8 +27,27 @@ def index(request):
...
@@ -25,8 +27,27 @@ def index(request):
like
,
love
,
angry
,
like
,
love
,
angry
,
)
)
return_string
+=
'</ul>'
return_string
+=
'</ul>'
html_string
=
'<html><head>Widget’s Announcement Board<br><br>Announcements:</head><body>{}</body><html>'
.
format
(
return_string
)
html_string
=
'<html><head>Widget’s Announcement Board<br><br>Announcements:</head><body>{}</body><html>'
.
format
(
return_string
)
return
HttpResponse
(
html_string
)
return
HttpResponse
(
html_string
)
def
AnnouncementView
(
request
):
announcements
=
Announcement
.
objects
.
all
()
context
=
{
'announcements'
:
announcements
}
return
render
(
request
,
'announcements/announcements.html'
,
context
)
class
AnnouncementsDetailView
(
DetailView
):
model
=
Announcement
template_name
=
'announcements/announcements-details.html'
class
AnnouncementsCreateView
(
CreateView
):
model
=
Announcement
fields
=
'__all__'
template_name
=
'announcements/announcements-add.html'
class
AnnouncementsUpdateView
(
UpdateView
):
model
=
Announcement
fields
=
'__all__'
template_name
=
'announcements/announcements-edit.html'
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