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

Commit

Permalink
Make note titles non-unique and OK to be blank
Browse files Browse the repository at this point in the history
  • Loading branch information
ptgolden committed Oct 4, 2016
1 parent 722ab4f commit bd2c3d4
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 5 deletions.
24 changes: 24 additions & 0 deletions editorsnotes/main/migrations/0027_auto_20160926_1311.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.4 on 2016-09-26 13:11
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main', '0026_auto_20160926_1237'),
]

operations = [
migrations.AlterField(
model_name='note',
name='title',
field=models.CharField(blank=True, help_text='The title of the note (optional).', max_length=200),
),
migrations.AlterUniqueTogether(
name='note',
unique_together=set([]),
),
]
8 changes: 3 additions & 5 deletions editorsnotes/main/models/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ class Note(LastUpdateMetadata, Administered, URLAccessible, ENMarkup,
enables.
"""
title = models.CharField(
max_length=80,
max_length=200,
blank=True,
help_text=(
'The title of the note.'
'The title of the note (optional).'
)
)

Expand Down Expand Up @@ -78,9 +79,6 @@ class Meta:
permissions = (
('view_private_note', 'Can view notes private to a project.'),
)
unique_together = (
('title', 'project'),
)

def as_text(self):
return self.title
Expand Down
20 changes: 20 additions & 0 deletions editorsnotes/main/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,26 @@ def testAssignTopics(self):
self.assertEqual(1, len(topic.assignments.all()))
self.assertEqual(topic, note.related_topics.all()[0].topic)

def testEmptyTitle(self):
empty_title = main_models.Note.objects.create(
creator=self.user, last_updater=self.user, project=self.project
)

self.assertEqual(empty_title.title, '')

def testDuplicateTitle(self):
title1 = main_models.Note.objects.create(
title='example',
creator=self.user, last_updater=self.user, project=self.project
)

title2 = main_models.Note.objects.create(
title='example',
creator=self.user, last_updater=self.user, project=self.project
)

self.assertEqual(title1.title, title2.title)


class DocumentTestCase(TestCase):
fixtures = ['projects.json']
Expand Down

0 comments on commit bd2c3d4

Please sign in to comment.