From 25e74088b80285d48a17e334c9b012018b9c4d62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sascha=20I=C3=9Fbr=C3=BCcker?= Date: Sat, 6 Jul 2019 08:14:13 +0200 Subject: [PATCH] Simplify view naming --- bookmarks/urls.py | 18 +++++++++--------- bookmarks/views/api.py | 2 +- bookmarks/views/bookmarks.py | 12 ++++++------ bookmarks/views/settings.py | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/bookmarks/urls.py b/bookmarks/urls.py index dcfea83..16f825a 100644 --- a/bookmarks/urls.py +++ b/bookmarks/urls.py @@ -9,15 +9,15 @@ urlpatterns = [ # Redirect root to bookmarks index url(r'^$', RedirectView.as_view(pattern_name='bookmarks:index', permanent=False)), # Bookmarks - path('bookmarks', views.bookmarks_index, name='index'), - path('bookmarks/new', views.bookmarks_new, name='new'), - path('bookmarks/close', views.bookmarks_close, name='close'), - path('bookmarks//edit', views.bookmarks_edit, name='edit'), - path('bookmarks//remove', views.bookmarks_remove, name='remove'), - path('bookmarklet', views.bookmarks_bookmarklet, name='bookmarklet'), + path('bookmarks', views.bookmarks.index, name='index'), + path('bookmarks/new', views.bookmarks.new, name='new'), + path('bookmarks/close', views.bookmarks.close, name='close'), + path('bookmarks//edit', views.bookmarks.edit, name='edit'), + path('bookmarks//remove', views.bookmarks.remove, name='remove'), + path('bookmarklet', views.bookmarks.bookmarklet, name='bookmarklet'), # Settings - path('settings', views.settings_index, name='settings_index'), - path('settings/import', views.settings_bookmark_import, name='settings_import'), + path('settings', views.settings.index, name='settings_index'), + path('settings/import', views.settings.bookmark_import, name='settings_import'), # API - path('api/website_metadata', views.api.api_website_metadata, name='api.website_metadata'), + path('api/website_metadata', views.api.website_metadata, name='api.website_metadata'), ] diff --git a/bookmarks/views/api.py b/bookmarks/views/api.py index 6534cec..b4dd8fe 100644 --- a/bookmarks/views/api.py +++ b/bookmarks/views/api.py @@ -5,7 +5,7 @@ from bookmarks.services.website_loader import load_website_metadata @login_required -def api_website_metadata(request): +def website_metadata(request): url = request.GET.get('url') metadata = load_website_metadata(url) return JsonResponse(metadata.to_dict()) diff --git a/bookmarks/views/bookmarks.py b/bookmarks/views/bookmarks.py index a3946bb..581109c 100644 --- a/bookmarks/views/bookmarks.py +++ b/bookmarks/views/bookmarks.py @@ -12,7 +12,7 @@ _default_page_size = 30 @login_required -def bookmarks_index(request): +def index(request): page = request.GET.get('page') query_string = request.GET.get('q') query_set = queries.query_bookmarks(request.user, query_string) @@ -34,7 +34,7 @@ def bookmarks_index(request): @login_required -def bookmarks_new(request): +def new(request): initial_url = request.GET.get('url') initial_auto_close = 'auto_close' in request.GET @@ -59,7 +59,7 @@ def bookmarks_new(request): @login_required -def bookmarks_edit(request, bookmark_id: int): +def edit(request, bookmark_id: int): bookmark = Bookmark.objects.get(pk=bookmark_id) if request.method == 'POST': form = BookmarkForm(request.POST, instance=bookmark) @@ -74,19 +74,19 @@ def bookmarks_edit(request, bookmark_id: int): @login_required -def bookmarks_remove(request, bookmark_id: int): +def remove(request, bookmark_id: int): bookmark = Bookmark.objects.get(pk=bookmark_id) bookmark.delete() return HttpResponseRedirect(reverse('bookmarks:index')) @login_required -def bookmarks_bookmarklet(request): +def bookmarklet(request): return render(request, 'bookmarks/bookmarklet.html', { 'application_url': request.build_absolute_uri("/bookmarks/new") }) @login_required -def bookmarks_close(request): +def close(request): return render(request, 'bookmarks/close.html') diff --git a/bookmarks/views/settings.py b/bookmarks/views/settings.py index 7b844ed..5a166ed 100644 --- a/bookmarks/views/settings.py +++ b/bookmarks/views/settings.py @@ -8,7 +8,7 @@ from bookmarks.services.importer import import_netscape_html @login_required -def settings_index(request): +def index(request): import_message = _find_message_with_tag(messages.get_messages(request), 'bookmark_import') return render(request, 'settings/index.html', { 'import_message': import_message @@ -16,7 +16,7 @@ def settings_index(request): @login_required -def settings_bookmark_import(request): +def bookmark_import(request): try: import_file = request.FILES.get('import_file') content = import_file.read()