From c5bf7b6c476b1c9045ae731cd7bc9dfdded5c854 Mon Sep 17 00:00:00 2001 From: albert Date: Tue, 9 Apr 2013 18:15:04 -0400 Subject: [PATCH] fixes #1241 --- app/controllers/static_controller.rb | 5 +++++ app/views/layouts/default.html.erb | 2 +- app/views/static/terms_of_service.html.erb | 5 +++++ app/views/users/_tos.html.erb | 2 +- config/routes.rb | 1 + 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb index a018f9874..031df4706 100644 --- a/app/controllers/static_controller.rb +++ b/app/controllers/static_controller.rb @@ -1,6 +1,11 @@ class StaticController < ApplicationController def terms_of_service end + + def accept_terms_of_service + cookies.permanent[:accepted_tos] = "1" + redirect_to(params[:url] || posts_path) + end def error end diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index 479681eac..97620c8ba 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -44,7 +44,7 @@ <%= render "users/upgrade_notice" %> <% end %> - <% if !CurrentUser.is_privileged? && CurrentUser.user.created_at > 2.weeks.ago %> + <% if cookies["accepted_tos"].blank? && !CurrentUser.is_privileged? %> <%= render "users/tos" %> <% end %> diff --git a/app/views/static/terms_of_service.html.erb b/app/views/static/terms_of_service.html.erb index 81cb2d859..0ed4aec0e 100644 --- a/app/views/static/terms_of_service.html.erb +++ b/app/views/static/terms_of_service.html.erb @@ -50,6 +50,11 @@

Danbooru will not disclose the IP address, email address, password, or DMails of any user except to the staff.

Danbooru is allowed to make public everything else, including but not limited to: uploaded posts, favorited posts, comments, forum posts, wiki edits, and note edits.

+ + <%= form_tag(accept_terms_of_service_path) do %> + <%= hidden_field_tag :url, params[:url] %> + <%= submit_tag "I have read and agree to these rules" %> + <% end %> <% content_for(:page_title) do %> diff --git a/app/views/users/_tos.html.erb b/app/views/users/_tos.html.erb index f0df1d8d2..e323724d2 100644 --- a/app/views/users/_tos.html.erb +++ b/app/views/users/_tos.html.erb @@ -1,3 +1,3 @@
-

<%= link_to "Read the rules before proceeding!", terms_of_service_path %>

+

<%= link_to "Read the rules before proceeding!", terms_of_service_path(:url => request.fullpath) %>

diff --git a/config/routes.rb b/config/routes.rb index 8347591c9..15aacccf2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -311,6 +311,7 @@ Danbooru::Application.routes.draw do match "/static/bookmarklet" => "static#bookmarklet", :as => "bookmarklet" match "/static/site_map" => "static#site_map", :as => "site_map" match "/static/terms_of_service" => "static#terms_of_service", :as => "terms_of_service" + match "/static/accept_terms_of_service" => "static#accept_terms_of_service", :as => "accept_terms_of_service" match "/static/mrtg" => "static#mrtg", :as => "mrtg" match "/static/contact" => "static#contact", :as => "contact" match "/static/benchmark" => "static#benchmark"