changeset 304:6c56a595dc1c cannam-pre-20110113-merge

Merge from branch "feature_73"
author Chris Cannam
date Mon, 28 Mar 2011 17:32:56 +0100
parents 93b4cfd3aaaa (diff) defe55be97b9 (current diff)
children f5a3d57f3d90
files config/locales/en-GB.yml config/locales/en.yml config/routes.rb
diffstat 14 files changed, 168 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/app/controllers/attachments_controller.rb	Thu Mar 24 15:48:36 2011 +0000
+++ b/app/controllers/attachments_controller.rb	Mon Mar 28 17:32:56 2011 +0100
@@ -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?
--- a/app/controllers/files_controller.rb	Thu Mar 24 15:48:36 2011 +0000
+++ b/app/controllers/files_controller.rb	Mon Mar 28 17:32:56 2011 +0100
@@ -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
--- a/app/controllers/members_controller.rb	Thu Mar 24 15:48:36 2011 +0000
+++ b/app/controllers/members_controller.rb	Mon Mar 28 17:32:56 2011 +0100
@@ -28,12 +28,24 @@
       attrs = params[:member].dup
       if (user_ids = attrs.delete(:user_ids))
         user_ids.each do |user_id|
-          members << Member.new(attrs.merge(:user_id => user_id))
+          @new_member = Member.new(attrs.merge(:user_id => user_id))
+          members << @new_member
+
+          # send notification to member
+          Mailer.deliver_added_to_project(@new_member, @project)
+
         end
       else
-        members << Member.new(attrs)
+        @new_member = Member.new(attrs)
+        members << @new_member
+        
+        # send notification to member
+        Mailer.deliver_added_to_project(@new_member, @project)
+        
       end
+
       @project.members << members
+
     end
     respond_to do |format|
       if members.present? && members.all? {|m| m.valid? }
@@ -54,8 +66,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(', ')))
           }
         }
         
--- a/app/models/mailer.rb	Thu Mar 24 15:48:36 2011 +0000
+++ b/app/models/mailer.rb	Mon Mar 28 17:32:56 2011 +0100
@@ -31,6 +31,27 @@
     h = h.to_s.gsub(%r{\/.*$}, '') unless Redmine::Utils.relative_url_root.blank?
     { :host => h, :protocol => Setting.protocol }
   end
+
+
+
+  # Builds a tmail object used to email the specified user that he was added to a project
+  #
+  # Example:
+  #   add_to_project(user) => tmail object
+  #   Mailer.deliver_add_to_project(user) => sends an email to the registered user
+  def added_to_project(member, project)
+
+    user = User.find(member.user_id)
+
+    set_language_if_valid user.language
+    recipients user.mail
+    subject l(:mail_subject_added_to_project, Setting.app_title)
+    body :project_url => url_for(:controller => 'projects', :action => 'show', :id => project.id),
+        :project_name => project.name
+    render_multipart('added_to_project', body)
+  end
+
+
   
   # Builds a tmail object used to email recipients of the added issue.
   #
@@ -440,3 +461,7 @@
     end
   end
 end
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/views/attachments/toggle_active.rhtml	Mon Mar 28 17:32:56 2011 +0100
@@ -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
+%>
--- a/app/views/files/index.html.erb	Thu Mar 24 15:48:36 2011 +0000
+++ b/app/views/files/index.html.erb	Mon Mar 28 17:32:56 2011 +0100
@@ -5,29 +5,51 @@
 <h2><%=l(:label_attachment_plural)%></h2>
 
 <% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
+<% active_change_allowed = delete_allowed %>
 
 <table class="list files">
   <thead><tr>
+    <%= sort_header_tag('active', :caption => l(:field_active)) %>
     <%= sort_header_tag('filename', :caption => l(:field_filename)) %>
     <%= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc') %>
     <%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc') %>
-    <%= sort_header_tag('downloads', :caption => l(:label_downloads_abbr), :default_order => 'desc') %>
+    <%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc') %>
     <th>MD5</th>
     <th></th>
   </tr></thead>
   <tbody>
