Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_vincentdjango
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
1
Merge Requests
1
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
Almira Redoble
midterm_vincentdjango
Commits
e76c70e0
Commit
e76c70e0
authored
May 11, 2023
by
Jayson Lim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
created announcement-edit.html and implemented UpdateView. Configured also the links of each page
parent
d815dee3
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
6 deletions
+38
-6
models.py
widget_vincentdjango/announcements/models.py
+1
-1
announcement-details.html
...cements/templates/announcements/announcement-details.html
+3
-0
announcement-edit.html
...ouncements/templates/announcements/announcement-edit.html
+15
-0
announcements.html
.../announcements/templates/announcements/announcements.html
+11
-2
urls.py
widget_vincentdjango/announcements/urls.py
+2
-2
views.py
widget_vincentdjango/announcements/views.py
+6
-1
db.sqlite3
widget_vincentdjango/db.sqlite3
+0
-0
No files found.
widget_vincentdjango/announcements/models.py
View file @
e76c70e0
...
...
@@ -13,7 +13,7 @@ class Announcement(models.Model):
on_delete
=
models
.
CASCADE
,
related_name
=
'announcements'
,
)
pub_datetime
=
models
.
DateTimeField
(
auto_now_add
=
True
)
pub_datetime
=
models
.
DateTimeField
(
auto_now_add
=
True
,
editable
=
False
)
def
__str__
(
self
):
return
self
.
title
...
...
widget_vincentdjango/announcements/templates/announcements/announcement-details.html
View file @
e76c70e0
...
...
@@ -13,4 +13,7 @@
{{ reaction.name }}: {{ reaction.tally }}
</p>
{% endfor %}
<button
onclick=
"window.location.href='{% url 'announcements:announcements-edit' pk=object.pk %}'"
>
Edit Announcement
</button>
{% endblock %}
\ No newline at end of file
widget_vincentdjango/announcements/templates/announcements/announcement-edit.html
0 → 100644
View file @
e76c70e0
{% extends 'base.html' %}
{% load static %}
{% block title %} Edit Anouncement {% endblock %}
{% block heading %}
<h1>
Edit Announcement:
</h1>
{% endblock %}
{% block content %}
<form
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<br>
<input
type=
"submit"
value=
"Save Changes to Announcement"
>
</form>
{% endblock %}
widget_vincentdjango/announcements/templates/announcements/announcements.html
View file @
e76c70e0
...
...
@@ -8,7 +8,7 @@
{% block content %}
<h2>
Announcements:
</h2>
<ul>
{% for object in announcements %}
{% for object in announcements
|dictsortreversed:"pub_datetime"
%}
<li>
<a
href=
"{{ object.get_absolute_url }}"
>
{{ object.title }} by
{{ object.author.first_name}} {{ object.author.last_name }}
...
...
@@ -17,5 +17,14 @@
{% endfor %}
</ul>
<hr>
<button
onclick=
"window.location.href='{% url 'announcements:announcements-add' %}'"
>
New Announcement
</button>
<button
onclick=
"window.location.href='{% url 'announcements:announcements-add' %}'"
>
New Announcement
</button>
<div
id=
"footer"
>
<a
href=
"{% url 'dashboard:index' %}"
>
Dashboard
</a>
<a
href=
"{% url 'forum:index' %}"
>
Forum
</a>
<a
href=
"{% url 'assignments:homePage' %}"
>
Assignments
</a>
<a
href=
"{% url 'widget_calendar:index' %}"
>
Calendar
</a>
</div>
{% endblock %}
widget_vincentdjango/announcements/urls.py
View file @
e76c70e0
from
django.urls
import
path
from
.views
import
index
,
AnnouncementsDetailView
,
AnnouncementsCreateView
from
.views
import
index
,
AnnouncementsDetailView
,
AnnouncementsCreateView
,
AnnouncementsUpdateView
urlpatterns
=
[
path
(
''
,
index
,
name
=
'index'
),
path
(
'announcements/<int:pk>/details'
,
AnnouncementsDetailView
.
as_view
(),
name
=
'announcements-detail'
),
path
(
'announcements/add'
,
AnnouncementsCreateView
.
as_view
(),
name
=
'announcements-add'
),
path
(
'announcements/<int:pk>/edit'
,
AnnouncementsUpdateView
.
as_view
(),
name
=
'announcements-edit'
)
]
...
...
widget_vincentdjango/announcements/views.py
View file @
e76c70e0
...
...
@@ -17,3 +17,8 @@ class AnnouncementsCreateView(CreateView):
model
=
Announcement
template_name
=
'announcements/announcement-add.html'
fields
=
[
"title"
,
"body"
,
"author"
]
class
AnnouncementsUpdateView
(
UpdateView
):
model
=
Announcement
template_name
=
'announcements/announcement-edit.html'
fields
=
'__all__'
\ No newline at end of file
widget_vincentdjango/db.sqlite3
View file @
e76c70e0
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