diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index 77aae6f7d..8ba5bb468 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -1,6 +1,6 @@ class ArtistsController < ApplicationController respond_to :html, :xml, :json - before_filter :member_only, :except => [:index, :show, :banned] + before_filter :member_only, :except => [:index, :show, :show_or_new, :banned] before_filter :builder_only, :only => [:destroy] before_filter :admin_only, :only => [:ban, :unban] before_filter :load_artist, :only => [:ban, :unban, :show, :edit, :update, :destroy, :undelete] @@ -93,7 +93,9 @@ class ArtistsController < ApplicationController if @artist redirect_to artist_path(@artist) else - redirect_to new_artist_path(:name => params[:name]) + @artist = Artist.new(name: params[:name]) + @post_set = PostSets::Artist.new(@artist) + respond_with(@artist) end end diff --git a/app/controllers/bulk_update_requests_controller.rb b/app/controllers/bulk_update_requests_controller.rb index 57214efe6..49b6be349 100644 --- a/app/controllers/bulk_update_requests_controller.rb +++ b/app/controllers/bulk_update_requests_controller.rb @@ -1,6 +1,6 @@ class BulkUpdateRequestsController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only + before_filter :member_only, :except => [:index, :show] before_filter :admin_only, :only => [:approve] before_filter :load_bulk_update_request, :except => [:new, :create, :index] diff --git a/app/controllers/dmails_controller.rb b/app/controllers/dmails_controller.rb index 3a27011af..1ffc2abf5 100644 --- a/app/controllers/dmails_controller.rb +++ b/app/controllers/dmails_controller.rb @@ -1,6 +1,6 @@ class DmailsController < ApplicationController respond_to :html, :xml, :json - before_filter :member_only + before_filter :member_only, except: [:index, :show, :destroy, :mark_all_as_read] def new if params[:respond_to_id] diff --git a/app/controllers/favorites_controller.rb b/app/controllers/favorites_controller.rb index 2623cee9c..895b9c32e 100644 --- a/app/controllers/favorites_controller.rb +++ b/app/controllers/favorites_controller.rb @@ -1,5 +1,5 @@ class FavoritesController < ApplicationController - before_filter :member_only + before_filter :member_only, except: [:index] respond_to :html, :xml, :json skip_before_filter :api_check diff --git a/app/controllers/forum_posts_controller.rb b/app/controllers/forum_posts_controller.rb index e3970036a..c69c61a7b 100644 --- a/app/controllers/forum_posts_controller.rb +++ b/app/controllers/forum_posts_controller.rb @@ -1,6 +1,6 @@ class ForumPostsController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only, :except => [:index, :show] + before_filter :member_only, :except => [:index, :show, :search] before_filter :load_post, :only => [:edit, :show, :update, :destroy, :undelete] before_filter :check_min_level, :only => [:edit, :show, :update, :destroy, :undelete] skip_before_filter :api_check diff --git a/app/controllers/iqdb_queries_controller.rb b/app/controllers/iqdb_queries_controller.rb index e5b88b425..abd23e002 100644 --- a/app/controllers/iqdb_queries_controller.rb +++ b/app/controllers/iqdb_queries_controller.rb @@ -1,6 +1,5 @@ # todo: move this to iqdbs class IqdbQueriesController < ApplicationController - before_filter :member_only respond_to :html, :json, :xml def index diff --git a/app/controllers/maintenance/user/api_keys_controller.rb b/app/controllers/maintenance/user/api_keys_controller.rb index 8f4844be4..e29330524 100644 --- a/app/controllers/maintenance/user/api_keys_controller.rb +++ b/app/controllers/maintenance/user/api_keys_controller.rb @@ -1,7 +1,6 @@ module Maintenance module User class ApiKeysController < ApplicationController - before_filter :member_only before_filter :check_privilege before_filter :authenticate!, :except => [:show] rescue_from ::SessionLoader::AuthenticationFailure, :with => :authentication_failed diff --git a/app/controllers/maintenance/user/dmail_filters_controller.rb b/app/controllers/maintenance/user/dmail_filters_controller.rb index f5a0ce855..040d5e532 100644 --- a/app/controllers/maintenance/user/dmail_filters_controller.rb +++ b/app/controllers/maintenance/user/dmail_filters_controller.rb @@ -2,7 +2,6 @@ module Maintenance module User class DmailFiltersController < ApplicationController before_filter :ensure_ownership - before_filter :member_only respond_to :html, :json, :xml def edit diff --git a/app/controllers/notes_controller.rb b/app/controllers/notes_controller.rb index bed70f667..d4648a971 100644 --- a/app/controllers/notes_controller.rb +++ b/app/controllers/notes_controller.rb @@ -1,6 +1,6 @@ class NotesController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only, :except => [:index, :show] + before_filter :member_only, :except => [:index, :show, :search] def search end diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index afd255094..95478709b 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -1,5 +1,5 @@ class ReportsController < ApplicationController - before_filter :member_only + before_filter :member_only, :except => [:upload_tags] before_filter :gold_only, :only => [:similar_users] before_filter :moderator_only, :only => [:post_versions, :post_versions_create] diff --git a/app/controllers/saved_searches_controller.rb b/app/controllers/saved_searches_controller.rb index 83d02d062..67c41c4c7 100644 --- a/app/controllers/saved_searches_controller.rb +++ b/app/controllers/saved_searches_controller.rb @@ -1,5 +1,4 @@ class SavedSearchesController < ApplicationController - before_filter :member_only before_filter :check_availability respond_to :html, :xml, :json, :js diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 66207db1c..d2228ac30 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -1,5 +1,5 @@ class UploadsController < ApplicationController - before_filter :member_only + before_filter :member_only, except: [:index, :show] respond_to :html, :xml, :json, :js def new diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index d501df51f..b837dc652 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,6 +1,5 @@ class UsersController < ApplicationController respond_to :html, :xml, :json - before_filter :member_only, :only => [:edit, :update] skip_before_filter :api_check def new diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb index 213aefb29..ae707acc9 100644 --- a/app/controllers/wiki_pages_controller.rb +++ b/app/controllers/wiki_pages_controller.rb @@ -1,6 +1,6 @@ class WikiPagesController < ApplicationController respond_to :html, :xml, :json, :js - before_filter :member_only, :except => [:index, :show, :show_or_new] + before_filter :member_only, :except => [:index, :search, :show, :show_or_new] before_filter :builder_only, :only => [:destroy] before_filter :normalize_search_params, :only => [:index] @@ -32,6 +32,9 @@ class WikiPagesController < ApplicationController end end + def search + end + def show if params[:id] =~ /\A\d+\Z/ @wiki_page = WikiPage.find(params[:id]) diff --git a/app/views/artists/_show.html.erb b/app/views/artists/_show.html.erb new file mode 100644 index 000000000..d36f490f6 --- /dev/null +++ b/app/views/artists/_show.html.erb @@ -0,0 +1,28 @@ +
+
+

