pedagogy: basic uv detail view

This commit is contained in:
Antoine Bartuccio 2019-06-16 02:19:56 +02:00
parent ab344ba02f
commit 1172402166
Signed by: klmp200
GPG Key ID: E7245548C53F904B
3 changed files with 30 additions and 4 deletions

View File

@ -27,7 +27,7 @@ from django import forms
from core.views.forms import MarkdownInput from core.views.forms import MarkdownInput
from core.models import User from core.models import User
from pedagogy.models import UV from pedagogy.models import UV, UVComment
class UVForm(forms.ModelForm): class UVForm(forms.ModelForm):
@ -68,3 +68,13 @@ class UVForm(forms.ModelForm):
super(UVForm, self).__init__(*args, **kwargs) super(UVForm, self).__init__(*args, **kwargs)
self.fields["author"].queryset = User.objects.filter(id=author_id).all() self.fields["author"].queryset = User.objects.filter(id=author_id).all()
self.fields["author"].initial = author_id self.fields["author"].initial = author_id
class UVCommentForm(forms.ModelForm):
"""
Form handeling creation and edit of an UVComment
"""
class Meta:
model = UVComment
fields = ()

View File

@ -0,0 +1,13 @@
{% extends "core/base.jinja" %}
{% block title %}
{% trans %}UV Details{% endtrans %}
{% endblock %}
{% block content %}
<h1>{{ object.code }} - {{ object.title }}</h1>
<p>{{ object.objectives|markdown }}</p>
<p>{{ object.program|markdown }}</p>
<p>{{ object.skills|markdown }}</p>
<p>{{ object.key_concepts|markdown }}</p>
{% endblock %}

View File

@ -41,7 +41,7 @@ from core.views import (
CanEditPropMixin, CanEditPropMixin,
) )
from pedagogy.forms import UVForm from pedagogy.forms import UVForm, UVCommentForm
from pedagogy.models import UV from pedagogy.models import UV
# Some mixins # Some mixins
@ -71,13 +71,16 @@ class CanCreateUVFunctionMixin(View):
# Acutal views # Acutal views
class UVDetailFormView(DetailFormView): class UVDetailFormView(CanViewMixin, CanCreateUVFunctionMixin, DetailFormView):
""" """
Dispaly every comment of an UV and detailed infos about it Dispaly every comment of an UV and detailed infos about it
Allow to comment the UV Allow to comment the UV
""" """
pass model = UV
pk_url_kwarg = "uv_id"
template_name = "pedagogy/uv_detail.jinja"
form_class = UVCommentForm
class UVCommentDetailView(DetailView): class UVCommentDetailView(DetailView):