Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
Merge commit 'ari/master' into dev
Browse files Browse the repository at this point in the history
Conflicts:
	app/models/task.rb
  • Loading branch information
Fudge committed Feb 17, 2009
2 parents fadef08 + 61ded58 commit 19ca87e
Show file tree
Hide file tree
Showing 10 changed files with 163 additions and 82 deletions.
14 changes: 2 additions & 12 deletions app/models/notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,7 @@ def created(task, user, note = "", sent_at = Time.now)
@body = {:task => task, :user => user, :note => note}
@subject = "#{$CONFIG[:prefix]} #{_('Created')}: #{task.issue_name} [#{task.project.name}] (#{(task.users.empty? ? _('Unassigned') : task.users.collect{|u| u.name}.join(', '))})"

@recipients = ""
@recipients = [user.email] if user.receive_notifications > 0
@recipients += task.users.collect{ |u| u.email if u.receive_notifications > 0 } unless task.users.empty?
@recipients += task.watchers.collect{|w| w.email if w.receive_notifications > 0}
@recipients += task.notify_emails.split(',').collect{|e| e.strip} unless (task.notify_emails.nil? || task.notify_emails.length == 0)
@recipients.uniq!
@recipients = task.notification_email_addresses(user)

@from = "#{$CONFIG[:from]}@#{$CONFIG[:email_domain]}"
@sent_on = sent_at
Expand All @@ -33,12 +28,7 @@ def changed(update_type, task, user, change, sent_at = Time.now)

@body = {:task => task, :user => user, :change => change}

@recipients = ""
@recipients = [user.email] if user.receive_notifications > 0
@recipients += task.users.collect{ |u| u.email if u.receive_notifications > 0 } unless task.users.empty?
@recipients += task.watchers.collect{|w| w.email if w.receive_notifications > 0}
@recipients += task.notify_emails.split(',').collect{|e| e.strip} unless (task.notify_emails.nil? || task.notify_emails.length == 0)
@recipients.uniq!
@recipients = task.notification_email_addresses(user)

@from = "#{$CONFIG[:from]}@#{$CONFIG[:email_domain]}"
@sent_on = sent_at
Expand Down
40 changes: 39 additions & 1 deletion app/models/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ def low?
end

###
#
# Generate a cache key from all changing data
###
def cache_expiry(current_user)
# due / completed ago
Expand Down Expand Up @@ -838,4 +838,42 @@ def cache_expiry(current_user)
"#{locale_part}#{due_part}#{worked_part}#{config_part}"
end

###
# Returns an array of email addresses of people who should be
# notified about changes to this task.
###
def notification_email_addresses(user_who_made_change = nil)
recipients = [ ]

if user_who_made_change and
user_who_made_change.receive_notifications?
recipients << user_who_made_change
end

# add in watchers and users
recipients += users.select { |u| u.receive_notifications? }
recipients += watchers.select { |u| u.receive_notifications? }
recipients = recipients.uniq.compact

# remove them if they don't want their own notifications.
# do it here rather than at start of method in case they're
# on the watchers list, etc
if user_who_made_change and
!user_who_made_change.receive_own_notifications?
recipients.delete(user_who_made_change)
end

emails = recipients.map { |u| u.email }

# add in notify emails
if !notify_emails.blank?
emails += notify_emails.split(",")
end
emails = emails.compact.map { |e| e.strip }

# and finally remove dupes
emails = emails.uniq

return emails
end
end
3 changes: 1 addition & 2 deletions app/views/layouts/application.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
<td align=left class="page_header tooltip" width="100%" colspan="2" title="<%= _'Easy access to commonly needed information.'%>">
<div style="float:left;"><%=_ 'Notes'%></div><div style="float:right;padding-top:0.1em;"><%= link_to _('New'), :controller => 'pages', :action => 'new' %></div></td>
</tr>
<tr><td colspan="2"><div style="height:0.2em;"></div></td></tr>
<tr><td colspan="2"><div style="height:0.2em;"></div></td></tr>
<% for page in current_pages %>
<tr>
<td align=left class="pages_item" colspan=2><%= link_to "#{page.name} / #{page.project.name}", { :controller => 'pages', :action => 'show', :id => page} %> <small>(<%=_('%s ago', time_ago_in_words( page.updated_at, false ) )%>)</small></td>
Expand All @@ -158,7 +158,6 @@
</td></tr>
</table>
</div></td>
</td>
</tr>
</table>

Expand Down
74 changes: 32 additions & 42 deletions app/views/tasks/_form.rhtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<%= error_messages_for 'task' %>
<!--[form:task]-->
<%

perms = {}

['comment', 'edit', 'reassign', 'prioritize', 'close', 'milestone'].each do |p|
Expand All @@ -10,11 +10,7 @@
perms[p] = { :disabled => 'disabled' }
end
end

%>

<!--[form:task]-->

