aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/controllers/request_controller.rb29
-rw-r--r--app/helpers/config_helper.rb4
-rw-r--r--app/views/layouts/default.rhtml24
-rw-r--r--app/views/layouts/no_chrome.rhtml47
-rw-r--r--app/views/request/new.rhtml42
-rw-r--r--app/views/user/signin_successful.rhtml6
-rw-r--r--config/general.yml-example3
7 files changed, 90 insertions, 65 deletions
diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb
index b7c8767cc..e13291c2d 100644
--- a/app/controllers/request_controller.rb
+++ b/app/controllers/request_controller.rb
@@ -23,6 +23,17 @@ class RequestController < ApplicationController
end
def select_authority
+ # Check whether we force the user to sign in right at the start, or we allow her
+ # to start filling the request anonymously
+ if force_registration_on_new_request && !authenticated?(
+ :web => _("To send your FOI request"),
+ :email => _("Then you'll be allowed to send FOI requests."),
+ :email_subject => _("Confirm your email address")
+ )
+ # do nothing - as "authenticated?" has done the redirect to signin page for us
+ return
+ end
+
medium_cache
end
@@ -276,15 +287,6 @@ class RequestController < ApplicationController
return
end
- if !authenticated?(
- :web => _("To send your FOI request"),
- :email => _("Then your FOI request to {{public_body_name}} will be sent.",:public_body_name=>@info_request.public_body.name),
- :email_subject => _("Confirm your FOI request to ") + @info_request.public_body.name
- )
- # do nothing - as "authenticated?" has done the redirect to signin page for us
- return
- end
-
# Show preview page, if it is a preview
if params[:preview].to_i == 1
message = ""
@@ -307,6 +309,15 @@ class RequestController < ApplicationController
return
end
+ if !authenticated?(
+ :web => _("To send your FOI request"),
+ :email => _("Then your FOI request to {{public_body_name}} will be sent.",:public_body_name=>@info_request.public_body.name),
+ :email_subject => _("Confirm your FOI request to ") + @info_request.public_body.name
+ )
+ # do nothing - as "authenticated?" has done the redirect to signin page for us
+ return
+ end
+
@info_request.user = authenticated_user
# This automatically saves dependent objects, such as @outgoing_message, in the same transaction
@info_request.save!
diff --git a/app/helpers/config_helper.rb b/app/helpers/config_helper.rb
index 80f2deed2..b0381a2f5 100644
--- a/app/helpers/config_helper.rb
+++ b/app/helpers/config_helper.rb
@@ -2,4 +2,8 @@ module ConfigHelper
def site_name
MySociety::Config.get('SITE_NAME', 'Alaveteli')
end
+
+ def force_registration_on_new_request
+ MySociety::Config.get('FORCE_REGISTRATION_ON_NEW_REQUEST', false)
+ end
end \ No newline at end of file
diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml
index d4a506594..069ed9787 100644
--- a/app/views/layouts/default.rhtml
+++ b/app/views/layouts/default.rhtml
@@ -51,6 +51,28 @@
</head>
<body>
+ <!-- XXX: move to a separate file -->
+ <% if force_registration_on_new_request && !@user %>
+ <%= javascript_include_tag 'jquery.fancybox-1.3.4.pack' %>
+ <script>
+ $(document).ready(function() {
+ $("#make-request-link").fancybox({
+ 'modal': false,
+ 'width': 800,
+ 'height': 500,
+ 'type': 'iframe',
+ 'href': '/en/profile/sign_in?modal=1',
+ 'onClosed': function() {
+ // modal_signin_successful variable set by modal dialog box
+ if (typeof modal_signin_successful != 'undefined' ) {
+ window.location.href = '<%= select_authority_url %>';
+ }
+ }
+ });
+ });
+ </script>
+ <% end %>
+
<% # code for popup advert for a campaign etc.
=begin
<div id="everypage" class="jshide">
@@ -96,7 +118,7 @@
<div id="topnav">
<ul id="navigation">
<li class="<%= 'selected' if params[:controller] == 'general' %>"><%= link_to _("Home"), select_authority_url %></li>
- <li class="<%= 'selected' if params[:controller] == 'request' and ['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("Make a request"), select_authority_url %></li>
+ <li class="<%= 'selected' if params[:controller] == 'request' and ['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("Make a request"), select_authority_url, :id => 'make-request-link' %></li>
<li class="<%= 'selected' if params[:controller] == 'request' and !['new', 'select_authority'].include?(params[:action]) %>"><%= link_to _("View requests"), request_list_successful_url %></li>
<li class="<%= 'selected' if params[:controller] == 'public_body' %>"><%= link_to _("View authorities"), list_public_bodies_default %></li>
<li class="<%= 'selected' if params[:controller] == 'blog' %>"><%= link_to _("Read blog"), blog_url %></li>
diff --git a/app/views/layouts/no_chrome.rhtml b/app/views/layouts/no_chrome.rhtml
index 8225aec75..c314dfbd3 100644
--- a/app/views/layouts/no_chrome.rhtml
+++ b/app/views/layouts/no_chrome.rhtml
@@ -1,14 +1,39 @@
-<div class="entirebody">
- <div id="content">
- <% if flash[:notice] %>
- <div id="notice"><%= flash[:notice] %></div>
- <% end %>
- <% if flash[:error] %>
- <div id="error"><%= flash[:error] %></div>
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html lang="<%= I18n.locale %>">
+ <head>
+ <title>
+ <% if @title %>
+ <%=@title%> - <%= site_name %>
+ <% else %>
+ <%= site_name %> - <%= _('Make and browse Freedom of Information (FOI) requests') %>
<% end %>
+ </title>
+
+ <script type="text/javascript" src="/javascripts/jquery.js"></script>
+
+ <%= stylesheet_link_tag 'main', :title => "Main", :rel => "stylesheet" %>
+ <!--[if LT IE 7]>
+ <style type="text/css">@import url("/stylesheets/ie6.css");</style>
+ <![endif]-->
+ <!--[if LT IE 7]>
+ <style type="text/css">@import url("/stylesheets/ie6-custom.css");</style>
+ <![endif]-->
+ <%= stylesheet_link_tag 'custom', :title => "Main", :rel => "stylesheet" %>
+ </head>
+ <body>
+ <div class="entirebody">
+ <div id="content">
+ <% if flash[:notice] %>
+ <div id="notice"><%= flash[:notice] %></div>
+ <% end %>
+ <% if flash[:error] %>
+ <div id="error"><%= flash[:error] %></div>
+ <% end %>
- <div id="<%= controller.controller_name + "_" + controller.action_name %>" class="controller_<%= controller.controller_name %>">
- <%= yield :layout %>
+ <div id="<%= controller.controller_name + "_" + controller.action_name %>" class="controller_<%= controller.controller_name %>">
+ <%= yield :layout %>
+ </div>
+ </div>
</div>
- </div>
-</div>
+ </body>
+</html> \ No newline at end of file
diff --git a/app/views/request/new.rhtml b/app/views/request/new.rhtml
index 5ddec100f..cd748b6c2 100644
--- a/app/views/request/new.rhtml
+++ b/app/views/request/new.rhtml
@@ -9,47 +9,6 @@
});
</script>
-<%
- enable_modal_signin = false;
-%>
-
-<% if enable_modal_signin && !@user %>
-<%= javascript_include_tag 'jquery.fancybox-1.3.4.pack' %>
-<%= javascript_include_tag 'jquery.form' %>
-<script>
- function onSuccessfulLogin() {
- $.fancybox.close();
- $("#write_form").ajaxFormUnbind();
- $("#write_form").submit();
- }
-
- function interceptFormSubmit(form_id) {
- $(form_id).ajaxForm({
- success: function(responseText) {
- $("#fancybox-content").html(responseText);
- interceptFormSubmits();
- }
- });
- };
-
- function interceptFormSubmits() {
- interceptFormSubmit("#signin_form");
- interceptFormSubmit("#signup_form");
- };
-
- $(document).ready(function() {
- $("#write_form").ajaxForm({
- success: function(responseText) {
- $.fancybox({
- 'content': responseText,
- 'onComplete': interceptFormSubmits
- });
- }
- });
- });
-</script>
-<% end %>
-
<% @title = _("Make an {{law_used_short}} request to '{{public_body_name}}'",:law_used_short=>h(@info_request.law_used_short),:public_body_name=>h(@info_request.public_body.name)) %>
<% if @existing_request %>
@@ -170,7 +129,6 @@
<%= f.hidden_field(:public_body_id, { :value => @info_request.public_body_id } ) %>
<%= hidden_field_tag(:submitted_new_request, 1 ) %>
<%= hidden_field_tag(:preview, 1 ) %>
- <%= hidden_field_tag(:modal, 1 ) if enable_modal_signin %>
<%= submit_tag _("Preview your public request") %>
</div>
diff --git a/app/views/user/signin_successful.rhtml b/app/views/user/signin_successful.rhtml
index 38aebb846..762bfa763 100644
--- a/app/views/user/signin_successful.rhtml
+++ b/app/views/user/signin_successful.rhtml
@@ -1,7 +1,9 @@
<%= _("You're in. <a href=\"#\" id=\"send-request\">Continue sending your request</a>") %>
-<script>
+<script>
+ parent.modal_signin_successful = true;
+
$("#send-request").click(function() {
- onSuccessfulLogin(); return false;
+ parent.$.fancybox.close(); return false;
});
</script> \ No newline at end of file
diff --git a/config/general.yml-example b/config/general.yml-example
index 3537cd792..e2652c848 100644
--- a/config/general.yml-example
+++ b/config/general.yml-example
@@ -36,6 +36,9 @@ FRONTPAGE_PUBLICBODY_EXAMPLES: 'tgq'
# URL of theme to install (when running rails-post-deploy script)
THEME_URL: 'git://github.com/mysociety/whatdotheyknow-theme.git'
+# Whether a user needs to sign in to start the New Request process
+FORCE_REGISTRATION_ON_NEW_REQUEST: false
+
## Incoming email
# Your email domain, e.g. 'foifa.com'