+<% have_file = false %>
 <% @containers.each do |container| %>	
   <% next if container.attachments.empty? -%>
 	<% if container.is_a?(Version) -%>
   <tr>
-  	<th colspan="6" align="left">
+  	<th colspan="7" align="left">
   		<%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package") %>
 		</th>
 	</tr>
 	<% end -%>
   <% container.attachments.each do |file| %>		
-  <tr class="file <%= cycle("odd", "even") %>">
-    <td class="filename"><%= link_to_attachment file, :download => true, :title => file.description %></td>
+  <tr class="file <%= cycle("odd", "even") %> <%= "active" if file.active? %>">
+    <td class="active">
+      <% have_file = true %>
+      <% if active_change_allowed
+           active_id = "active-" + file.id.to_s -%>
+        <div id="<%= active_id %>">
+        <%= 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
+        %>
+        </div>
+      <% else -%>
+        <%= image_tag('fav.png') if file.active? %>
+      <% end -%>
+    </td>
+    <% if file.active? %>
+      <td class="filename active"><%= link_to_attachment file, :download => true %><br><span class="description"><%= h(file.description) %></span></td>
+    <% else %>
+      <td class="filename"><%= link_to_attachment file, :download => true, :title => file.description %>
+    <% end %>
+    </td>
     <td class="created_on"><%= format_time(file.created_on) %></td>
     <td class="filesize"><%= number_to_human_size(file.filesize) %></td>
     <td class="downloads"><%= file.downloads %></td>
@@ -43,4 +65,6 @@
   </tbody>
 </table>
 
+<%= l(:text_files_active_change) if active_change_allowed and have_file %>
+
 <% html_title(l(:label_attachment_plural)) -%>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/views/mailer/added_to_project.text.html.rhtml	Mon Mar 28 17:32:56 2011 +0100
@@ -0,0 +1,3 @@
+<p><%= l(:notice_added_to_project, :project_name => @project_name) %></p>
+<p><%= l(:notice_project_homepage, :project_url => @project_url) %></p>
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/views/mailer/added_to_project.text.plain.rhtml	Mon Mar 28 17:32:56 2011 +0100
@@ -0,0 +1,2 @@
+<%= l(:notice_added_to_project, :project_name => @project_name) %>
+<%= l(:notice_project_homepage, :project_url => @project_url)  %>
--- a/app/views/projects/settings/_members.rhtml	Thu Mar 24 15:48:36 2011 +0000
+++ b/app/views/projects/settings/_members.rhtml	Mon Mar 28 17:32:56 2011 +0100
@@ -2,6 +2,7 @@
 <% roles = Role.find_all_givable
    members = @project.member_principals.find(:all, :include => [:roles, :principal]).sort %>
 
+
 <div class="splitcontentleft">
 <% if members.any? %>
 <table class="list members">
@@ -73,10 +74,11 @@
 		<% end %>
 		</div>
 		
-    <p><%= l(:label_role_plural) %>:
+    <p><%= l(:label_set_role_plural) %>:</p>
+    <p>
     <% roles.each do |role| %>
-    	<label><%= check_box_tag 'member[role_ids][]', role.id %> <%=h role %></label>
-   	<% end %></p>
+    	<label><%= check_box_tag 'member[role_ids][]', role.id %> <%=h role %> </label><div style="margin-left: 2em; margin-bottom: 0.5em"><i><%=l( 'label_' + role.name.downcase + "_description").to_sym %></i></div>
+   	<% end %>
    	
     <p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>
 		</fieldset>
--- a/config/locales/en-GB.yml	Thu Mar 24 15:48:36 2011 +0000
+++ b/config/locales/en-GB.yml	Mon Mar 28 17:32:56 2011 +0100
@@ -482,7 +482,6 @@
   label_information_plural: Information
   label_please_login: Please log in
   label_register: Register
