Skip to content

Commit

Permalink
Merge branch 'release/0.17'
Browse files Browse the repository at this point in the history
  • Loading branch information
crowbot committed Mar 4, 2014
2 parents 8e911d5 + a38b298 commit ede46dc
Show file tree
Hide file tree
Showing 172 changed files with 15,108 additions and 1,311 deletions.
5 changes: 0 additions & 5 deletions .cvsignore

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ GEM
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
will_paginate (3.0.4)
will_paginate (3.0.5)
xapian-full-alaveteli (1.2.9.5)
xml-simple (1.1.2)
zip (2.0.2)
Expand Down
14 changes: 14 additions & 0 deletions app/assets/javascripts/new-request.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
$(document).ready(function() {
$('.batch_public_body_list').hide();
var showtext = $('.batch_public_body_toggle').attr('data-showtext');
var hidetext = $('.batch_public_body_toggle').attr('data-hidetext');
$('.toggle-message').text(showtext);
$('.batch_public_body_toggle').click(function(){
$('.batch_public_body_list').toggle();
if ($('.toggle-message').text() == showtext){
$('.toggle-message').text(hidetext);
}else{
$('.toggle-message').text(showtext);
}
})
})
67 changes: 67 additions & 0 deletions app/assets/javascripts/select-authorities.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
$(document).ready(function() {

function add_option(selector, value, text) {
var optionExists = ($(selector + ' option[value=' + value + ']').length > 0);
if(!optionExists){
$(selector).append("<option value=" + value + ">" + text + "</option>");
}
}
// Transfer a set of select options defined by 'from_selector' to another select,
// defined by 'to_selector'
function transfer_options(from_selector, to_selector){
$(from_selector).each(function()
{
add_option(to_selector, $(this).val(), $(this).text());
$(this).remove();
})
$('#public_body_query').val('');
return false;
}

// Submit the search form once the text reaches a certain length
$("#public_body_query").keypress($.debounce( 300, function() {
if ($('#public_body_query').val().length >= 3) {
$('#body_search_form').submit();
}
}));

// Populate the candidate list with json search results
$('#body_search_form').on('ajax:success', function(event, data, status, xhr) {
$('#select_body_candidates').empty();
$.each(data, function(key, value)
{
add_option('#select_body_candidates', value['id'], value['name']);
});
});

// Add a hidden element to the submit form for every option in the selected list
$('#body_submit_button').click(function(){
$('#select_body_selections option').each(function()
{
$('#body_submit_form').append('<input type="hidden" value="' + $(this).val() + '" name="public_body_ids[]">' );
})
})

// Transfer selected candidates to selected list
$('#body_select_button').click(function(){
return transfer_options('#select_body_candidates option:selected', '#select_body_selections');
})

// Transfer selected selected options back to candidate list
$('#body_deselect_button').click(function(){
return transfer_options('#select_body_selections option:selected', '#select_body_candidates');
})

// Transfer all candidates to selected list
$('#body_select_all_button').click(function(){
return transfer_options('#select_body_candidates option', '#select_body_selections');
})

// Transfer all selected back to candidate list
$('#body_deselect_all_button').click(function(){
return transfer_options('#select_body_selections option', '#select_body_candidates');
})

// Show the buttons for selecting and deselecting all
$('.select_all_button').show();
})
47 changes: 46 additions & 1 deletion app/assets/stylesheets/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1722,7 +1722,7 @@ padding-right:50px;
margin-bottom:10px;
}

div.ff-icon-printfix,.comment_in_request_text img.comment_quote,body.front #other-country-notice,#other-country-notice,#authority_preview .public-body-name-prefix,#authority_preview #list-filter,#authority_preview h2.foi_results,div#show_response_view p.event_actions {
div.ff-icon-printfix,.comment_in_request_text img.comment_quote,body.front #other-country-notice,#other-country-notice,#authority_preview .public-body-name-prefix,#authority_preview #list-filter,#authority_preview h2.foi_results,div#show_response_view p.event_actions, div.batch_public_body_toggle {
display:none;
}

Expand Down Expand Up @@ -1777,3 +1777,48 @@ text-decoration:none;
the axes black rather than transparent grey for the moment: */
color: #000 !important;
}


#body_selection .body_list {
width: 45%;
}

#body_selection .body_list input[type='submit'] {
margin: 10px 0;
width: 45%;
}

#body_selection .body_list #body_select_all_button,
#body_selection .body_list #body_deselect_button{
float: right;
}

#body_selection #body_candidates {
float: left;
}

#body_selection #body_selections {
float: right;
}

#body_selection #body_submission input[type='submit'] {
margin: 10px 0;
width:100%;
}

#body_selection .select_all_button {
display: none;
}

#body_selection .body_select {
width: 100%;
}

.batch_public_body_list {
margin-left: 110px;
}

.batch_public_body_toggle {
color: #0000EE;
font-size: 0.9em;
}
13 changes: 8 additions & 5 deletions app/controllers/admin_general_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,16 @@ def index
@comment_count = Comment.count

