Commit 9dfd18a6 authored by Martin Lehoux's avatar Martin Lehoux

add correction

parent 24cf5c5c
......@@ -14,7 +14,7 @@ class PostCourseCommentForm(forms.ModelForm):
class PostDocumentForm(forms.ModelForm):
class Meta:
model = Document
fields=['name','course','file','description','type','documentDate']
fields=['name','course','file','description','type','documentDate','correction']
class PostCourseForm(forms.ModelForm):
class Meta:
......
......@@ -36,12 +36,12 @@ class Document(models.Model):
user = models.ForeignKey('User', on_delete=models.SET_NULL,null=True,blank=True)
course = models.ForeignKey('Course',on_delete=models.SET_NULL,null=True,blank=True)
file = models.FileField(upload_to='')
correction = models.FileField(upload_to='corrections/', blank=True, null=True)
type = models.CharField(
max_length=50,
choices=(
('Annale','Annale'),
('Fiche','Fiche'),
('Correction','Correction'),
('Poly de cours','Poly de cours'),
('Notes de cours', 'Notes de cours'),
),
......
......@@ -40,7 +40,11 @@
<input type="date" name="documentDate" id="documentDate">
</div>
<div class="field">
<input type="file" name="file"/>
<input type="file" name="file" required/>
</div>
<div class="field">
<label>Correction (facultatif)</label>
<input type="file" name="correction">
</div>
<div class="field">
<label for="course">Quel est le cours correspondant ?</label>
......
......@@ -286,6 +286,7 @@ def post_document(request):
file=form.files['file'],
type=form.cleaned_data['type'],
user=request.user,
correction=form.files.get('correction')
)
document.save()
request.messages.append({
......
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