-  label_terms_and_conditions: Terms & Conditions for use of code.soundsoftware.ac.uk
   label_login_with_open_id_option: or login with OpenID
   label_password_lost: Lost password
   label_home: Home
@@ -967,3 +966,13 @@
   label_user_search: "Search for user:"
   field_visible: Visible
   setting_emails_header: Emails header
+
+  label_manager_description: All powers including adding and removing members and adjusting project settings
+  label_developer_description: Can commit to repository and carry out most project editing tasks
+  label_reporter_description: Can submit bug reports; has read access for private projects
+
+  label_set_role_plural: Choose roles for new member
+  notice_added_to_project: 'You have been added to the project "{{project_name}}".'
+  notice_project_homepage: "You can visit the project using the following link: {{project_url}}"
+  mail_subject_added_to_project: "You've been added to a project on {{value}}"
+  
\ No newline at end of file
--- a/config/locales/en.yml	Thu Mar 24 15:48:36 2011 +0000
+++ b/config/locales/en.yml	Mon Mar 28 17:32:56 2011 +0100
@@ -493,8 +493,6 @@
   label_information_plural: Information
   label_please_login: Please log in
   label_register: Register
-  label_terms_and_conditions: Terms & Conditions for use of code.soundsoftware.ac.uk
-  label_accept_terms_and_conditions: I have read the terms and conditions and fully accept them
   label_login_with_open_id_option: or login with OpenID
   label_password_lost: Lost password
   label_home: Home
@@ -865,6 +863,7 @@
   version_status_closed: closed
 
   field_active: Active
+  field_current: Current
   
   text_select_mail_notifications: Select actions for which email notifications should be sent.
   text_regexp_info: eg. ^[A-Z0-9]+$
@@ -929,6 +928,7 @@
   text_own_membership_delete_confirmation: "You are about to remove some or all of your permissions and may no longer be able to edit this project after that.\nAre you sure you want to continue?"
   text_zoom_in: Zoom in
   text_zoom_out: Zoom out
+  text_files_active_change: <br>Click the star to switch active status for a download on or off.<br>Active files will be shown more prominently in the download page.
   text_settings_repo_creation: <b>Creating repository...</b></p><p>The source code repository for a project will be set up automatically within a few minutes of the project being created.</p><p>Please check again in five minutes, and <a href="/projects/soundsoftware-site/wiki/Help">contact us</a> if there is any problem.</p><p>If you wish to use this project to track a repository that is already hosted somewhere else, please wait until the repository has been created here and then return to this settings page to configure it.</p><p>If you don't want a repository at all, go to the Modules tab and switch it off there.
   text_settings_repo_explanation: <b>External repositories</b><p>Normally your project's primary repository will be the Mercurial repository hosted at this site.<p>However, if you already have your project hosted somewhere else, you can specify your existing external repository's URL here &ndash; then this site will track that repository in a read-only &ldquo;mirror&rdquo; copy.  External Mercurial, git and Subversion repositories can be tracked. Note that you cannot switch to an external repository if you have already made any commits to the repository hosted here.
   text_settings_repo_is_internal: Currently the repository hosted at this site is the primary repository for this project.
@@ -936,7 +936,7 @@
   text_settings_repo_need_help: Please <a href="/projects/soundsoftware-site/wiki/Help">contact us</a> if you need help deciding how best to set this up.<br>We can also import complete revision history from other systems into a new primary repository for you if you wish.
 
 
-  
+ 
   default_role_manager: Manager
   default_role_developer: Developer
   default_role_reporter: Reporter
@@ -964,3 +964,17 @@
   enumeration_activities: Activities (time tracking)
   enumeration_system_activity: System Activity
 