# Tasks to do
@requires_admin_requests = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => ["described_state = 'requires_admin'"], :order => "last_event_time")
@error_message_requests = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => ["described_state = 'error_message'"], :order => "last_event_time")
@attention_requests = InfoRequest.find(:all, :select => '*, ' + InfoRequest.last_event_time_clause + ' as last_event_time', :conditions => ["described_state = 'attention_requested'"], :order => "last_event_time")
@blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"], :order => "updated_at")
@requires_admin_requests = InfoRequest.find_in_state('requires_admin')
@error_message_requests = InfoRequest.find_in_state('error_message')
@attention_requests = InfoRequest.find_in_state('attention_requested')
@blank_contacts = PublicBody.find(:all, :conditions => ["request_email = ''"],
:order => "updated_at")
@old_unclassified = InfoRequest.find_old_unclassified(:limit => 20,
:conditions => ["prominence = 'normal'"])
:conditions => ["prominence = 'normal'"])
@holding_pen_messages = InfoRequest.holding_pen_request.incoming_messages
@new_body_requests = PublicBodyChangeRequest.new_body_requests.open
@body_update_requests = PublicBodyChangeRequest.body_update_requests.open
end

def timeline
Expand Down
15 changes: 15 additions & 0 deletions app/controllers/admin_public_body_change_requests_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class AdminPublicBodyChangeRequestsController < AdminController

def edit
@change_request = PublicBodyChangeRequest.find(params[:id])
end

def update
@change_request = PublicBodyChangeRequest.find(params[:id])
@change_request.close!
@change_request.send_response(params[:subject], params[:response])
flash[:notice] = 'The change request has been closed and the user has been notified'
redirect_to admin_general_index_path
end

end
42 changes: 39 additions & 3 deletions app/controllers/admin_public_body_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,33 @@ def show

def new
@public_body = PublicBody.new
render
if params[:change_request_id]
@change_request = PublicBodyChangeRequest.find(params[:change_request_id])
end
if @change_request
@change_request_user_response = render_to_string(:template => "admin_public_body_change_requests/add_accepted",
:formats => [:txt])
@public_body.name = @change_request.public_body_name
@public_body.request_email = @change_request.public_body_email
@public_body.last_edit_comment = @change_request.comment_for_public_body
end
render :formats => [:html]
end

def create
I18n.with_locale(I18n.default_locale) do
if params[:change_request_id]
@change_request = PublicBodyChangeRequest.find(params[:change_request_id])
end
params[:public_body][:last_edit_editor] = admin_current_user()
@public_body = PublicBody.new(params[:public_body])
if @public_body.save
if @change_request
response_text = params[:response].gsub(_("[Authority URL will be inserted here]"),
public_body_url(@public_body, :only_path => false))
@change_request.close!
@change_request.send_response(params[:subject], response_text)
end
flash[:notice] = 'PublicBody was successfully created.'
redirect_to admin_body_show_url(@public_body)
else
Expand All @@ -103,15 +122,32 @@ def create

def edit
@public_body = PublicBody.find(params[:id])
@public_body.last_edit_comment = ""
render
if params[:change_request_id]
@change_request = PublicBodyChangeRequest.find(params[:change_request_id])
end
if @change_request
@change_request_user_response = render_to_string(:template => "admin_public_body_change_requests/update_accepted",
:formats => [:txt])
@public_body.request_email = @change_request.public_body_email
@public_body.last_edit_comment = @change_request.comment_for_public_body
else
@public_body.last_edit_comment = ""
end
render :formats => [:html]
end

def update
if params[:change_request_id]
@change_request = PublicBodyChangeRequest.find(params[:change_request_id])
end
I18n.with_locale(I18n.default_locale) do
params[:public_body][:last_edit_editor] = admin_current_user()
@public_body = PublicBody.find(params[:id])
if @public_body.update_attributes(params[:public_body])
if @change_request
@change_request.close!
@change_request.send_response(params[:subject], params[:response])
end
flash[:notice] = 'PublicBody was successfully updated.'
redirect_to admin_body_show_url(@public_body)
else
Expand Down
19 changes: 9 additions & 10 deletions app/controllers/admin_request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@ def list

def show
@info_request = InfoRequest.find(params[:id])
# XXX is this *really* the only way to render a template to a
# variable, rather than to the response?
vars = OpenStruct.new(:name_to => @info_request.user_name,
:name_from => AlaveteliConfiguration::contact_name,
:info_request => @info_request, :reason => params[:reason],
:info_request_url => 'http://' + AlaveteliConfiguration::domain + request_url(@info_request),
:site_name => site_name)
template = File.read(File.join(File.dirname(__FILE__), "..", "views", "admin_request", "hidden_user_explanation.html.erb"))
@request_hidden_user_explanation = ERB.new(template).result(vars.instance_eval { binding })
vars_for_explanation = {:reason => params[:reason],
:info_request => @info_request,
:name_to => @info_request.user_name,
:name_from => AlaveteliConfiguration::contact_name,
:info_request_url => request_url(@info_request, :only_path => false)}
@request_hidden_user_explanation = render_to_string(:template => "admin_request/hidden_user_explanation",
:locals => vars_for_explanation)
end

def resend
Expand Down Expand Up @@ -281,7 +279,8 @@ def hide_request

if ! info_request.is_external?
ContactMailer.from_admin_message(
info_request.user,
info_request.user.name,
info_request.user.email,
subject,
params[:explanation].strip.html_safe
).deliver
Expand Down
1 change: 1 addition & 0 deletions app/controllers/admin_user_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def update
@admin_user.ban_text = params[:admin_user][:ban_text]
@admin_user.about_me = params[:admin_user][:about_me]
@admin_user.no_limit = params[:admin_user][:no_limit]
@admin_user.can_make_batch_requests = params[:admin_user][:can_make_batch_requests]

if @admin_user.valid?
@admin_user.save!
Expand Down
Loading

0 comments on commit ede46dc

Please sign in to comment.