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): ...@@ -17,7 +17,7 @@ class WidgetUser(models.Model):
department = models.ForeignKey(Department, null=True, on_delete=models.CASCADE) department = models.ForeignKey(Department, null=True, on_delete=models.CASCADE)
def __str__(self): 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): def get_absolute_url(self):
return reverse('dashboard:widgetuser-details', kwargs={'pk': self.pk}) 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 @@ ...@@ -6,7 +6,7 @@
<h2>Forum Posts:</h2> <h2>Forum Posts:</h2>
{% for post in forum%} {% for post in forum%}
<a href="{% url 'forum:forumpostdetails' post.pk%}"> <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> </a>
{%endfor%} {%endfor%}
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
<input type="button" value= "New Post"></a> <input type="button" value= "New Post"></a>
<br> <br>
<br> <br>
<a href= "{%url 'Dashboard:dashboard_view' %}">Dashboard</a><br> <a href= "/dashboard">Dashboard</a><br>
<a href= "{%url 'assignments:assignments' %}">Assignments</a> <a href= "/assignments/">Assignments</a>
<br> <br>
{% endblock%} {% endblock%}
\ No newline at end of file
...@@ -4,10 +4,10 @@ from .views import (ForumViews, ForumPostDetails, ...@@ -4,10 +4,10 @@ from .views import (ForumViews, ForumPostDetails,
ForumPostNew, ForumPostEdit) ForumPostNew, ForumPostEdit)
urlpatterns = [ urlpatterns = [
path('forum/', views.ForumViews, name='forum'), path('', views.ForumViews, name='forum'),
path('forum/forumposts/<int:pk>/details/', ForumPostDetails.as_view(), name="forumpostdetails"), path('forumposts/<int:pk>/details/', ForumPostDetails.as_view(), name="forumpostdetails"),
path('forum/forumposts/add/', ForumPostNew.as_view(), name='forumpostnew'), path('forumposts/add/', ForumPostNew.as_view(), name='forumpostnew'),
path('forum/forumposts/<int:pk>/edit/', ForumPostEdit.as_view(), name = 'forumpostedit'), path('forumposts/<int:pk>/edit/', ForumPostEdit.as_view(), name = 'forumpostedit'),
] ]
app_name = "forum" app_name = "forum"
...@@ -10,15 +10,15 @@ from .forms import ForumPostForm ...@@ -10,15 +10,15 @@ from .forms import ForumPostForm
def ForumViews(request): def ForumViews(request):
forum = ForumPost.objects.all() forum = ForumPost.objects.all()
context = {'forum':forum} context = {'forum':forum}
return render(request, 'forum.html', context) return render(request, 'forum/forum.html', context)
class ForumPostDetails(DetailView): class ForumPostDetails(DetailView):
template_name= "forumpost-details.html" template_name= "forum/forumpost-details.html"
model = ForumPost model = ForumPost
class ForumPostNew(CreateView): class ForumPostNew(CreateView):
form_class = ForumPostForm form_class = ForumPostForm
template_name = "forumpost-add.html" template_name = "forum/forumpost-add.html"
def get_success(self): def get_success(self):
return reverse('forum:forumpostnew', kwargs = {'pk': self.object.id}, return reverse('forum:forumpostnew', kwargs = {'pk': self.object.id},
...@@ -26,7 +26,7 @@ class ForumPostNew(CreateView): ...@@ -26,7 +26,7 @@ class ForumPostNew(CreateView):
class ForumPostEdit(UpdateView): class ForumPostEdit(UpdateView):
form_class = ForumPostForm form_class = ForumPostForm
template_name = "forumpost-edit.html" template_name = "forum/forumpost-edit.html"
queryset = ForumPost.objects.all() queryset = ForumPost.objects.all()
def get_success_url(self): 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