Artist: <%= link_to @artist.pretty_name, posts_path(:tags => @artist.name), :class => "tag-type-#{@artist.category_name}" %>

+ + <% if @artist.notes.present? && @artist.visible? %> +
+ <%= format_text(@artist.notes, :ragel => true, :disable_mentions => true) %> +
+ +

<%= link_to "View wiki page", @artist.wiki_page %>

+ <% end %> + + <%= yield %> + +
+

Recent Posts

+
+ <%= @post_set.presenter.post_previews_html(self) %> +
+
+ + <%= render "secondary_links" %> +
+
+ +<% content_for(:page_title) do %> + Artist - <%= @artist.name %> - <%= Danbooru.config.app_name %> +<% end %> diff --git a/app/views/artists/show.html.erb b/app/views/artists/show.html.erb index 94a0c1125..f07270296 100644 --- a/app/views/artists/show.html.erb +++ b/app/views/artists/show.html.erb @@ -1,35 +1,9 @@ -
-
-

Artist: <%= link_to @artist.pretty_name, posts_path(:tags => @artist.name), :class => "tag-type-#{@artist.category_name}" %>

- - <% if @artist.notes.present? && @artist.visible? %> -
- <%= format_text(@artist.notes, :ragel => true, :disable_mentions => true) %> -
- -

<%= link_to "View wiki page", @artist.wiki_page %>

- <% end %> - - <% if @artist.visible? %> -
- <%= render "summary", artist: @artist %> -
- - <% else %> -

The artist requested removal of this page.

- <% end %> - -
-

Recent Posts

-
- <%= @post_set.presenter.post_previews_html(self) %> -
+<%= render layout: "show" do %> + <% if @artist.visible? %> +
+ <%= render "summary", artist: @artist %>
- - <%= render "secondary_links" %> -
-
- -<% content_for(:page_title) do %> - Artist - <%= @artist.name %> - <%= Danbooru.config.app_name %> + <% else %> +

The artist requested removal of this page.

+ <% end %> <% end %> diff --git a/app/views/artists/show_or_new.html.erb b/app/views/artists/show_or_new.html.erb new file mode 100644 index 000000000..221f69869 --- /dev/null +++ b/app/views/artists/show_or_new.html.erb @@ -0,0 +1,5 @@ +<%= render layout: "show" do %> +
+

This artist entry does not exist. <%= link_to "Create new artist entry", new_artist_path(name: params[:name]) %>.

+
+<% end %> diff --git a/test/functional/artists_controller_test.rb b/test/functional/artists_controller_test.rb index 362a66f0d..db3c4ec67 100644 --- a/test/functional/artists_controller_test.rb +++ b/test/functional/artists_controller_test.rb @@ -42,7 +42,7 @@ class ArtistsControllerTest < ActionController::TestCase assert_redirected_to(@masao) get :show_or_new, { name: "nobody" }, { user_id: @user.id } - assert_redirected_to(new_artist_path(name: "nobody")) + assert_response :success end should "get the edit page" do diff --git a/test/functional/dmails_controller_test.rb b/test/functional/dmails_controller_test.rb index a697a0b75..1c9c74f0e 100644 --- a/test/functional/dmails_controller_test.rb +++ b/test/functional/dmails_controller_test.rb @@ -62,6 +62,13 @@ class DmailsControllerTest < ActionController::TestCase assert_response :success assert_equal(0, assigns[:dmails].size) end + + should "work for banned users" do + ban = FactoryGirl.create(:ban, :user => @user, :banner => FactoryGirl.create(:admin_user)) + get :index, {:search => {:owner_id => @dmail.owner_id, :folder => "sent"}}, {:user_id => @dmail.owner_id} + + assert_response :success + end end context "show action" do diff --git a/test/functional/users_controller_test.rb b/test/functional/users_controller_test.rb index 77fe9b81f..76e56dc16 100644 --- a/test/functional/users_controller_test.rb +++ b/test/functional/users_controller_test.rb @@ -124,6 +124,15 @@ class UsersControllerTest < ActionController::TestCase assert_equal(20, @user.level) end end + + context "for a banned user" do + should "allow the user to edit their settings" do + @user = FactoryGirl.create(:banned_user) + post :update, {:id => @user.id, :user => {:favorite_tags => "xyz"}}, {:user_id => @user.id} + + assert_equal("xyz", @user.reload.favorite_tags) + end + end end end end