<tr>
<td valign="top">
<fieldset id="task_information" style="padding-right:0.5em;"><legend><%=_ 'Information' %></legend>
Expand All @@ -27,15 +23,6 @@
<%= text_area 'task', 'description', { :rows => 15, :style => "width:80%;" }.merge( perms['edit'] ) %> <br />
<label for="comment"><%=_ 'Comment' %></label>
<%= text_area_tag 'comment', {}, { :rows => 8, :style => "width:80%;" }.merge( perms['comment'] ) %> <br />
<label for="task_tmp_file"><%=_ 'Attach file' %></label>
<div id="upload_container">
<%= file_field_tag 'tmp_files[]', { :size => 35, :class => "file" }.merge( perms['comment'] ) %>
<% if perms['comment'].empty? %>
<span style="float:left;padding-right:0.4em;padding-top:0.4em"><%= link_to_function _("Upload more files") do |page|
page.insert_html :bottom, :upload_container, "<label>&nbsp;</label><input type=\"file\" size=\"35\" name=\"tmp_files[]\"/><br />"
end %></span>
<% end %>
<br />
</div>


Expand Down Expand Up @@ -84,8 +71,6 @@


<% unless @tags.nil? %>


<script type="text/javascript">
new Autocompleter.Local('task_set_tags', 'task_set_tags_auto_complete', [<%= @tags.collect {|t| "'#{t[0].gsub(/'/, "\\\\\'")}'"}.join(', ') %>], {tokens:[','], minChars:0, frequency: 0, choices: 15});
</script>
Expand Down Expand Up @@ -180,8 +165,6 @@ else
num = num + 1
end



%>

<% if current_user.option_tracktime.to_i == 1%>
Expand Down Expand Up @@ -212,8 +195,6 @@ end
<% end %>
<% end %>



</fieldset>

<fieldset id="task_notify" style="padding-right:0;">
Expand Down Expand Up @@ -305,8 +286,6 @@ updateList('<%= w.gsub(/'/, "\\\\\'") %>');

jQuery('#task_due_at').datepicker();

jQuery('#task_due_at').datepicker();

</script>

</fieldset>
Expand Down Expand Up @@ -341,8 +320,6 @@ jQuery('#task_due_at').datepicker();
<input name="dependencies[]" size="12" type="text" disabled="disabled">
<% end %>



<% @task.dependencies.each do |d| %>
<div class="dependency_no">
<% if perms['prioritize'].empty? %>
Expand All @@ -354,31 +331,44 @@ jQuery('#task_due_at').datepicker();
<input name="dependencies[]" type="hidden" value="<%=d.task_num%>">
<span class="divider"></span>
</div>

<% end %>

</fieldset>

<% unless @task.dependants.empty? %>
<fieldset id="task_dependants" style="padding-right:0;">
<legend><%=_ "Depended on by"%></legend>

<% @task.dependants.each do |d| %>
<% unless @task.dependants.empty? %>
<div style="clear:both">
<label for="dependants"><%=_ "Depended on by"%></label>
<% @task.dependants.each do |d| %>
<%= link_to_task(d) %><br/>
<% end %>
</div>
<% end %>

<div id="dep_<%=d.id%>">
<div><% if d.done? %><img src="/images/tick.png" border="0"><% else %><img src="/images/spacer.gif" width="16px"><% end %><%= link_to_task(d) %></div>
</div>
<% end %>
</fieldset>

</fieldset>
<fieldset id="task_attachments" style="padding-right:0;">
<legend><%=_ "Attachments" %></legend>
<% for file in @task.attachments %>
<% if file.thumbnail? %>
<div>
<%= link_to image_tag("/project_files/thumbnail/#{file.id}", {:border=>0, :style=>'float:none'}), {:controller => 'project_files', :action => 'download', :id => file.id.to_s + "." + file.file_extension}, {:rel=>'shadowbox'} %>
</div>
<% end %>



<%= link_to h(file.name), {:controller => 'project_files', :action => 'download', :id => file.id.to_s + "." + file.file_extension}, {:rel=>'shadowbox'} %><em> (<%=number_to_human_size(file.file_size)%>)</em>
<%= link_to image_tag("/images/cross_small.png", :border=>0), {:controller => 'project_files', :action => 'destroy', :id => file.id}, :confirm => _("Really delete %s?", file.name), :class => 'close-cross' %>
<span class="divider"></span>
<% end %>

<label for="task_tmp_file"><%=_ 'Attach file' %></label>
<div id="upload_container">
<%= file_field_tag 'tmp_files[]', { :size => 15, :class => "file" }.merge( perms['comment'] ) %>
</div>
<% if perms['comment'].empty? %>
<span style="float:left"><%= link_to_function _("Upload more files") do |page|
page.insert_html :bottom, :upload_container, "<label>&nbsp;</label><input type=\"file\" size=\"15\" class\"file\" name=\"tmp_files[]\"/><br />"
end %></span>
<% end %>
</fieldset>

</td>
</tr>



<!--[eoform:task]-->
24 changes: 2 additions & 22 deletions app/views/tasks/edit.rhtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% form_tag({ :action => 'update', :id => @task}, { :multipart => "true", :id => "taskform" }) do %>
<%
form_tag({ :action => 'update', :id => @task}, { :multipart => "true", :id => "taskform" }) do %>
<table cellpadding="0" cellspacing="0" class="content" width="100%" style="padding-left: 1em; padding-right: 1em;">
<tr>
<td align="left" colspan="3" class="page_header" id="task_page_header">
Expand Down Expand Up @@ -52,27 +53,6 @@ $('comment').focus();
}
</style>

<div style="float:right;width:20%;padding-right:1em;">

<% if @task.attachments.size > 0 %>
<fieldset id="task_attachments">
<legend><%=_ "Attachments" %></legend>

<% for file in @task.attachments %>
<% if file.thumbnail? %>
<div>
<%= link_to image_tag("/project_files/thumbnail/#{file.id}", {:border=>0, :style=>'float:none'}), {:controller => 'project_files', :action => 'download', :id => file.id.to_s + "." + file.file_extension}, {:rel=>'shadowbox'} %>
</div>
<% end %>
<%= link_to h(file.name), {:controller => 'project_files', :action => 'download', :id => file.id.to_s + "." + file.file_extension}, {:rel=>'shadowbox'} %><em> (<%=number_to_human_size(file.file_size)%>)</em>
<%= link_to image_tag("/images/cross_small.png", :border=>0), {:controller => 'project_files', :action => 'destroy', :id => file.id}, :confirm => _("Really delete %s?", file.name), :class => 'close-cross' %>
<span class="divider"></span>
<% end %>

</fieldset>
<% end %>
</div>

<div id="content" style="width:79%;">
<table cellpadding="0" cellspacing="0" class="content" width="100%" style="padding-left: 1em; padding-right: 1em;">
<tr><td>&nbsp;</td></tr>
Expand Down
1 change: 1 addition & 0 deletions app/views/users/_form.rhtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<label for="user_option_tooltips"><%=_ 'Show Tooltips' %></label><%= check_box 'user', 'option_tooltips' %><br/>
<label for="user_send_notifications"><%=_ 'Send Notifications' %></label><%= check_box 'user', 'send_notifications' %><br/>
<label for="user_receive_notifications"><%=_ 'Receive Notifications' %></label><%= check_box 'user', 'receive_notifications' %><br/>
<label for="user_receive_own_notifications"><%=_ 'Receive Own Notifications' %></label><%= check_box 'user', 'receive_own_notifications' %><br/>
</fieldset>
<br>
<!--[eoform:user]-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
class ConvertTypePrioritySeverityToProperties < ActiveRecord::Migration
def self.up
deactivate_project_stat_counts

add_column Property.table_name, :default_sort, :boolean unless Property.column_names.include?('default_sort')
add_column Property.table_name, :default_color, :boolean unless Property.column_names.include?('default_color')
change_column PropertyValue.table_name, :default, :boolean

Property.reset_column_information

Company.find(:all).each do |c|
type, priority, severity = c.create_default_properties
c.tasks.each_with_index do |t, i|
Expand All @@ -24,9 +28,13 @@ def self.up
View.find(:all).each do |v|
v.convert_attributes_to_properties
end

reactivate_project_stat_counts
end

def self.down
deactivate_project_stat_counts

Company.find(:all).each do |c|
c.tasks.each do |t|
t.convert_properties_to_attributes
Expand All @@ -49,5 +57,27 @@ def self.down

remove_column Property.table_name, :default_sort
remove_column Property.table_name, :default_color

reactivate_project_stat_counts
end

def self.deactivate_project_stat_counts
Project.class_eval do
alias :old_update_project_stats :update_project_stats
def update_project_stats
# do nothing
end
end
end

def self.reactivate_project_stat_counts
Project.class_eval do
alias :update_project_stats :old_update_project_stats
end

Project.find(:all).each do |p|
p.update_project_stats
p.save
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class AddReceiveOwnNotificationsToUser < ActiveRecord::Migration
def self.up
add_column(User.table_name, :receive_own_notifications, :boolean, :default => true)
end

def self.down
remove_column(User.table_name, :receive_own_notifications)
end
end
7 changes: 4 additions & 3 deletions public/stylesheets/tt.css
Original file line number Diff line number Diff line change
Expand Up @@ -548,12 +548,13 @@ fieldset#task_information select { float: none; }
fieldset input.file {
clear: right;
text-align: left;
font-size: 95%;
width: 50%;
font-size: 90%;
width: 90%;
padding-right: 1em;
margin-top: 0;
margin-bottom: 0;
}


fieldset div.buttons {
padding-top: 0.5em;
}
Expand Down
Loading

0 comments on commit 19ca87e

Please sign in to comment.