widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #12872
[Merge] lp:~widelands-dev/widelands-website/bug-1723640_news_current_user into lp:widelands-website
kaputtnik has proposed merging lp:~widelands-dev/widelands-website/bug-1723640_news_current_user into lp:widelands-website.
Requested reviews:
Widelands Developers (widelands-dev)
Related bugs:
Bug #1723640 in Widelands Website: "Select the current user in users list when posting news"
https://bugs.launchpad.net/widelands-website/+bug/1723640
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands-website/bug-1723640_news_current_user/+merge/341582
Use the current user as initial data for the author of a news post.
Fixes bug 1723640
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/bug-1723640_news_current_user into lp:widelands-website.
=== modified file 'news/admin.py'
--- news/admin.py 2016-12-13 18:28:51 +0000
+++ news/admin.py 2018-03-18 16:16:23 +0000
@@ -9,6 +9,12 @@
class PostAdmin(admin.ModelAdmin):
+
+ def get_changeform_initial_data(self, request):
+ # Set initial Data for the ForeignKey field to prevent
+ # digging through the users list
+ return {'author': request.user}
+
list_display = ('title', 'publish', 'status')
list_filter = ('publish', 'categories', 'status')
search_fields = ('title', 'body')
Follow ups