From: Colin Powell Date: Sat, 30 Apr 2011 03:57:17 +0000 (-0400) Subject: A catch up commit, as I was getting lazy. X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=5eb8353f2fbf139dc5a5ce82a54f4c7373a3e512;p=django-notes.git A catch up commit, as I was getting lazy. --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7e99e36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc \ No newline at end of file diff --git a/notes/__init__.py b/notes/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/notes/admin.py b/notes/admin.py index 1c197ad..4c8022e 100644 --- a/notes/admin.py +++ b/notes/admin.py @@ -1,5 +1,8 @@ -from notes.models import Note +from notes.models import Note, Topic +from django.contrib import admin from django.contrib.contenttypes import generic class NoteInline(generic.GenericTabularInline): model = Note + +admin.site.register(Topic) diff --git a/notes/forms.py b/notes/forms.py new file mode 100644 index 0000000..f9d0e38 --- /dev/null +++ b/notes/forms.py @@ -0,0 +1,8 @@ +from django.forms import ModelForm +from notes.models import Note + +class NoteForm(ModelForm): + class Meta: + model = Note + fields=['content', 'markup', 'topic','date', 'public'] + diff --git a/notes/models.py b/notes/models.py index 35ed321..13a653c 100644 --- a/notes/models.py +++ b/notes/models.py @@ -3,6 +3,7 @@ from django.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic from django.contrib.auth.models import User +from django.utils.translation import ugettext_lazy as _ from myutils.models import MarkupMixin from django_extensions.db.models import TitleSlugDescriptionModel, TimeStampedModel @@ -13,18 +14,25 @@ class Topic(TitleSlugDescriptionModel, TimeStampedModel): Topic model class. """ + class Meta: + verbose_name = _('Topic') + verbose_name_plural = _('Topics') + + def __unicode__(self): + return self.title + class Note(MarkupMixin, TimeStampedModel): """ Note model class. A simple model to handle adding arbitrary numbers of notes to an animal profile. """ - topic=models.models.ForeignKey(Topic) - date=models.DateField(_('Date'), auto_now=True) + topic=models.ForeignKey(Topic) + date=models.DateField(_('Date'), default=datetime.now()) content=models.TextField(_('Content')) - rendered_content=models.TextField(_('Rendered content'), blank=True, null=True) + rendered_content=models.TextField(_('Rendered content'), blank=True, null=True, editable=False) public=models.BooleanField(_('Public'), default=True) - author=models.ForeignKey(User) + author=models.ForeignKey(User, blank=True, null=True) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey("content_type", "object_id") @@ -38,3 +46,5 @@ class Note(MarkupMixin, TimeStampedModel): class MarkupOptions: rendered_field = 'rendered_content' source_field = 'content' + +