summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2023-07-20 08:42:11 -0500
committerluxagraf <sng@luxagraf.net>2023-07-20 08:42:11 -0500
commit30a7a279f51596aa5c03b1b62d7226b9ae734f94 (patch)
tree95f0009b5566be4d66bc9de5455d3e6051fd691f
parentd5710c7fa9b55c69c3415f2d9ef49ae63bee7d2e (diff)
posts: fixed a template bug in notes
-rw-r--r--app/posts/templates/posts/note_form.html2
-rw-r--r--app/posts/views.py5
2 files changed, 7 insertions, 0 deletions
diff --git a/app/posts/templates/posts/note_form.html b/app/posts/templates/posts/note_form.html
index 1ef1bd2..15797f2 100644
--- a/app/posts/templates/posts/note_form.html
+++ b/app/posts/templates/posts/note_form.html
@@ -15,10 +15,12 @@
</main>
{% endblock %}
{% block js %}
+ {% if is_update %}{%else%}
<script type="text/javascript">
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");
</script>
+{% endif %}
{% endblock%}
diff --git a/app/posts/views.py b/app/posts/views.py
index a26e53a..ae8b1e4 100644
--- a/app/posts/views.py
+++ b/app/posts/views.py
@@ -39,6 +39,11 @@ class NoteCreateView(CreateView):
class NoteUpdateView(UpdateView):
model = Note
fields = ['title', 'url', 'body_markdown', 'post']
+
+ def get_context_data(self, **kwargs):
+ context = super(NoteUpdateView, self).get_context_data(**kwargs)
+ context['is_update'] = True
+ return context
def get_success_url(self):
return reverse('posts:detail', kwargs={"pk": self.object.post.pk})