Use the name field from the materials upload form. Fixes ticket #1445. Commit ready for merge.

- Legacy-Id: 8099
This commit is contained in:
Robert Sparks 2014-07-16 14:47:39 +00:00
parent dac3efcb68
commit 4de405e8d3
2 changed files with 3 additions and 7 deletions

View file

@ -65,7 +65,7 @@ class GroupMaterialTests(TestCase):
test_file.seek(0)
# post
r = self.client.post(url, dict(title="Test File",
r = self.client.post(url, dict(title="Test File - with fancy title",
name="slides-%s-test-file" % group.acronym,
state=State.objects.get(type="slides", slug="active").pk,
material=test_file))
@ -73,7 +73,7 @@ class GroupMaterialTests(TestCase):
doc = Document.objects.get(name="slides-%s-test-file" % group.acronym)
self.assertEqual(doc.rev, "00")
self.assertEqual(doc.title, "Test File")
self.assertEqual(doc.title, "Test File - with fancy title")
self.assertEqual(doc.get_state_slug(), "active")
with open(os.path.join(self.materials_dir, "slides", doc.name + "-" + doc.rev + ".pdf")) as f:

View file

@ -7,7 +7,6 @@ from django import forms
from django.shortcuts import render, get_object_or_404, redirect
from django.http import HttpResponseForbidden, Http404
from django.utils.html import mark_safe
from django.utils.text import slugify
from django.contrib.auth.decorators import login_required
from django.core.urlresolvers import reverse as urlreverse
@ -30,9 +29,6 @@ def choose_material_type(request, acronym):
'material_types': DocTypeName.objects.filter(slug__in=group.features.material_types),
})
def name_for_material(doc_type, group, title):
return "%s-%s-%s" % (doc_type.slug, group.acronym, slugify(title))
class UploadMaterialForm(forms.Form):
title = forms.CharField(max_length=Document._meta.get_field("title").max_length)
name = forms.CharField(max_length=Document._meta.get_field("name").max_length)
@ -112,7 +108,7 @@ def edit_material(request, name=None, acronym=None, action=None, doc_type=None):
doc.type = document_type
doc.group = group
doc.rev = "00"
doc.name = name_for_material(doc.type, doc.group, form.cleaned_data["title"])
doc.name = form.cleaned_data["name"]
prev_rev = None
else:
save_document_in_history(doc)