+  label_manager_description: All powers including adding and removing members and adjusting project settings
+  label_developer_description: Can commit to repository and carry out most project editing tasks
+  label_reporter_description: Can submit bug reports; has read access for private projects
+
+  label_set_role_plural: Choose roles for new member
+
+  label_manager_description: All powers including adding and removing members and adjusting project settings
+  label_developer_description: Can commit to repository and carry out most project editing tasks
+  label_reporter_description: Can submit bug reports; has read access for private projects
+
+  label_set_role_plural: Choose roles for new member
+  notice_added_to_project: 'You have been added to the project "{{project_name}}".'
+  notice_project_homepage: "You can visit the project using the following link: {{project_url}}"
+  mail_subject_added_to_project: "You've been added to a project on {{value}}"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/db/migrate/20110303152903_add_active_column_to_attachments.rb	Mon Mar 28 17:32:56 2011 +0100
@@ -0,0 +1,9 @@
+class AddActiveColumnToAttachments < ActiveRecord::Migration
+  def self.up
+    add_column :attachments, :active, :boolean
+  end
+
+  def self.down
+    remove_column :attachments, :active
+  end
+end
--- a/public/stylesheets/application.css	Thu Mar 24 15:48:36 2011 +0000
+++ b/public/stylesheets/application.css	Mon Mar 28 17:32:56 2011 +0100
@@ -157,7 +157,7 @@
 tr.changeset td.committed_on { text-align: center; width: 15%; }
 
 table.files tr.file td { text-align: center; }
-table.files tr.file td.filename { text-align: left; padding-left: 24px; }
+table.files tr.file td.filename { text-align: left; }
 table.files tr.file td.digest { font-size: 80%; }
 
 table.members td.roles, table.memberships td.roles { width: 45%; }
--- a/public/themes/soundsoftware/stylesheets/application.css	Thu Mar 24 15:48:36 2011 +0000
+++ b/public/themes/soundsoftware/stylesheets/application.css	Mon Mar 28 17:32:56 2011 +0100
@@ -37,16 +37,41 @@
 
 body,p,h2,h3,h4,li,table,.wiki h1 { 
   font-family: DroidSans, 'Liberation Sans', tahoma, verdana, sans-serif; 
+  line-height: 1.34;
 }
 
 h2,h3,h4,.wiki h1 {
   color: #3e442c;
+  font-weight: bold;
+}
+
+.wiki h2,.wiki h3,.wiki h4 {
+  color: #000;
 }
 
 h2,.wiki h1 {
-    font-size: 1.8em;
+  font-size: 1.8em;
 }
 
+.wiki h2 {
+  margin-top: 1em;
+}
+
+.splitcontentleft p:first-child {
+  margin-top: 0;
+}
+
+div.attachments {
+  margin-top: 2em;
+}
+#wiki_add_attachment {
+  margin-top: 1.5em;
+}
+
+/* Hide these (the paragraph markers that show anchors) -- they confuse more than they help */
+a.wiki-anchor:hover { display: none; }
+h1:hover a.wiki-anchor, h2:hover a.wiki-anchor, h3:hover a.wiki-anchor { display: none; }
+
 .box {
     padding: 6px;
     margin-bottom: 10px;
@@ -81,6 +106,10 @@
 
 ul.projects .public, ul.projects .private { padding-left: 0.5em; color: #3e442c; font-size: 0.95em }
 
+table.files tr.active td { padding-top: 0.5em; padding-bottom: 0.5em; }
+table.files .file .active { font-weight: bold; }
+table.files .file .description { font-weight: normal; color: #3e442c; }
+
 #top-menu { position: absolute; top: 0; z-index: 1; left: 0px; width: 100%; font-size: 90%; /* height: 2em; */ margin: 0; padding: 0; padding-top: 0.5em; background-color: #3e442c; }
 #top-menu ul { margin-left: 10px; }
 #top-menu a { font-weight: bold; }
@@ -98,7 +127,7 @@
 #project-jump-box { float: right;  margin-right: 6px; margin-top: 5px; color: #000; }
 #project-ancestors-title {
     margin-bottom: 0px;
-    margin-left: 10px;
+    margin-left: 12px;
     margin-top: 6px;
     font-family: GilliusADFNo2, 'Gill Sans', Tahoma, sans-serif;
     font-weight: normal;