Commit 5fadab0c authored by Christian Sarabia's avatar Christian Sarabia

Merge branch 'sarabia/forum' into 'master'

Updated visual elements and CSS

See merge request !2
parents e4182b16 917803c2
from django import forms from django import forms
from homepage.models import WidgetUser
from .models import Post from .models import Post
class AddForm(forms.ModelForm): class AddForm(forms.ModelForm):
class Meta: class Meta:
model = Post model = Post
fields = "__all__" fields = "__all__"
\ No newline at end of file
# post_title = forms.CharField(label='Title', max_length=50)
# post_body = forms.CharField(label='Body', max_length=1500, widget=forms.Textarea)
# # pub_date = models.DateTimeField("date published")
# author = forms.ModelChoiceField(label='Author', queryset=WidgetUser.objects.all())
# post_image = forms.ImageField(required=False)
\ No newline at end of file
...@@ -13,6 +13,9 @@ class Post(models.Model): ...@@ -13,6 +13,9 @@ class Post(models.Model):
def __str__(self): def __str__(self):
return self.post_title return self.post_title
def get_absolute_url(self):
return u'%d/details' % self.pk
class Reply(models.Model): class Reply(models.Model):
post = models.ForeignKey(Post, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.CASCADE)
reply_body = models.TextField(max_length=1500) reply_body = models.TextField(max_length=1500)
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
{% else %} {% else %}
<p>There is no post.</p> <p>There is no post.</p>
{% endif %} {% endif %}
<li><a href="/forum/add">Write a new forum post...</a></li> <button onclick="window.location.href='/forum/add'"">Write a new forum post</button>
</ul> </ul>
</div> </div>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -36,8 +36,12 @@ class AddView(View): ...@@ -36,8 +36,12 @@ class AddView(View):
if form.is_valid(): if form.is_valid():
print(form.cleaned_data['post_title']) print(form.cleaned_data['post_title'])
form.save() form.save()
post = Post.objects.latest('id')
replies = Reply.objects.filter(post=post).order_by("-pub_date")
context = {'form' : form} context = {
"post": post,
return render(request, 'forum/add.html', context) "replies": replies
}
return render(request, "forum/detail.html", context)
from statistics import mode
from django import forms
from .models import WidgetUser
class WidgetUserForm(forms.ModelForm):
class Meta:
model = WidgetUser
fields = ['last_name', 'first_name', 'middle_name', 'id_num', 'email', 'department', 'image']
\ No newline at end of file
...@@ -7,12 +7,6 @@ ...@@ -7,12 +7,6 @@
{% block title %}{{object.pk}}{% endblock %} {% block title %}{{object.pk}}{% endblock %}
{% block content %} {% block content %}
<nav class="topnav">
<a href="{% url 'homepage:indexHomepage' %}">Homepage</a>
<a href="{% url 'announcements:indexAnnouncements' %}">Announcements</a>
<a href="{% url 'forum:indexForum' %}">Forum</a>
<a href="{% url 'assignments:indexAssignments' %}">Assignments</a>
</nav>
<div class="flex-container"> <div class="flex-container">
<div class="user-card"> <div class="user-card">
......
...@@ -5,15 +5,8 @@ ...@@ -5,15 +5,8 @@
<link rel="stylesheet" type="text/css" href="{% static 'homepage/style.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'homepage/style.css' %}">
{% endblock %} {% endblock %}
{% block title %}{{object.pk}}{% endblock %} {% block title %}New Widget User{% endblock %}
{% block content %} {% block content %}
<nav class="topnav">
<a href="{% url 'homepage:indexHomepage' %}">Homepage</a>
<a href="{% url 'announcements:indexAnnouncements' %}">Announcements</a>
<a href="{% url 'forum:indexForum' %}">Forum</a>
<a href="{% url 'assignments:indexAssignments' %}">Assignments</a>
</nav>
<div class="flex-container"> <div class="flex-container">
<form method="POST" enctype="multipart/form-data"> <form method="POST" enctype="multipart/form-data">
{% csrf_token %} {% csrf_token %}
......
...@@ -2,12 +2,14 @@ body { ...@@ -2,12 +2,14 @@ body {
font-family: sans-serif, Arial, Helvetica; font-family: sans-serif, Arial, Helvetica;
color:#035700; color:#035700;
line-height: 2; line-height: 2;
background-color:rgb(230, 253, 228);
} }
div { div {
margin: auto; margin: auto;
width: 50%; width: 50%;
border: 3px solid rgb(194, 7, 169); border: 3px solid rgb(194, 7, 169);
border-radius: 10px;
padding: 30px 40px 40px 40px; padding: 30px 40px 40px 40px;
} }
...@@ -51,3 +53,26 @@ img { ...@@ -51,3 +53,26 @@ img {
a { a {
color:#891fa3; color:#891fa3;
} }
input[type=submit], button {
width: 40%;
background-color: #ff91f0;
padding: 5px;
margin: 25px 0px 0px 0px;
border: none;
border-radius: 18px;
cursor: pointer;
font-family: sans-serif, Arial, Helvetica;
font-size: 18px;
color:#2d384e;
line-height: 2;
float: right;
}
input[type=submit]:hover , button:hover{
background-color: #fcaef1;
}
textarea, input {
border-radius: 5px;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment