# HG changeset patch # User Chris Cannam # Date 1300879904 0 # Node ID 861eb230b8fe04fe22aa2cf7a80676f9319765ca # Parent 23c69f60a959320bf9c4988a2c3d8a8490d8d468# Parent fa07572ee073d0e660162633b012dd2610b25972 Merge from branch "bug_95" diff -r fa07572ee073 -r 861eb230b8fe app/controllers/application_controller.rb --- a/app/controllers/application_controller.rb Wed Mar 23 11:31:14 2011 +0000 +++ b/app/controllers/application_controller.rb Wed Mar 23 11:31:44 2011 +0000 @@ -263,6 +263,12 @@ uri = URI.parse(back_url) # do not redirect user to another host or to the login or register page if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)}) + # soundsoftware: if login page is https but back_url http, + # switch back_url to https to ensure cookie validity (#83) + if (uri.scheme == "http") && (URI.parse(request.url).scheme == "https") + uri.scheme = "https" + back_url = uri.to_s + end redirect_to(back_url) return end diff -r fa07572ee073 -r 861eb230b8fe app/controllers/attachments_controller.rb --- a/app/controllers/attachments_controller.rb Wed Mar 23 11:31:14 2011 +0000 +++ b/app/controllers/attachments_controller.rb Wed Mar 23 11:31:44 2011 +0000 @@ -16,9 +16,11 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class AttachmentsController < ApplicationController + before_filter :find_project before_filter :file_readable, :read_authorize, :except => :destroy before_filter :delete_authorize, :only => :destroy + before_filter :active_authorize, :only => :toggle_active verify :method => :post, :only => :destroy @@ -54,6 +56,12 @@ redirect_to :controller => 'projects', :action => 'show', :id => @project end + def toggle_active + @attachment.active = !@attachment.active? + @attachment.save! + render :layout => false + end + private def find_project @attachment = Attachment.find(params[:id]) @@ -77,6 +85,10 @@ @attachment.deletable? ? true : deny_access end + def active_authorize + true + end + def detect_content_type(attachment) content_type = attachment.content_type if content_type.blank? diff -r fa07572ee073 -r 861eb230b8fe app/controllers/files_controller.rb --- a/app/controllers/files_controller.rb Wed Mar 23 11:31:14 2011 +0000 +++ b/app/controllers/files_controller.rb Wed Mar 23 11:31:44 2011 +0000 @@ -10,6 +10,7 @@ def index sort_init 'filename', 'asc' sort_update 'filename' => "#{Attachment.table_name}.filename", + 'active' => "#{Attachment.table_name}.active", 'created_on' => "#{Attachment.table_name}.created_on", 'size' => "#{Attachment.table_name}.filesize", 'downloads' => "#{Attachment.table_name}.downloads" @@ -33,4 +34,5 @@ end redirect_to project_files_path(@project) end + end diff -r fa07572ee073 -r 861eb230b8fe app/controllers/members_controller.rb --- a/app/controllers/members_controller.rb Wed Mar 23 11:31:14 2011 +0000 +++ b/app/controllers/members_controller.rb Wed Mar 23 11:31:44 2011 +0000 @@ -54,8 +54,8 @@ errors = members.collect {|m| m.errors.full_messages }.flatten.uniq - - page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', '))) + + # page.alert(l(:notice_failed_to_save_members, :errors => errors.join(', '))) } } diff -r fa07572ee073 -r 861eb230b8fe app/views/attachments/toggle_active.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/views/attachments/toggle_active.rhtml Wed Mar 23 11:31:44 2011 +0000 @@ -0,0 +1,7 @@ +<%= +file = Attachment.find(params[:id]) +active_id = "active-" + file.id.to_s +link_to_remote image_tag(file.active? ? 'fav.png' : 'fav_off.png'), + :url => {:controller => 'attachments', :action => 'toggle_active', :project_id => @project.id, :id => file}, + :update => active_id +%> diff -r fa07572ee073 -r 861eb230b8fe app/views/files/index.html.erb --- a/app/views/files/index.html.erb Wed Mar 23 11:31:14 2011 +0000 +++ b/app/views/files/index.html.erb Wed Mar 23 11:31:44 2011 +0000 @@ -5,29 +5,51 @@
MD5 | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
+ | <%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package") %> | |||||||||||
<%= link_to_attachment file, :download => true, :title => file.description %> | +||||||||||||
+ <% have_file = true %>
+ <% if active_change_allowed
+ active_id = "active-" + file.id.to_s -%>
+
+ <%= link_to_remote image_tag(file.active? ? 'fav.png' : 'fav_off.png'),
+ :url => {:controller => 'attachments', :action => 'toggle_active', :project_id => @project.id, :id => file},
+ :update => active_id
+ %>
+
+ <% else -%>
+ <%= image_tag('fav.png') if file.active? %>
+ <% end -%>
+ |
+ <% if file.active? %>
+ <%= link_to_attachment file, :download => true %> <%= h(file.description) %> |
+ <% else %>
+ <%= link_to_attachment file, :download => true, :title => file.description %> + <% end %> + | <%= format_time(file.created_on) %> | <%= number_to_human_size(file.filesize) %> | <%= file.downloads %> | @@ -43,4 +65,6 @@