Skip to content
This repository was archived by the owner on Jun 1, 2022. It is now read-only.

Commit bd2c3d4

Browse files
committed
Make note titles non-unique and OK to be blank
1 parent 722ab4f commit bd2c3d4

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.9.4 on 2016-09-26 13:11
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
dependencies = [
11+
('main', '0026_auto_20160926_1237'),
12+
]
13+
14+
operations = [
15+
migrations.AlterField(
16+
model_name='note',
17+
name='title',
18+
field=models.CharField(blank=True, help_text='The title of the note (optional).', max_length=200),
19+
),
20+
migrations.AlterUniqueTogether(
21+
name='note',
22+
unique_together=set([]),
23+
),
24+
]

editorsnotes/main/models/notes.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ class Note(LastUpdateMetadata, Administered, URLAccessible, ENMarkup,
2626
enables.
2727
"""
2828
title = models.CharField(
29-
max_length=80,
29+
max_length=200,
30+
blank=True,
3031
help_text=(
31-
'The title of the note.'
32+
'The title of the note (optional).'
3233
)
3334
)
3435

@@ -78,9 +79,6 @@ class Meta:
7879
permissions = (
7980
('view_private_note', 'Can view notes private to a project.'),
8081
)
81-
unique_together = (
82-
('title', 'project'),
83-
)
8482

8583
def as_text(self):
8684
return self.title

editorsnotes/main/tests/models.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,26 @@ def testAssignTopics(self):
3838
self.assertEqual(1, len(topic.assignments.all()))
3939
self.assertEqual(topic, note.related_topics.all()[0].topic)
4040

41+
def testEmptyTitle(self):
42+
empty_title = main_models.Note.objects.create(
43+
creator=self.user, last_updater=self.user, project=self.project
44+
)
45+
46+
self.assertEqual(empty_title.title, '')
47+
48+
def testDuplicateTitle(self):
49+
title1 = main_models.Note.objects.create(
50+
title='example',
51+
creator=self.user, last_updater=self.user, project=self.project
52+
)
53+
54+
title2 = main_models.Note.objects.create(
55+
title='example',
56+
creator=self.user, last_updater=self.user, project=self.project
57+
)
58+
59+
self.assertEqual(title1.title, title2.title)
60+
4161

4262
class DocumentTestCase(TestCase):
4363
fixtures = ['projects.json']

0 commit comments

Comments
 (0)