Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
midterm_robo_mommy
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Raul Jarod Conanan
midterm_robo_mommy
Commits
13e880fe
Commit
13e880fe
authored
May 13, 2023
by
Jiuvi Anne Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed variable names and fixed templates.
parent
619afd5f
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
37 additions
and
16 deletions
+37
-16
models.cpython-38.pyc
...obo_mommy/announcements/__pycache__/models.cpython-38.pyc
+0
-0
urls.cpython-38.pyc
..._robo_mommy/announcements/__pycache__/urls.cpython-38.pyc
+0
-0
views.cpython-38.pyc
...robo_mommy/announcements/__pycache__/views.cpython-38.pyc
+0
-0
0002_alter_reaction_announcement.py
...ouncements/migrations/0002_alter_reaction_announcement.py
+19
-0
0002_alter_reaction_announcement.cpython-38.pyc
...pycache__/0002_alter_reaction_announcement.cpython-38.pyc
+0
-0
models.py
widget_robo_mommy/announcements/models.py
+1
-1
announcement-add.html
...nouncements/templates/announcements/announcement-add.html
+2
-2
announcement-details.html
...cements/templates/announcements/announcement-details.html
+8
-7
announcement-edit.html
...ouncements/templates/announcements/announcement-edit.html
+1
-1
announcements.html
.../announcements/templates/announcements/announcements.html
+2
-2
views.py
widget_robo_mommy/announcements/views.py
+4
-3
wsgi.cpython-38.pyc
...o_mommy/widget_robo_mommy/__pycache__/wsgi.cpython-38.pyc
+0
-0
No files found.
widget_robo_mommy/announcements/__pycache__/models.cpython-38.pyc
View file @
13e880fe
No preview for this file type
widget_robo_mommy/announcements/__pycache__/urls.cpython-38.pyc
View file @
13e880fe
No preview for this file type
widget_robo_mommy/announcements/__pycache__/views.cpython-38.pyc
View file @
13e880fe
No preview for this file type
widget_robo_mommy/announcements/migrations/0002_alter_reaction_announcement.py
0 → 100644
View file @
13e880fe
# Generated by Django 3.2 on 2023-05-13 14:43
from
django.db
import
migrations
,
models
import
django.db.models.deletion
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'announcements'
,
'0001_initial'
),
]
operations
=
[
migrations
.
AlterField
(
model_name
=
'reaction'
,
name
=
'announcement'
,
field
=
models
.
ForeignKey
(
null
=
True
,
on_delete
=
django
.
db
.
models
.
deletion
.
CASCADE
,
related_name
=
'react'
,
to
=
'announcements.announcement'
),
),
]
widget_robo_mommy/announcements/migrations/__pycache__/0002_alter_reaction_announcement.cpython-38.pyc
0 → 100644
View file @
13e880fe
File added
widget_robo_mommy/announcements/models.py
View file @
13e880fe
...
@@ -19,6 +19,6 @@ class Reaction(models.Model):
...
@@ -19,6 +19,6 @@ class Reaction(models.Model):
name
=
models
.
CharField
(
max_length
=
5
,
default
=
LIKE
,
null
=
True
,
blank
=
True
)
name
=
models
.
CharField
(
max_length
=
5
,
default
=
LIKE
,
null
=
True
,
blank
=
True
)
tally
=
models
.
IntegerField
(
default
=
0
,
null
=
True
,
blank
=
True
)
tally
=
models
.
IntegerField
(
default
=
0
,
null
=
True
,
blank
=
True
)
announcement
=
models
.
ForeignKey
(
Announcement
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
announcement
=
models
.
ForeignKey
(
Announcement
,
related_name
=
"react"
,
on_delete
=
models
.
CASCADE
,
null
=
True
)
# Create your models here.
# Create your models here.
widget_robo_mommy/announcements/templates/announcements/announcement-add.html
View file @
13e880fe
...
@@ -5,10 +5,10 @@
...
@@ -5,10 +5,10 @@
<title>
Add Announcement
</title>
<title>
Add Announcement
</title>
<h1>
Add a new announcement:
</h1>
<h1>
Add a new announcement:
</h1>
<form
action=
"
/"
method=
"post"
>
<form
action=
"
"
method=
POST
>
{% csrf_token %}
{% csrf_token %}
{{ form.as_p }}
{{ form.as_p }}
<input
type=
"submit"
value=
"
Save Changes to
Announcement"
>
<input
type=
"submit"
value=
"
Add
Announcement"
>
</form>
</form>
{% endblock content %}
{% endblock content %}
\ No newline at end of file
widget_robo_mommy/announcements/templates/announcements/announcement-details.html
View file @
13e880fe
...
@@ -3,17 +3,18 @@
...
@@ -3,17 +3,18 @@
{% block content %}
{% block content %}
<title>
{{
announcement.title
}}
</title>
<title>
{{
announce.title
}}
</title>
<h1>
{{announcement.title}}
</h1>
<h1>
{{ announce.title }}
</h1>
<h2>
by
</h2>
<h2>
by {{ announce.author.first_name }} {{ announce.author.last_name }}
</h2>
<p>
{{ announce.pub_datetime|date:'m/d/Y, h:i A' }}
</p>
<p>
{{ announce
ment.body }}
</p><br
>
<p>
{{ announce
.body }}
</p
>
<p>
<p>
{% for react
ion in reaction.model
.all %}
{% for react
in announce.react
.all %}
{{ react
ion.name }}: {{ reaction
.tally }}
<br>
{{ react
.name }}: {{ react
.tally }}
<br>
{% endfor %}
{% endfor %}
</p>
</p>
<a
href =
"
announcements/<int:pk>
/edit/"
><button
value=
""
>
Edit Announcement
</button></a>
<a
href =
"
/announcements/{{ announce.pk }}
/edit/"
><button
value=
""
>
Edit Announcement
</button></a>
{% endblock content %}
{% endblock content %}
\ No newline at end of file
widget_robo_mommy/announcements/templates/announcements/announcement-edit.html
View file @
13e880fe
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<title>
Edit Announcement
</title>
<title>
Edit Announcement
</title>
<h1>
Edit announcement:
</h1>
<h1>
Edit announcement:
</h1>
<form
action=
"
/
"
method=
POST
>
<form
action=
""
method=
POST
>
{% csrf_token %}
{% csrf_token %}
{{ form.as_p }}
{{ form.as_p }}
<input
type=
"submit"
value=
"Save Changes to Announcement"
>
<input
type=
"submit"
value=
"Save Changes to Announcement"
>
...
...
widget_robo_mommy/announcements/templates/announcements/announcements.html
View file @
13e880fe
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
<h1>
Welcome to Widget's Announcement Board!
</h1>
<h1>
Welcome to Widget's Announcement Board!
</h1>
<h3>
Announcements:
</h3>
<h3>
Announcements:
</h3>
{% for announce
ment in announcements
%}
{% for announce
in announcement
%}
<a
href =
"
announcements/{{ announcedetails.pk }}/details/"
>
{{ announcement.title }} by {{ announcement.author.first_name }} {{ announcement
.author.last_name }}
</a><br>
<a
href =
"
{{ announce.pk }}/details/"
>
{{ announce.title }} by {{ announce.author.first_name }} {{ announce
.author.last_name }}
</a><br>
{% endfor %}
<br>
{% endfor %}
<br>
<a
href=
"add/"
><button
value=
"click here"
>
Add Announcement
</button></a><br><br>
<a
href=
"add/"
><button
value=
"click here"
>
Add Announcement
</button></a><br><br>
...
...
widget_robo_mommy/announcements/views.py
View file @
13e880fe
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views.generic.detail
import
DetailView
from
django.views.generic.detail
import
DetailView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
django.views.generic.edit
import
CreateView
,
UpdateView
from
django.urls
import
reverse
from
.models
import
Announcement
,
Reaction
from
.models
import
Announcement
,
Reaction
import
pytz
import
pytz
from
django.utils
import
timezone
from
django.utils
import
timezone
...
@@ -12,7 +13,6 @@ def convert_to_localtime(utctime):
...
@@ -12,7 +13,6 @@ def convert_to_localtime(utctime):
localtz
=
utc
.
astimezone
(
timezone
.
get_current_timezone
())
localtz
=
utc
.
astimezone
(
timezone
.
get_current_timezone
())
return
localtz
.
strftime
(
format
)
return
localtz
.
strftime
(
format
)
def
index
(
request
):
def
index
(
request
):
announcement
=
Announcement
.
objects
.
all
()
.
order_by
(
'-pub_datetime'
)
announcement
=
Announcement
.
objects
.
all
()
.
order_by
(
'-pub_datetime'
)
context
=
{
context
=
{
...
@@ -25,11 +25,11 @@ class AnnouncementDetailView(DetailView):
...
@@ -25,11 +25,11 @@ class AnnouncementDetailView(DetailView):
model
=
Announcement
model
=
Announcement
template_name
=
'announcements/announcement-details.html'
template_name
=
'announcements/announcement-details.html'
queryset
=
Announcement
.
objects
.
all
()
queryset
=
Announcement
.
objects
.
all
()
context_object_name
=
'annou
cedetails
'
context_object_name
=
'annou
nce
'
class
AnnouncementAddView
(
CreateView
):
class
AnnouncementAddView
(
CreateView
):
model
=
Announcement
model
=
Announcement
fields
=
'__all__'
fields
=
[
'title'
,
'body'
,
'author'
]
template_name
=
'announcements/announcement-add.html'
template_name
=
'announcements/announcement-add.html'
def
get_success_url
(
self
):
def
get_success_url
(
self
):
...
@@ -39,6 +39,7 @@ class AnnouncementAddView(CreateView):
...
@@ -39,6 +39,7 @@ class AnnouncementAddView(CreateView):
class
AnnouncementEditView
(
UpdateView
):
class
AnnouncementEditView
(
UpdateView
):
model
=
Announcement
model
=
Announcement
template_name
=
'announcements/announcement-edit.html'
template_name
=
'announcements/announcement-edit.html'
fields
=
[
'title'
,
'body'
,
'author'
]
def
get_success_url
(
self
):
def
get_success_url
(
self
):
return
reverse
(
'announcement:announcementdetailview'
,
kwargs
=
{
'pk'
:
self
.
object
.
id
},
return
reverse
(
'announcement:announcementdetailview'
,
kwargs
=
{
'pk'
:
self
.
object
.
id
},
...
...
widget_robo_mommy/widget_robo_mommy/__pycache__/wsgi.cpython-38.pyc
0 → 100644
View file @
13e880fe
File added
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