...
 
Commits (4)
# Generated by Django 2.1.8 on 2019-05-15 20:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('teaching', '0004_auto_20190313_1722'),
]
operations = [
migrations.AddField(
model_name='license',
name='code',
field=models.CharField(default='CC', max_length=80),
preserve_default=False,
),
migrations.AddField(
model_name='license',
name='description',
field=models.TextField(blank=True, null=True, verbose_name='Description'),
),
migrations.AddField(
model_name='license',
name='title',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AddField(
model_name='license',
name='url',
field=models.URLField(blank=True, null=True),
),
]
# Generated by Django 2.1.8 on 2019-05-16 07:43
from django.db import migrations
def move_license(apps, schema_editor):
"""Change name to code"""
License = apps.get_model("teaching", "License")
for lic in License.objects.all():
lic.code = lic.name[:79]
lic.title = lic.name
lic.save()
class Migration(migrations.Migration):
dependencies = [
('teaching', '0005_auto_20190515_2028'),
]
operations = [
migrations.RunPython(move_license),
]
......@@ -14,9 +14,13 @@ class Author(models.Model):
class License(models.Model):
"""Model for License"""
name = models.CharField(max_length=100)
code = models.CharField(max_length=80)
title = models.CharField(max_length=200, blank=True, null=True)
description = models.TextField('Description', blank=True, null=True)
url = models.URLField(max_length=200, blank=True, null=True)
def __str__(self):
return self.name
return self.code
class CourseMaterial(models.Model):
......
......@@ -10,18 +10,6 @@
<form method="post">
{% csrf_token %}
{% bootstrap_form form %}
<div class="form-group">
<label>Author</label>
<div class="form-item">
{{ object.author }}
</div>
</div>
<div class="form-group">
<label>License</label>
<div class="form-item">
{{ object.license }}
</div>
</div>
{% buttons %}
<div class="text-right">
<a href="{% url 'teaching:coursematerial-list' %}">
......
......@@ -24,8 +24,8 @@
</div>
<div class="card-footer small">
Licence :
{% if coursematerial.license %}
{{ coursematerial.license }}
{% if course.license %}
{{ course.license }}
{% else %}
Non libre
{% endif %}
......
......@@ -18,7 +18,7 @@ class CourseMaterialDetail(DetailView):
class CourseMaterialCreateView(CreateView):
"""CourseMaterial create view"""
model = CourseMaterial
fields = ("title", "description", "url")
fields = ("title", "description", "url", "author", "license")
template_name = 'teaching/coursematerial_form.html'
success_url = reverse_lazy('teaching:coursematerial-list')
......@@ -26,6 +26,6 @@ class CourseMaterialCreateView(CreateView):
class CourseMaterialUpdateView(UpdateView):
"""CourseMaterial create view"""
model = CourseMaterial
fields = ("title", "description", "url")
fields = ("title", "description", "url", "author", "license")
template_name = 'teaching/coursematerial_form.html'
success_url = reverse_lazy('teaching:coursematerial-list')