diff options
Diffstat (limited to 'app/notes')
-rw-r--r-- | app/notes/forms.py | 5 | ||||
-rw-r--r-- | app/notes/templates/notes/note_form.html | 1 | ||||
-rw-r--r-- | app/notes/templates/notes/note_list.html | 3 |
3 files changed, 8 insertions, 1 deletions
diff --git a/app/notes/forms.py b/app/notes/forms.py index 5cde108..4342b89 100644 --- a/app/notes/forms.py +++ b/app/notes/forms.py @@ -7,9 +7,14 @@ class NoteCreateForm(ModelForm): def __init__(self,*args,**kwargs): user = kwargs.pop('user') + self.user = user super(NoteCreateForm,self).__init__(*args,**kwargs) self.fields['post'].queryset = Post.objects.filter(user=user).order_by("title") + def save(self, commit=True): + self.instance.user = self.user + return super().save(commit=commit) + class Meta: model = Note fields = ['title', 'url', 'body_markdown', 'post'] diff --git a/app/notes/templates/notes/note_form.html b/app/notes/templates/notes/note_form.html index 10d81ac..48ccde1 100644 --- a/app/notes/templates/notes/note_form.html +++ b/app/notes/templates/notes/note_form.html @@ -4,7 +4,6 @@ <form action="" method="post" class="comment-form">{% csrf_token %} {% for field in form %} <fieldset> - {%if field.name == "post" or field.name == "status" %}<span class="selector">{{field.label_tag}}</span>{%else%}{{field.label_tag}}{%endif%} {%if field.name == "body_markdown"%}<div class="textarea-rounded">{{ field }}</div>{%else%}{{field}}{%endif%} </fieldset> diff --git a/app/notes/templates/notes/note_list.html b/app/notes/templates/notes/note_list.html index c4d287c..2c74335 100644 --- a/app/notes/templates/notes/note_list.html +++ b/app/notes/templates/notes/note_list.html @@ -1,6 +1,9 @@ {% extends 'base.html' %} {% block primary %} <main class="post-detail"> + <div class="post-header"> + <a href="/notes/create" class="btn">New Note</a> + </div> <div class="note-list">{% for object in object_list %}<article> <h2>{%if object.url%}<a href="{{object.url}}">{{object.title}}</a>{%else%}{{object.title}}{%endif%}<span class="note-edit"><a href="{{object.get_absolute_url}}">edit</a></span></h2> <p>{{object.body_markdown}}</p> |