SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit a42c459d authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Basic views

parent 65465a6b
No related branches found
No related tags found
No related merge requests found
...@@ -46,6 +46,7 @@ urlpatterns = [ ...@@ -46,6 +46,7 @@ urlpatterns = [
url(r'^commentaries/', include('commentaries.urls', namespace="commentaries")), url(r'^commentaries/', include('commentaries.urls', namespace="commentaries")),
url(r'^commentary/', include('commentaries.urls', namespace="_commentaries")), url(r'^commentary/', include('commentaries.urls', namespace="_commentaries")),
url(r'^comments/', include('comments.urls', namespace="comments")), url(r'^comments/', include('comments.urls', namespace="comments")),
url(r'^forums/', include('forums.urls', namespace="forums")),
url(r'^funders/', include('funders.urls', namespace="funders")), url(r'^funders/', include('funders.urls', namespace="funders")),
url(r'^finances/', include('finances.urls', namespace="finances")), url(r'^finances/', include('finances.urls', namespace="finances")),
url(r'^guides/', include('guides.urls', namespace="guides")), url(r'^guides/', include('guides.urls', namespace="guides")),
......
...@@ -4,6 +4,7 @@ __license__ = "AGPL v3" ...@@ -4,6 +4,7 @@ __license__ = "AGPL v3"
from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.models import ContentType
from django.core.urlresolvers import reverse
from django.db import models from django.db import models
from django.utils import timezone from django.utils import timezone
...@@ -47,6 +48,9 @@ class Forum(models.Model): ...@@ -47,6 +48,9 @@ class Forum(models.Model):
def __str__(self): def __str__(self):
return self.slug return self.slug
def get_absolute_url(self):
return reverse('forums:forum_detail', kwargs={'slug': self.slug})
class Post(models.Model): class Post(models.Model):
""" """
......
from django.shortcuts import render __copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
# Create your views here.
from django.core.urlresolvers import reverse_lazy
from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView
from django.views.generic.list import ListView
from .models import Forum
from .forms import ForumForm
from scipost.mixins import PermissionsMixin
class ForumCreateView(PermissionsMixin, CreateView):
permission_required = 'forums.can_add_forum'
model = Forum
form_class = ForumForm
template_name = 'forums/forum_form.html'
success_url = reverse_lazy('forums:forums')
def get_initial(self):
initial = super().get_initial()
initial.update({
'moderators': self.request.user
})
return initial
class ForumDetailView(DetailView):
model = Forum
template_name = 'forums/forum_detail.html'
class ForumListView(ListView):
model = Forum
template_name = 'forum_list.html'
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment