summaryrefslogtreecommitdiff
path: root/app/notes
diff options
context:
space:
mode:
Diffstat (limited to 'app/notes')
-rw-r--r--app/notes/admin.py10
-rw-r--r--app/notes/models.py9
-rw-r--r--app/notes/templates/note_form.html6
-rw-r--r--app/notes/templates/note_list.html3
-rw-r--r--app/notes/views.py7
5 files changed, 16 insertions, 19 deletions
diff --git a/app/notes/admin.py b/app/notes/admin.py
index 5409200..931e2e0 100644
--- a/app/notes/admin.py
+++ b/app/notes/admin.py
@@ -9,7 +9,7 @@ from .models import (
@admin.register(LuxNote)
class LuxNoteAdmin(admin.ModelAdmin):
- list_display = ('title', 'admin_link', 'date_created')
+ list_display = ('title', 'admin_link', 'date_created', 'admin_tags')
search_fields = ['title', 'description', 'url']
list_filter = [TagListFilter]
fieldsets = (
@@ -18,16 +18,10 @@ class LuxNoteAdmin(admin.ModelAdmin):
'title',
'url',
'description',
- 'body_markdown'
+ 'body_markdown',
'tags',
)
}),
- ('Details', {
- 'fields': (
- 'date_created ',
- ),
- 'classes': 'collapse'
- }),
)
class Media:
diff --git a/app/notes/models.py b/app/notes/models.py
index c0c88e8..76670f5 100644
--- a/app/notes/models.py
+++ b/app/notes/models.py
@@ -3,7 +3,7 @@ import datetime
from django.db import models
from django.urls import reverse
from django.utils import timezone
-from django.utils.html import format_html
+from django.utils.html import format_html, format_html_join
from taggit.managers import TaggableManager
from utils.util import markdown_to_html
@@ -37,5 +37,12 @@ class LuxNote(models.Model):
self.body_html = markdown_to_html(self.body_markdown)
super(LuxNote, self).save(*args, **kwargs)
+ def admin_tags(self):
+ return format_html_join(
+ '\n', "<a href='/admin/links/link?tag={}'>{}</a>,",
+ ((tag.slug, tag.name) for tag in self.tags.all())
+ )
+ admin_tags.short_description = 'Tags'
+
def get_absolute_url(self, *args, **kwargs):
return reverse('notes:note-edit', kwargs={"pk": self.pk})
diff --git a/app/notes/templates/note_form.html b/app/notes/templates/note_form.html
index 9c8ac37..3924d48 100644
--- a/app/notes/templates/note_form.html
+++ b/app/notes/templates/note_form.html
@@ -27,13 +27,11 @@ form .selector label {
{% endblock %}
{% block js %}
<script type="text/javascript">
-var options = {searchable: true};
-NiceSelect.bind(document.getElementById("id_project"), options);
- {% if is_update %}{%else%}
+{% if is_update %}{%else%}
let params = new URL(document.location).searchParams;
document.getElementById('id_title').value = params.get("title");
document.getElementById('id_url').value = params.get("url");
-document.getElementById('id_body_markdown').value = params.get("description");
+document.getElementById('id_description').value = params.get("description");
{% endif %}
</script>
{% endblock%}
diff --git a/app/notes/templates/note_list.html b/app/notes/templates/note_list.html
index 1439f4a..e262558 100644
--- a/app/notes/templates/note_list.html
+++ b/app/notes/templates/note_list.html
@@ -18,7 +18,8 @@
<h2>{% if object.url %}<a href="{{object.url}}">{{object.title}}</a>{%else%}{{object.title}}{%endif%} <span class="note-edit"><a href="{%url 'notes:note-edit' object.id %}">edit</a></span></h2>
<p>{{object.description}}</p>
{% if object.project %}<p class="small">For: <a href="{% url 'notes:project-detail' object.project.id %}">{{object.project}}</a></p>{%endif%}
- <p class="small"><a href="{% url 'notes:note-detail' object.pk %}">View local</a></p>
+ <p class="note-edit">TAGS: {% for tag in object.tags.all %}<a href="/notes/?tag={{tag}}">{{tag}}</a>, {%endfor%}</p>
+ <p class="note-edit"><a href="{% url 'notes:note-detail' object.pk %}">View local</a></p>
<p class="small"><a href="{% url 'notes:note-delete' object.pk %}">delete</a></p>
</article>
{% endfor%}</div>
diff --git a/app/notes/views.py b/app/notes/views.py
index 984af9a..53811d0 100644
--- a/app/notes/views.py
+++ b/app/notes/views.py
@@ -25,10 +25,7 @@ class LuxNoteCreateView(CreateView):
if 'add_new' in self.request.POST:
return reverse('notes:note-create')
else:
- if self.object.project:
- return reverse('notes:project-detail', kwargs={"pk": self.object.project.pk})
- else:
- return reverse('notes:note-create')
+ return reverse('notes:note-create')
class LuxNoteUpdateView(UpdateView):
@@ -65,7 +62,7 @@ class LuxNoteListView(ListView):
class LuxNoteDeleteView(DeleteView):
# specify the model you want to use
model = LuxNote
- success_url = "/notes"
+ success_url = "/notes/"
template_name = "confirm_delete.html"