File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -169,7 +169,9 @@ class Meta:
169
169
170
170
@property
171
171
def has_notes (self ):
172
- return self .instance and self .instance .notes
172
+ return self .initial .get ("notes" , None ) or (
173
+ self .instance and self .instance .notes
174
+ )
173
175
174
176
175
177
class BookmarkSearch :
Original file line number Diff line number Diff line change @@ -100,6 +100,29 @@ def test_should_prefill_description_from_url_parameter(self):
100
100
html ,
101
101
)
102
102
103
+ def test_should_prefill_notes_from_url_parameter (self ):
104
+ response = self .client .get (
105
+ reverse ("bookmarks:new" )
106
+ + "?notes=%2A%2AFind%2A%2A%20more%20info%20%5Bhere%5D%28http%3A%2F%2Fexample.com%29"
107
+ )
108
+ html = response .content .decode ()
109
+
110
+ self .assertInHTML (
111
+ """
112
+ <details class="notes" open="">
113
+ <summary>
114
+ <span class="form-label d-inline-block">Notes</span>
115
+ </summary>
116
+ <label for="id_notes" class="text-assistive">Notes</label>
117
+ <textarea name="notes" cols="40" rows="8" class="form-input" id="id_notes">**Find** more info [here](http://example.com)</textarea>
118
+ <div class="form-input-hint">
119
+ Additional notes, supports Markdown.
120
+ </div>
121
+ </details>
122
+ """ ,
123
+ html ,
124
+ )
125
+
103
126
def test_should_enable_auto_close_when_specified_in_url_parameter (self ):
104
127
response = self .client .get (reverse ("bookmarks:new" ) + "?auto_close" )
105
128
html = response .content .decode ()
Original file line number Diff line number Diff line change @@ -192,6 +192,7 @@ def new(request):
192
192
initial_url = request .GET .get ("url" )
193
193
initial_title = request .GET .get ("title" )
194
194
initial_description = request .GET .get ("description" )
195
+ initial_notes = request .GET .get ("notes" )
195
196
initial_auto_close = "auto_close" in request .GET
196
197
initial_mark_unread = request .user .profile .default_mark_unread
197
198
@@ -214,6 +215,8 @@ def new(request):
214
215
form .initial ["title" ] = initial_title
215
216
if initial_description :
216
217
form .initial ["description" ] = initial_description
218
+ if initial_notes :
219
+ form .initial ["notes" ] = initial_notes
217
220
if initial_auto_close :
218
221
form .initial ["auto_close" ] = "true"
219
222
if initial_mark_unread :
You can’t perform that action at this time.
0 commit comments