Commit 2d877f16 authored by Anchilla Vera Marie Silang's avatar Anchilla Vera Marie Silang

Merge branch 'forumv2' into 'master'

Forumv2

See merge request !9
parents 412904bb 9f6f13a7
......@@ -17,7 +17,7 @@ class WidgetUser(models.Model):
department = models.ForeignKey(Department, null=True, on_delete=models.CASCADE)
def __str__(self):
return '{}, {} {} : {}'.format(self.last_name, self.first_name, self.middle_name, self.department)
return '{}, {}'.format(self.last_name, self.first_name)
def get_absolute_url(self):
return reverse('dashboard:widgetuser-details', kwargs={'pk': self.pk})
......
No preview for this file type
# Generated by Django 3.2 on 2023-05-13 13:54
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('forum', '0003_alter_forumpost_options'),
]
operations = [
migrations.AlterModelOptions(
name='forumpost',
options={'ordering': ['-pub_datetime']},
),
]
......@@ -6,7 +6,7 @@
<h2>Forum Posts:</h2>
{% for post in forum%}
<a href="{% url 'forum:forumpostdetails' post.pk%}">
{{post.title}} by {{post.author}}<br>
{{post.title}} by {{post.author.first_name}} {{post.author.last_name}}<br>
</a>
{%endfor%}
......@@ -15,8 +15,8 @@
<input type="button" value= "New Post"></a>
<br>
<br>
<a href= "{%url 'Dashboard:dashboard_view' %}">Dashboard</a><br>
<a href= "{%url 'assignments:assignments' %}">Assignments</a>
<a href= "/dashboard">Dashboard</a><br>
<a href= "/assignments/">Assignments</a>
<br>
{% endblock%}
\ No newline at end of file
......@@ -4,10 +4,10 @@ from .views import (ForumViews, ForumPostDetails,
ForumPostNew, ForumPostEdit)
urlpatterns = [
path('forum/', views.ForumViews, name='forum'),
path('forum/forumposts/<int:pk>/details/', ForumPostDetails.as_view(), name="forumpostdetails"),
path('forum/forumposts/add/', ForumPostNew.as_view(), name='forumpostnew'),
path('forum/forumposts/<int:pk>/edit/', ForumPostEdit.as_view(), name = 'forumpostedit'),
path('', views.ForumViews, name='forum'),
path('forumposts/<int:pk>/details/', ForumPostDetails.as_view(), name="forumpostdetails"),
path('forumposts/add/', ForumPostNew.as_view(), name='forumpostnew'),
path('forumposts/<int:pk>/edit/', ForumPostEdit.as_view(), name = 'forumpostedit'),
]
app_name = "forum"
......@@ -10,15 +10,15 @@ from .forms import ForumPostForm
def ForumViews(request):
forum = ForumPost.objects.all()
context = {'forum':forum}
return render(request, 'forum.html', context)
return render(request, 'forum/forum.html', context)
class ForumPostDetails(DetailView):
template_name= "forumpost-details.html"
template_name= "forum/forumpost-details.html"
model = ForumPost
class ForumPostNew(CreateView):
form_class = ForumPostForm
template_name = "forumpost-add.html"
template_name = "forum/forumpost-add.html"
def get_success(self):
return reverse('forum:forumpostnew', kwargs = {'pk': self.object.id},
......@@ -26,7 +26,7 @@ class ForumPostNew(CreateView):
class ForumPostEdit(UpdateView):
form_class = ForumPostForm
template_name = "forumpost-edit.html"
template_name = "forum/forumpost-edit.html"
queryset = ForumPost.objects.all()
def get_success_url(self):
......
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