File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed
Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ <h2>Add Work</h2>
2828 < label for ="selector-work-author "> Author</ label >
2929 < select id ="select-work-author " name ="work_author ">
3030 {% for author in authors %}
31- < option value ="{{ author.id }} "> {{ author.name }}</ option >
31+ < option value ="{{ author.id }} " {% if author.last_created %}selected{% endif %} > {{ author.name }}</ option >
3232 {% endfor %}
3333 </ select >
3434 </ p >
@@ -56,7 +56,7 @@ <h2>Add Quote</h2>
5656 < label for ="input-work "> Work</ label >
5757 < select id ="input-work " name ="quote_work ">
5858 {% for work in works %}
59- < option value ="{{ work.id }} "> {{ work.author.name }} – {{ work.title }}</ option >
59+ < option value ="{{ work.id }} " {% if work.last_created %}selected{% endif %} > {{ work.author.name }} – {{ work.title }}</ option >
6060 {% endfor %}
6161 </ select >
6262 </ p >
Original file line number Diff line number Diff line change @@ -481,6 +481,13 @@ def view_quote(request, qid):
481481 })
482482
483483
484+ def set_last_attribute (items : list [models .Author | models .Work ]):
485+ dates = [item .date_creation for item in items ]
486+ last = max (dates )
487+ for item in items :
488+ item .last_created = item .date_creation == last
489+
490+
484491@permission_required ("orgapy.add_quote" )
485492def view_create_quote (request ):
486493 if request .method == "POST" :
@@ -501,8 +508,10 @@ def view_create_quote(request):
501508 add_quote (request , work_id , request .POST .get ("quote_content" ).strip ())
502509 if "form_quote" in request .POST :
503510 return redirect ("orgapy:quotes_search" )
504- authors = models .Author .objects .filter (user = request .user ).order_by ("-date_creation" )
505- works = models .Work .objects .filter (user = request .user ).order_by ("-date_creation" )
511+ authors = models .Author .objects .filter (user = request .user ).order_by ("name" )
512+ set_last_attribute (authors )
513+ works = models .Work .objects .filter (user = request .user ).order_by ("author__name" , "title" )
514+ set_last_attribute (works )
506515 return render (request , "orgapy/create_quote.html" , {
507516 "authors" : authors ,
508517 "works" : works ,
You can’t perform that action at this time.
0 commit comments